2 Documentation Keywords for DIDM suites
5 Library RequestsLibrary
6 Variables ../variables/Variables.py
8 Resource ../variables/openflowplugin/Variables.robot
11 Check DIDM Registered With Device
12 [Documentation] Check for DIDM registered with the device
13 ${resp}= RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_NODES_API}
14 Should Be Equal As Strings ${resp.status_code} 200
16 Should Contain ${resp.text} didm
20 [Documentation] Extract device information
21 ${resp.text}= Check DIDM Registered With Device
22 ${json_resp}= RequestsLibrary.To_Json ${resp.text}
23 ${nodes_resp}= Get From Dictionary ${json_resp} nodes
24 ${node_resp}= Get From Dictionary ${nodes_resp} node
25 ${node_data}= Get From List ${node_resp} 0
27 Set Suite Variable ${node_data}
31 [Documentation] Check for the device IP address
32 ${dev_ip}= Set Variable flow-node-inventory:ip-address
33 ${node_data}= Find Device Data
34 ${device_keys}= Get Dictionary Keys ${node_data}
36 ${length}= Get Length ${device_keys}
37 FOR ${index} IN RANGE 0 ${length}
38 ${line}= Get From List ${device_keys} ${index}
39 Run Keyword And Return If '${dev_ip}' == '${line}' Get From Dictionary ${node_data} ${dev_ip}
44 [Documentation] Look for the device type
45 ${device_type}= Set Variable didm-identification:device-type
46 ${device_ip}= Check Device IP
47 Should Match ${DEVICE_IP} ${device_ip}
48 ${device_keys}= Get Dictionary Keys ${node_data}
50 ${length}= Get Length ${device_keys}
51 FOR ${index} IN RANGE 0 ${length}
52 ${line}= Get From List ${device_keys} ${index}
53 Run Keyword And Return If '${device_type}' == '${line}' Get From Dictionary ${node_data} ${device_type}
55 [Return] ${device_type}
58 [Documentation] Look for the device hardware information
59 ${device_hw}= Set Variable flow-node-inventory:hardware
60 ${device_keys}= Get Dictionary Keys ${node_data}
62 ${length}= Get Length ${device_keys}
63 FOR ${index} IN RANGE 0 ${length}
64 ${line}= Get From List ${device_keys} ${index}
65 Run Keyword And Return If '${device_hw}' == '${line}' Get From Dictionary ${node_data} ${device_hw}
70 [Documentation] Look for the device software information
71 ${device_sw}= Set Variable flow-node-inventory:software
72 ${device_keys}= Get Dictionary Keys ${node_data}
74 ${length}= Get Length ${device_keys}
75 FOR ${index} IN RANGE 0 ${length}
76 ${line}= Get From List ${device_keys} ${index}
77 Run Keyword And Return If '${device_sw}' == '${line}' Get From Dictionary ${node_data} ${device_sw}
81 Find Device Manufacturer
82 [Documentation] Look for the device manufacture
83 ${manufacture}= Set Variable flow-node-inventory:manufacturer
84 ${device_keys}= Get Dictionary Keys ${node_data}
86 ${length}= Get Length ${device_keys}
87 FOR ${index} IN RANGE 0 ${length}
88 ${line}= Get From List ${device_keys} ${index}
89 Run Keyword And Return If '${manufacture}' == '${line}' Get From Dictionary ${node_data} ${manufacture}
91 [Return] ${manufacture}
94 [Documentation] Look for the device serial number
95 ${serial_number}= Set Variable flow-node-inventory:serial-number
96 ${device_keys}= Get Dictionary Keys ${node_data}
98 ${length}= Get Length ${device_keys}
99 FOR ${index} IN RANGE 0 ${length}
100 ${line}= Get From List ${device_keys} ${index}
101 Run Keyword And Return If '${serial_number}' == '${line}' Get From Dictionary ${node_data} ${serial_number}
103 [Return] ${serial_number}
105 Find Device Description
106 [Documentation] Look for the device description
107 ${description}= Set Variable flow-node-inventory:description
108 ${device_keys}= Get Dictionary Keys ${node_data}
110 ${length}= Get Length ${device_keys}
111 FOR ${index} IN RANGE 0 ${length}
112 ${line}= Get From List ${device_keys} ${index}
113 Run Keyword And Return If '${description}' == '${line}' Get From Dictionary ${node_data} ${description}
115 [Return] ${description}