Add chlorine to release dict
[integration/test.git] / csit / libraries / DIDMKeywords.robot
1 *** Settings ***
2 Documentation     Keywords for DIDM suites
3 Library           SSHLibrary
4 Library           Collections
5 Library           RequestsLibrary
6 Variables         ../variables/Variables.py
7 Resource          ./Utils.robot
8 Resource          ../variables/openflowplugin/Variables.robot
9
10 *** Keywords ***
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
15     Log    ${resp.text}
16     Should Contain    ${resp.text}    didm
17     [Return]    ${resp.text}
18
19 Find Device Data
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
26     Log    ${node_data}
27     Set Suite Variable    ${node_data}
28     [Return]    ${node_data}
29
30 Check Device IP
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}
35     Log    ${device_keys}
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}
40     END
41     [Return]    ${dev_ip}
42
43 Find Device Type
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}
49     Log    ${device_keys}
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}
54     END
55     [Return]    ${device_type}
56
57 Find Device Hardware
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}
61     Log    ${device_keys}
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}
66     END
67     [Return]    ${device_hw}
68
69 Find Device Software
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}
73     Log    ${device_keys}
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}
78     END
79     [Return]    ${device_sw}
80
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}
85     Log    ${device_keys}
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}
90     END
91     [Return]    ${manufacture}
92
93 Find Serial Number
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}
97     Log    ${device_keys}
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}
102     END
103     [Return]    ${serial_number}
104
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}
109     Log    ${device_keys}
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}
114     END
115     [Return]    ${description}