From: Samuel Schneider Date: Wed, 18 Sep 2024 14:53:23 +0000 (+0200) Subject: Adapt CSIT for netconf-node state encapsulation X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ac4054c099e2bfda7dfd25f47a5db1b79b5b7a16;p=integration%2Ftest.git Adapt CSIT for netconf-node state encapsulation Adapt scripts used in scale test suites. Use payload with node encapsulation if version is at least scandium. JIRA: INTTEST-146 Change-Id: I4ebcc33b1c00d40bc74023f2f936406c72bb6b8b Signed-off-by: Samuel Schneider --- diff --git a/csit/libraries/TopologyNetconfNodes.py b/csit/libraries/TopologyNetconfNodes.py index 0dd5fb78d2..06e41cd518 100644 --- a/csit/libraries/TopologyNetconfNodes.py +++ b/csit/libraries/TopologyNetconfNodes.py @@ -16,6 +16,7 @@ def configure_device_range( device_ipaddress, device_port, device_count, + use_node_encapsulation, first_device_id=1, ): """Generate device_count names in format "$device_name_prefix-$i" and configure them into NETCONF topology at specified RESTCONF URL. @@ -70,29 +71,10 @@ def configure_device_range( for i in range(first_device_id, first_device_id + device_count): name = "{}-{}".format(device_name_prefix, i) device_names.append(name) - edits.append( - """ - { - "edit-id" : "node-%s", - "operation" : "replace", - "target" : "/network-topology:node[network-topology:node-id='%s']", - "value" : { - "node" : [ - { - "node-id" : "%s", - "netconf-node-topology:host" : "%s", - "netconf-node-topology:port" : %s, - "netconf-node-topology:username" : "admin", - "netconf-node-topology:password" : "topsecret", - "netconf-node-topology:tcp-only" : false, - "netconf-node-topology:keepalive-delay" : 0 - } - ] - } - } - """ - % (name, name, name, device_ipaddress, device_port) - ) + if use_node_encapsulation: + edits.append(get_encapsulated_payload(name, device_ipaddress, device_port)) + else: + edits.append(get_legacy_payload(name, device_ipaddress, device_port)) data = """ { @@ -171,6 +153,70 @@ def configure_device_range( return device_names +def get_legacy_payload(name, device_ipaddress, device_port): + return """ + { + "edit-id" : "node-%s", + "operation" : "replace", + "target": "/node=%s", + "value" : { + "node" : [ + { + "node-id" : "%s", + "netconf-node-topology:host" : "%s", + "netconf-node-topology:port" : %s, + "netconf-node-topology:login-password-unencrypted": { + "username": "admin", + "password": "topsecret" + }, + "netconf-node-topology:tcp-only" : false, + "netconf-node-topology:keepalive-delay" : 0 + } + ] + } + } + """ % ( + name, + name, + name, + device_ipaddress, + device_port, + ) + + +def get_encapsulated_payload(name, device_ipaddress, device_port): + return """ + { + "edit-id" : "node-%s", + "operation" : "replace", + "target": "/node=%s", + "value" : { + "node" : [ + { + "node-id" : "%s", + "netconf-node-topology:netconf-node":{ + "host" : "%s", + "port" : %s, + "login-password-unencrypted": { + "username": "admin", + "password": "topsecret" + }, + "tcp-only" : false, + "keepalive-delay" : 0 + } + } + ] + } + } + """ % ( + name, + name, + name, + device_ipaddress, + device_port, + ) + + def await_devices_connected(restconf_url, device_names, deadline_seconds): """Await all specified devices to become connected in NETCONF topology at specified RESTCONF URL.""" @@ -228,6 +274,7 @@ def main(args): device_ipaddress="127.0.0.1", device_port=17830, device_count=int(args[1]), + use_node_encapsulation=True, ) print(names) elif args[0] == "await": diff --git a/csit/suites/netconf/clusteringscale/topology_leader_ha.robot b/csit/suites/netconf/clusteringscale/topology_leader_ha.robot index f60809d83f..b3da798667 100644 --- a/csit/suites/netconf/clusteringscale/topology_leader_ha.robot +++ b/csit/suites/netconf/clusteringscale/topology_leader_ha.robot @@ -87,9 +87,10 @@ Start_Configurer [Documentation] Launch Python utility (while copying output to log file) and verify it does not stop by itself. ${log_filename} = Utils.Get_Log_File_Name configurer BuiltIn.Set_Suite_Variable \${log_filename} + ${use_node_encapsulation} = CompareStream.Set_Variable_If_At_Least_Scandium True False # TODO: Should things like restconf port/user/password be set from Variables? ${command} = BuiltIn.Set_Variable - ... python configurer.py --odladdress ${entity_ownership_leader_ip} --deviceaddress ${TOOLS_SYSTEM_IP} --devices ${DEVICE_SET_SIZE} --disconndelay ${CONFIGURED_DEVICES_LIMIT} --basename ${DEVICE_BASE_NAME} --connsleep ${CONNECTION_SLEEP} &> "${log_filename}" + ... python configurer.py --odladdress ${entity_ownership_leader_ip} --deviceaddress ${TOOLS_SYSTEM_IP} --devices ${DEVICE_SET_SIZE} --disconndelay ${CONFIGURED_DEVICES_LIMIT} --basename ${DEVICE_BASE_NAME} --connsleep ${CONNECTION_SLEEP} --encapsulation ${use_node_encapsulation} &> "${log_filename}" SSHLibrary.Write ${command} ${status} ${text} = BuiltIn.Run_Keyword_And_Ignore_Error SSHLibrary.Read_Until_Prompt BuiltIn.Log ${text} diff --git a/csit/suites/netconf/clusteringscale/topology_owner_ha.robot b/csit/suites/netconf/clusteringscale/topology_owner_ha.robot index 77c4e8bc83..16cee8efc6 100644 --- a/csit/suites/netconf/clusteringscale/topology_owner_ha.robot +++ b/csit/suites/netconf/clusteringscale/topology_owner_ha.robot @@ -111,9 +111,10 @@ Start_Configurer [Documentation] Launch Python utility (while copying output to log file) and verify it does not stop by itself. ${log_filename} = Utils.Get_Log_File_Name configurer BuiltIn.Set_Suite_Variable \${log_filename} + ${use_node_encapsulation} = CompareStream.Set_Variable_If_At_Least_Scandium True False # TODO: Should things like restconf port/user/password be set from Variables? ${command} = BuiltIn.Set_Variable - ... python configurer.py --odladdress ${topology_config_leader_ip} --deviceaddress ${TOOLS_SYSTEM_IP} --devices ${DEVICE_SET_SIZE} --disconndelay ${CONFIGURED_DEVICES_LIMIT} --basename ${DEVICE_BASE_NAME} --connsleep ${CONNECTION_SLEEP} &> "${log_filename}" + ... python configurer.py --odladdress ${topology_config_leader_ip} --deviceaddress ${TOOLS_SYSTEM_IP} --devices ${DEVICE_SET_SIZE} --disconndelay ${CONFIGURED_DEVICES_LIMIT} --basename ${DEVICE_BASE_NAME} --connsleep ${CONNECTION_SLEEP} --encapsulation ${use_node_encapsulation} &> "${log_filename}" SSHLibrary.Write ${command} ${status} ${text} = BuiltIn.Run_Keyword_And_Ignore_Error SSHLibrary.Read_Until_Prompt BuiltIn.Log ${text} diff --git a/csit/suites/netconf/scale/max_devices.robot b/csit/suites/netconf/scale/max_devices.robot index ac29a77bb9..4c15b2ff06 100644 --- a/csit/suites/netconf/scale/max_devices.robot +++ b/csit/suites/netconf/scale/max_devices.robot @@ -83,12 +83,14 @@ Find Max Netconf Devices END ${devices_to_configure} = BuiltIn.Evaluate ${devices} - len(${device_names}) ${first_id} = BuiltIn.Evaluate len(${device_names}) + 1 + ${use_node_encapsulation} = CompareStream.Set_Variable_If_At_Least_Scandium ${True} ${False} ${device_names} = TopologyNetconfNodes.Configure Device Range ... restconf_url=${restconf_url} ... device_name_prefix=${DEVICE_NAME_BASE} ... device_ipaddress=${TOOLS_SYSTEM_IP} ... device_port=17830 ... device_count=${devices_to_configure} + ... use_node_encapsulation=${use_node_encapsulation} ... first_device_id=${first_id} TopologyNetconfNodes.Await Devices Connected ... restconf_url=${restconf_url} diff --git a/tools/netconf_tools/configurer.py b/tools/netconf_tools/configurer.py index 98892c15b8..628277358c 100644 --- a/tools/netconf_tools/configurer.py +++ b/tools/netconf_tools/configurer.py @@ -122,23 +122,49 @@ def parse_arguments(): type=str2bool, help="Should single requests session be re-used", ) + parser.add_argument( + "--encapsulation", + default="True", + type=str2bool, + help="If payload with node encapsulation should be used", + ) return parser.parse_args() # arguments are read -DATA_TEMPLATE = string.Template( +LEGACY_DATA_TEMPLATE = string.Template( """{ "network-topology:node": { "node-id": "$DEVICE_NAME", "netconf-node-topology:host": "$DEVICE_IP", "netconf-node-topology:port": $DEVICE_PORT, - "netconf-node-topology:username": "$DEVICE_USER", - "netconf-node-topology:password": "$DEVICE_PASSWORD", + "netconf-node-topology:login-password-unencrypted": { + "username": "$DEVICE_USER", + "password": "$DEVICE_PASSWORD" + }, "netconf-node-topology:tcp-only": "false", "netconf-node-topology:keepalive-delay": 0 } }""" ) +ENCAPSULATION_DATA_TEMPLATE = string.Template( + """{ + "network-topology:node": { + "node-id": "$DEVICE_NAME", + "netconf-node-topology:netconf-node":{ + "host": "$DEVICE_IP", + "port": $DEVICE_PORT, + "login-password-unencrypted": { + "username": "$DEVICE_USER", + "password": "$DEVICE_PASSWORD" + }, + "tcp-only": "false", + "keepalive-delay": 0 + } + } +}""" +) + def count_response(counter, response, method): """Add counter item built from response data and given method.""" @@ -211,7 +237,10 @@ def main(): put_name = args.basename + "-" + str(port) + "-" + str(iteration) subst_dict["DEVICE_NAME"] = put_name subst_dict["DEVICE_PORT"] = str(port) - put_data = DATA_TEMPLATE.substitute(subst_dict) + if args.encapsulation: + put_data = ENCAPSULATION_DATA_TEMPLATE.substitute(subst_dict) + else: + put_data = LEGACY_DATA_TEMPLATE.substitute(subst_dict) uri = uri_part + put_name response = AuthStandalone.Put_Using_Session( session, uri, data=put_data, headers=put_headers