Migrate request invocations (netconf)
[integration/test.git] / csit / libraries / DIDMKeywords.robot
index 036105c4a19ba8d86c1047f2f0974514b05268db..9905ee117a9d0e1f7e15a0b6b58da6058e8583f8 100644 (file)
@@ -1,30 +1,33 @@
 *** Settings ***
-Documentation     Keywords for DIDM suites
-Library           SSHLibrary
-Library           Collections
-Library           RequestsLibrary
-Variables         ../variables/Variables.py
-Resource          ./Utils.robot
+Documentation       Keywords for DIDM suites
+
+Library             SSHLibrary
+Library             Collections
+Library             RequestsLibrary
+Variables           ../variables/Variables.py
+Resource            ./Utils.robot
+Resource            ../variables/openflowplugin/Variables.robot
+
 
 *** Keywords ***
 Check DIDM Registered With Device
     [Documentation]    Check for DIDM registered with the device
-    ${resp}=    RequestsLibrary.Get Request    session    ${OPERATIONAL_NODES_API}
+    ${resp}=    RequestsLibrary.Get Request    session    ${RFC8040_OPERATIONAL_NODES_API}
     Should Be Equal As Strings    ${resp.status_code}    200
-    Log    ${resp.content}
-    Should Contain    ${resp.content}    didm
-    [Return]    ${resp.content}
+    Log    ${resp.text}
+    Should Contain    ${resp.text}    didm
+    RETURN    ${resp.text}
 
 Find Device Data
     [Documentation]    Extract device information
-    ${resp.content}=    Check DIDM Registered With Device
-    ${json_resp}=    RequestsLibrary.To_Json    ${resp.content}
+    ${resp.text}=    Check DIDM Registered With Device
+    ${json_resp}=    RequestsLibrary.To_Json    ${resp.text}
     ${nodes_resp}=    Get From Dictionary    ${json_resp}    nodes
     ${node_resp}=    Get From Dictionary    ${nodes_resp}    node
     ${node_data}=    Get From List    ${node_resp}    0
     Log    ${node_data}
     Set Suite Variable    ${node_data}
-    [Return]    ${node_data}
+    RETURN    ${node_data}
 
 Check Device IP
     [Documentation]    Check for the device IP address
@@ -33,10 +36,11 @@ Check Device IP
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${dev_ip}' == '${line}'    Get From Dictionary    ${node_data}    ${dev_ip}
-    [Return]    ${dev_ip}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If    '${dev_ip}' == '${line}'    Get From Dictionary    ${node_data}    ${dev_ip}
+    END
+    RETURN    ${dev_ip}
 
 Find Device Type
     [Documentation]    Look for the device type
@@ -46,10 +50,15 @@ Find Device Type
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${device_type}' == '${line}'    Get From Dictionary    ${node_data}    ${device_type}
-    [Return]    ${device_type}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If
+        ...    '${device_type}' == '${line}'
+        ...    Get From Dictionary
+        ...    ${node_data}
+        ...    ${device_type}
+    END
+    RETURN    ${device_type}
 
 Find Device Hardware
     [Documentation]    Look for the device hardware information
@@ -57,10 +66,11 @@ Find Device Hardware
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${device_hw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_hw}
-    [Return]    ${device_hw}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If    '${device_hw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_hw}
+    END
+    RETURN    ${device_hw}
 
 Find Device Software
     [Documentation]    Look for the device software information
@@ -68,10 +78,11 @@ Find Device Software
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${device_sw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_sw}
-    [Return]    ${device_sw}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If    '${device_sw}' == '${line}'    Get From Dictionary    ${node_data}    ${device_sw}
+    END
+    RETURN    ${device_sw}
 
 Find Device Manufacturer
     [Documentation]    Look for the device manufacture
@@ -79,10 +90,15 @@ Find Device Manufacturer
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${manufacture}' == '${line}'    Get From Dictionary    ${node_data}    ${manufacture}
-    [Return]    ${manufacture}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If
+        ...    '${manufacture}' == '${line}'
+        ...    Get From Dictionary
+        ...    ${node_data}
+        ...    ${manufacture}
+    END
+    RETURN    ${manufacture}
 
 Find Serial Number
     [Documentation]    Look for the device serial number
@@ -90,10 +106,15 @@ Find Serial Number
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${serial_number}' == '${line}'    Get From Dictionary    ${node_data}    ${serial_number}
-    [Return]    ${serial_number}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If
+        ...    '${serial_number}' == '${line}'
+        ...    Get From Dictionary
+        ...    ${node_data}
+        ...    ${serial_number}
+    END
+    RETURN    ${serial_number}
 
 Find Device Description
     [Documentation]    Look for the device description
@@ -101,7 +122,12 @@ Find Device Description
     ${device_keys}=    Get Dictionary Keys    ${node_data}
     Log    ${device_keys}
     ${length}=    Get Length    ${device_keys}
-    : FOR    ${index}    IN RANGE    0    ${length}
-    \    ${line}=    Get From List    ${device_keys}    ${index}
-    \    Run Keyword And Return If    '${description}' == '${line}'    Get From Dictionary    ${node_data}    ${description}
-    [Return]    ${description}
+    FOR    ${index}    IN RANGE    0    ${length}
+        ${line}=    Get From List    ${device_keys}    ${index}
+        Run Keyword And Return If
+        ...    '${description}' == '${line}'
+        ...    Get From Dictionary
+        ...    ${node_data}
+        ...    ${description}
+    END
+    RETURN    ${description}