2 Documentation Keywords for DIDM suites
5 Library RequestsLibrary
6 Variables ../variables/Variables.py
10 Check DIDM Registered With Device
11 [Documentation] Check for DIDM registered with the device
12 ${resp}= RequestsLibrary.Get Request session ${OPERATIONAL_NODES_API}
13 Should Be Equal As Strings ${resp.status_code} 200
15 Should Contain ${resp.content} didm
16 [Return] ${resp.content}
19 [Documentation] Extract device information
20 ${resp.content}= Check DIDM Registered With Device
21 ${json_resp}= RequestsLibrary.To_Json ${resp.content}
22 ${nodes_resp}= Get From Dictionary ${json_resp} nodes
23 ${node_resp}= Get From Dictionary ${nodes_resp} node
24 ${node_data}= Get From List ${node_resp} 0
26 Set Suite Variable ${node_data}
30 [Documentation] Check for the device IP address
31 ${dev_ip}= Set Variable flow-node-inventory:ip-address
32 ${node_data}= Find Device Data
33 ${device_keys}= Get Dictionary Keys ${node_data}
35 ${length}= Get Length ${device_keys}
36 FOR ${index} IN RANGE 0 ${length}
37 ${line}= Get From List ${device_keys} ${index}
38 Run Keyword And Return If '${dev_ip}' == '${line}' Get From Dictionary ${node_data} ${dev_ip}
43 [Documentation] Look for the device type
44 ${device_type}= Set Variable didm-identification:device-type
45 ${device_ip}= Check Device IP
46 Should Match ${DEVICE_IP} ${device_ip}
47 ${device_keys}= Get Dictionary Keys ${node_data}
49 ${length}= Get Length ${device_keys}
50 FOR ${index} IN RANGE 0 ${length}
51 ${line}= Get From List ${device_keys} ${index}
52 Run Keyword And Return If '${device_type}' == '${line}' Get From Dictionary ${node_data} ${device_type}
54 [Return] ${device_type}
57 [Documentation] Look for the device hardware information
58 ${device_hw}= Set Variable flow-node-inventory:hardware
59 ${device_keys}= Get Dictionary Keys ${node_data}
61 ${length}= Get Length ${device_keys}
62 FOR ${index} IN RANGE 0 ${length}
63 ${line}= Get From List ${device_keys} ${index}
64 Run Keyword And Return If '${device_hw}' == '${line}' Get From Dictionary ${node_data} ${device_hw}
69 [Documentation] Look for the device software information
70 ${device_sw}= Set Variable flow-node-inventory:software
71 ${device_keys}= Get Dictionary Keys ${node_data}
73 ${length}= Get Length ${device_keys}
74 FOR ${index} IN RANGE 0 ${length}
75 ${line}= Get From List ${device_keys} ${index}
76 Run Keyword And Return If '${device_sw}' == '${line}' Get From Dictionary ${node_data} ${device_sw}
80 Find Device Manufacturer
81 [Documentation] Look for the device manufacture
82 ${manufacture}= Set Variable flow-node-inventory:manufacturer
83 ${device_keys}= Get Dictionary Keys ${node_data}
85 ${length}= Get Length ${device_keys}
86 FOR ${index} IN RANGE 0 ${length}
87 ${line}= Get From List ${device_keys} ${index}
88 Run Keyword And Return If '${manufacture}' == '${line}' Get From Dictionary ${node_data} ${manufacture}
90 [Return] ${manufacture}
93 [Documentation] Look for the device serial number
94 ${serial_number}= Set Variable flow-node-inventory:serial-number
95 ${device_keys}= Get Dictionary Keys ${node_data}
97 ${length}= Get Length ${device_keys}
98 FOR ${index} IN RANGE 0 ${length}
99 ${line}= Get From List ${device_keys} ${index}
100 Run Keyword And Return If '${serial_number}' == '${line}' Get From Dictionary ${node_data} ${serial_number}
102 [Return] ${serial_number}
104 Find Device Description
105 [Documentation] Look for the device description
106 ${description}= Set Variable flow-node-inventory:description
107 ${device_keys}= Get Dictionary Keys ${node_data}
109 ${length}= Get Length ${device_keys}
110 FOR ${index} IN RANGE 0 ${length}
111 ${line}= Get From List ${device_keys} ${index}
112 Run Keyword And Return If '${description}' == '${line}' Get From Dictionary ${node_data} ${description}
114 [Return] ${description}