2 Documentation Keywords for DIDM suites
6 Library RequestsLibrary
7 Variables ../variables/Variables.py
9 Resource ../variables/openflowplugin/Variables.robot
13 Check DIDM Registered With Device
14 [Documentation] Check for DIDM registered with the device
15 ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
16 Should Be Equal As Strings ${resp.status_code} 200
18 Should Contain ${resp.text} didm
22 [Documentation] Extract device information
23 ${resp.text}= Check DIDM Registered With Device
24 ${json_resp}= RequestsLibrary.To_Json ${resp.text}
25 ${nodes_resp}= Get From Dictionary ${json_resp} nodes
26 ${node_resp}= Get From Dictionary ${nodes_resp} node
27 ${node_data}= Get From List ${node_resp} 0
29 Set Suite Variable ${node_data}
33 [Documentation] Check for the device IP address
34 ${dev_ip}= Set Variable flow-node-inventory:ip-address
35 ${node_data}= Find Device Data
36 ${device_keys}= Get Dictionary Keys ${node_data}
38 ${length}= Get Length ${device_keys}
39 FOR ${index} IN RANGE 0 ${length}
40 ${line}= Get From List ${device_keys} ${index}
41 Run Keyword And Return If '${dev_ip}' == '${line}' Get From Dictionary ${node_data} ${dev_ip}
46 [Documentation] Look for the device type
47 ${device_type}= Set Variable didm-identification:device-type
48 ${device_ip}= Check Device IP
49 Should Match ${DEVICE_IP} ${device_ip}
50 ${device_keys}= Get Dictionary Keys ${node_data}
52 ${length}= Get Length ${device_keys}
53 FOR ${index} IN RANGE 0 ${length}
54 ${line}= Get From List ${device_keys} ${index}
55 Run Keyword And Return If
56 ... '${device_type}' == '${line}'
57 ... Get From Dictionary
64 [Documentation] Look for the device hardware information
65 ${device_hw}= Set Variable flow-node-inventory:hardware
66 ${device_keys}= Get Dictionary Keys ${node_data}
68 ${length}= Get Length ${device_keys}
69 FOR ${index} IN RANGE 0 ${length}
70 ${line}= Get From List ${device_keys} ${index}
71 Run Keyword And Return If '${device_hw}' == '${line}' Get From Dictionary ${node_data} ${device_hw}
76 [Documentation] Look for the device software information
77 ${device_sw}= Set Variable flow-node-inventory:software
78 ${device_keys}= Get Dictionary Keys ${node_data}
80 ${length}= Get Length ${device_keys}
81 FOR ${index} IN RANGE 0 ${length}
82 ${line}= Get From List ${device_keys} ${index}
83 Run Keyword And Return If '${device_sw}' == '${line}' Get From Dictionary ${node_data} ${device_sw}
87 Find Device Manufacturer
88 [Documentation] Look for the device manufacture
89 ${manufacture}= Set Variable flow-node-inventory:manufacturer
90 ${device_keys}= Get Dictionary Keys ${node_data}
92 ${length}= Get Length ${device_keys}
93 FOR ${index} IN RANGE 0 ${length}
94 ${line}= Get From List ${device_keys} ${index}
95 Run Keyword And Return If
96 ... '${manufacture}' == '${line}'
97 ... Get From Dictionary
101 RETURN ${manufacture}
104 [Documentation] Look for the device serial number
105 ${serial_number}= Set Variable flow-node-inventory:serial-number
106 ${device_keys}= Get Dictionary Keys ${node_data}
108 ${length}= Get Length ${device_keys}
109 FOR ${index} IN RANGE 0 ${length}
110 ${line}= Get From List ${device_keys} ${index}
111 Run Keyword And Return If
112 ... '${serial_number}' == '${line}'
113 ... Get From Dictionary
117 RETURN ${serial_number}
119 Find Device Description
120 [Documentation] Look for the device description
121 ${description}= Set Variable flow-node-inventory:description
122 ${device_keys}= Get Dictionary Keys ${node_data}
124 ${length}= Get Length ${device_keys}
125 FOR ${index} IN RANGE 0 ${length}
126 ${line}= Get From List ${device_keys} ${index}
127 Run Keyword And Return If
128 ... '${description}' == '${line}'
129 ... Get From Dictionary
133 RETURN ${description}