diff options
Diffstat (limited to 'lib/common_test/src/ct_netconfc.erl')
| -rw-r--r-- | lib/common_test/src/ct_netconfc.erl | 68 | 
1 files changed, 53 insertions, 15 deletions
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl index 80ffb51ab9..0de7bf03af 100644 --- a/lib/common_test/src/ct_netconfc.erl +++ b/lib/common_test/src/ct_netconfc.erl @@ -3,16 +3,17 @@  %%  %% Copyright Ericsson AB 2012-2014. All Rights Reserved.  %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at  %% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%%     http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License.  %%  %% %CopyrightEnd%  %% @@ -191,6 +192,7 @@  	 get_config/4,  	 edit_config/3,  	 edit_config/4, +	 edit_config/5,  	 delete_config/2,  	 delete_config/3,  	 copy_config/3, @@ -691,15 +693,39 @@ get_config(Client, Source, Filter, Timeout) ->  %%----------------------------------------------------------------------  %% @spec edit_config(Client, Target, Config) -> Result -%% @equiv edit_config(Client, Target, Config, infinity) +%% @equiv edit_config(Client, Target, Config, [], infinity)  edit_config(Client, Target, Config) ->      edit_config(Client, Target, Config, ?DEFAULT_TIMEOUT).  %%---------------------------------------------------------------------- --spec edit_config(Client, Target, Config, Timeout) -> Result when +-spec edit_config(Client, Target, Config, OptParamsOrTimeout) -> Result when        Client :: client(),        Target :: netconf_db(),        Config :: simple_xml(), +      OptParamsOrTimeout :: [simple_xml()] | timeout(), +      Result :: ok | {error,error_reason()}. +%% @doc +%% +%% If `OptParamsOrTimeout' is a timeout value, then this is +%% equivalent to {@link edit_config/5. edit_config(Client, Target, +%% Config, [], Timeout)}. +%% +%% If `OptParamsOrTimeout' is a list of simple XML, then this is +%% equivalent to {@link edit_config/5. edit_config(Client, Target, +%% Config, OptParams, infinity)}. +%% +%% @end +edit_config(Client, Target, Config, Timeout) when ?is_timeout(Timeout) -> +    edit_config(Client, Target, Config, [], Timeout); +edit_config(Client, Target, Config, OptParams) when is_list(OptParams) -> +    edit_config(Client, Target, Config, OptParams, ?DEFAULT_TIMEOUT). + +%%---------------------------------------------------------------------- +-spec edit_config(Client, Target, Config, OptParams, Timeout) -> Result when +      Client :: client(), +      Target :: netconf_db(), +      Config :: simple_xml(), +      OptParams :: [simple_xml()],        Timeout :: timeout(),        Result :: ok | {error,error_reason()}.  %% @doc Edit configuration data. @@ -708,10 +734,20 @@ edit_config(Client, Target, Config) ->  %% include `:candidate' or `:startup' in its list of  %% capabilities.  %% +%% `OptParams' can be used for specifying optional parameters +%% (`default-operation', `test-option' or `error-option') that will be +%% added to the `edit-config' request. The value must be a list +%% containing valid simple XML, for example +%% +%% ``` +%% [{'default-operation', ["none"]}, +%%  {'error-option', ["rollback-on-error"]}] +%%''' +%%  %% @end  %%---------------------------------------------------------------------- -edit_config(Client, Target, Config, Timeout) -> -    call(Client, {send_rpc_op, edit_config, [Target,Config], Timeout}). +edit_config(Client, Target, Config, OptParams, Timeout) -> +    call(Client, {send_rpc_op, edit_config, [Target,Config,OptParams], Timeout}).  %%---------------------------------------------------------------------- @@ -1100,6 +1136,7 @@ handle_msg({get_event_streams=Op,Streams,Timeout}, From, State) ->      SimpleXml = encode_rpc_operation(get,[Filter]),      do_send_rpc(Op, SimpleXml, Timeout, From, State). +%% @private  handle_msg({ssh_cm, CM, {data, Ch, _Type, Data}}, State) ->      ssh_connection:adjust_window(CM,Ch,size(Data)),      handle_data(Data, State); @@ -1254,8 +1291,8 @@ encode_rpc_operation(get,[Filter]) ->      {get,filter(Filter)};  encode_rpc_operation(get_config,[Source,Filter]) ->      {'get-config',[{source,[Source]}] ++ filter(Filter)}; -encode_rpc_operation(edit_config,[Target,Config]) -> -    {'edit-config',[{target,[Target]},{config,[Config]}]}; +encode_rpc_operation(edit_config,[Target,Config,OptParams]) -> +    {'edit-config',[{target,[Target]}] ++ OptParams ++ [{config,[Config]}]};  encode_rpc_operation(delete_config,[Target]) ->      {'delete-config',[{target,[Target]}]};  encode_rpc_operation(copy_config,[Target,Source]) -> @@ -1712,6 +1749,7 @@ log(#connection{host=Host,port=Port,name=Name},Action,Data) ->  %% Log callback - called from the error handler process +%% @private  format_data(How,Data) ->      %% Assuming that the data is encoded as UTF-8.  If it is not, then      %% the printout might be wrong, but the format function will not  | 
