LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 1401-ct-Allow-ct_netconfc-edit_config-3-4-5-to-take-a-lis.patch of Package erlang (Project home:Ledest:erlang:20)

From 871f133a49ecdc59a4e9d81d532ac6d7d78aa6db Mon Sep 17 00:00:00 2001
From: Siri Hansen <siri@erlang.org>
Date: Thu, 31 Jan 2019 14:49:31 +0100
Subject: [PATCH] [ct] Allow ct_netconfc:edit_config/3,4,5 to take a list of
 XML elements

The yang RFC allows more than one top element of config data in an
edit-config element.
---
 lib/common_test/src/ct_netconfc.erl                            | 10 ++++++----
 .../test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl            |  6 ++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl
index 29188a648e..6a758c4ea3 100644
--- a/lib/common_test/src/ct_netconfc.erl
+++ b/lib/common_test/src/ct_netconfc.erl
@@ -583,7 +583,7 @@ get_config(Client, Source, Filter, Timeout) ->
 -spec edit_config(Client, Target, Config) -> Result when
       Client :: client(),
       Target :: netconf_db(),
-      Config :: simple_xml(),
+      Config :: simple_xml() | [simple_xml()],
       Result :: ok | {error,error_reason()}.
 edit_config(Client, Target, Config) ->
     edit_config(Client, Target, Config, ?DEFAULT_TIMEOUT).
@@ -591,7 +591,7 @@ edit_config(Client, Target, Config) ->
 -spec edit_config(Client, Target, Config, OptParams) -> Result when
       Client :: client(),
       Target :: netconf_db(),
-      Config :: simple_xml(),
+      Config :: simple_xml() | [simple_xml()],
       OptParams :: [simple_xml()],
       Result :: ok | {error,error_reason()};
                  (Client, Target, Config, Timeout) -> Result when
@@ -608,10 +608,12 @@ edit_config(Client, Target, Config, OptParams) when is_list(OptParams) ->
 -spec edit_config(Client, Target, Config, OptParams, Timeout) -> Result when
       Client :: client(),
       Target :: netconf_db(),
-      Config :: simple_xml(),
+      Config :: simple_xml() | [simple_xml()],
       OptParams :: [simple_xml()],
       Timeout :: timeout(),
       Result :: ok | {error,error_reason()}.
+edit_config(Client, Target, Config, OptParams, Timeout) when not is_list(Config)->
+    edit_config(Client, Target, [Config], OptParams, Timeout);
 edit_config(Client, Target, Config, OptParams, Timeout) ->
     call(Client, {send_rpc_op, edit_config, [Target,Config,OptParams], Timeout}).
 
@@ -1113,7 +1115,7 @@ encode_rpc_operation(get,[Filter]) ->
 encode_rpc_operation(get_config,[Source,Filter]) ->
     {'get-config',[{source,[Source]}] ++ filter(Filter)};
 encode_rpc_operation(edit_config,[Target,Config,OptParams]) ->
-    {'edit-config',[{target,[Target]}] ++ OptParams ++ [{config,[Config]}]};
+    {'edit-config',[{target,[Target]}] ++ OptParams ++ [{config,Config}]};
 encode_rpc_operation(delete_config,[Target]) ->
     {'delete-config',[{target,[Target]}]};
 encode_rpc_operation(copy_config,[Target,Source]) ->
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index a2fa099a8c..0d17481e95 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
@@ -440,6 +440,12 @@ edit_config(Config) ->
     ?ok = ct_netconfc:edit_config(Client,running,
 				  {server,[{xmlns,"myns"}],
 				   [{name,["myserver"]}]}),
+    ?NS:expect_reply('edit-config',ok),
+    ?ok = ct_netconfc:edit_config(Client,running,
+				  [{server,[{xmlns,"myns"}],
+                                    [{name,["server1"]}]},
+                                   {server,[{xmlns,"myns"}],
+                                    [{name,["server2"]}]}]),
     ?NS:expect_do_reply('close-session',close,ok),
     ?ok = ct_netconfc:close_session(Client),
     ok.
-- 
2.16.4