Library RequestsLibrary
Library SSHLibrary
Resource NexusKeywords.robot
+Resource Restconf.robot
Resource SSHKeywords.robot
Resource TemplatedRequests.robot
Resource Utils.robot
# This keyword should be renamed but without an automatic keyword naming standards checker this is
# potentially destabilizing change so right now it is as FIXME. Proposed new name:
# Count_Device_Instances_In_Netconf_Topology
- ${mounts}= TemplatedRequests.Get_As_Json_From_Uri ${OPERATIONAL_API}/network-topology:network-topology/topology/topology-netconf session=${session}
+ ${uri} = Restconf.Generate URI network-topology:network-topology operational
+ ${mounts}= TemplatedRequests.Get_As_Json_From_Uri ${uri} session=${session}
Builtin.Log ${mounts}
${actual_count}= Builtin.Evaluate len('''${mounts}'''.split('"node-id": "${device_name}"'))-1
Builtin.Return_From_Keyword ${actual_count}
[Arguments] ${device_name} ${session}=default
[Documentation] Check that the specified device has no Netconf connectors nor associated data.
Check_Device_Has_No_Netconf_Connector ${device_name} session=${session}
- ${uri}= Builtin.Set_Variable ${CONFIG_API}/network-topology:network-topology/topology/topology-netconf/node/${device_name}
+ ${uri} = Restconf.Generate URI network-topology:network-topology config topology=topology-netconf node=${device_name}
${status} ${response}= BuiltIn.Run_Keyword_And_Ignore_Error TemplatedRequests.Get_As_Xml_From_Uri ${uri} session=${session}
BuiltIn.Should_Be_Equal_As_Strings ${status} FAIL
BuiltIn.Should_Contain ${response} 404
Check_Device_Connected
[Arguments] ${device_name} ${session}=default
[Documentation] Check that the specified device is accessible from Netconf.
- ${device_status}= TemplatedRequests.Get_As_Json_From_Uri ${OPERATIONAL_API}/network-topology:network-topology/topology/topology-netconf/node/${device_name} session=${session}
+ ${uri} = Restconf.Generate URI network-topology:network-topology operational topology=topology-netconf node=${device_name}
+ ${device_status}= TemplatedRequests.Get_As_Json_From_Uri ${uri} session=${session}
Builtin.Should_Contain ${device_status} "netconf-node-topology:connection-status": "connected"
Wait_Device_Connected
--- /dev/null
+*** Settings ***
+
+*** Variables ***
+${USE_RFC8040} = False
+
+*** Keywords ***
+
+Generate URI
+ [Arguments] ${identifier} ${datastore}=config @{node_value_list}
+ [Documentation] Returns the proper URI to use depending on if RFC8040 is to be used or not. Variable input
+ ... error checking is done to ensure the ${USE_RFC8040} Flag is one of True or False and the ${datastore} variable
+ ... must be config or operational. @{node_value_list} is expected to be in the format of node=value. RFC8040 can
+ ... use that as is with '=' delimiter, but older restconf URI will convert the '=' to a '/'
+ ${uri} = Run Keyword If "${USE_RFC8040}" == "True" Generate RFC8040 URI ${identifier} ${datastore} @{node_value_list}
+ Return From Keyword If "${USE_RFC8040}" == "True" ${uri}
+ Run Keyword If "${USE_RFC8040}" != "False" Fail Invalid Value for RFC8040 Flag: ${USE_RFC8040}
+ Run Keyword If "${datastore}"!="config" and "${datastore}"!="operational" Fail Invalid value for datastore: ${datastore}
+ ${uri} = Run Keyword If "${datastore}"=="config" Set Variable ${CONFIG_API}/${identifier}
+ ... ELSE Set Variable ${OPERATIONAL_API}/${identifier}
+ ${node_value_path} = Set Variable ${EMPTY}
+ FOR ${nv} IN @{node_value_list}
+ ${nv} = String.Replace String ${nv} = /
+ ${node_value_path} = Set Variable ${node_value_path}/${nv}
+ END
+ [Return] ${uri}${node_value_path}
+
+Generate RFC8040 URI
+ [Arguments] ${identifier} ${datastore}=config @{node_value_list}
+ ${node_value_path} = Set Variable ${EMPTY}
+ FOR ${nv} IN @{node_value_list}
+ ${node_value_path} = Set Variable ${node_value_path}/${nv}
+ END
+ ${uri} = Run Keyword If "${datastore}" == "config" Set Variable rests/data/${identifier}${node_value_path}?content=config
+ ... ELSE Set Variable rests/data/${identifier}${node_value_path}?content=nonconfig
+ [Return] ${uri}