383a0146878943a77cfc76c0fb37673748433fde
[testsuite.git] / robot / resources / stack_validation / validate_common.robot
1 *** Settings ***
2 Documentation     Testing openstack.
3 Library    OperatingSystem
4 Library    SSHLibrary
5 Library    RequestsLibrary
6 Library    ONAPLibrary.JSON
7 Library    ONAPLibrary.Openstack
8 Library    Collections
9 Resource          ../../resources/openstack/keystone_interface.robot
10 Resource          ../../resources/openstack/nova_interface.robot
11 Resource          ../../resources/openstack/heat_interface.robot
12 Resource          ../../resources/ssh/files.robot
13 Resource          ../../resources/ssh/processes.robot
14 Resource          packet_generator_interface.robot
15
16
17 *** Variables ***
18
19 *** Keywords ***
20 Wait For Server
21     [Documentation]    Attempts to login to the passed server info and verify (??). Uses server info to get public ip and locate corresponding provate key file
22     [Arguments]    ${server_ip}    ${timeout}=300s
23     #${file}=    Catenate    ${GLOBAL_VM_PRIVATE_KEY}
24     # Preload is using onap public key
25     ${file}=    Catenate    ${GLOBAL_ONAP_PRIVATE_KEY}
26     Wait Until Keyword Succeeds    ${timeout}    5 sec    Open Connection And Log In    ${server_ip}    root    ${file}
27     ${lines}=   Grep Local File    "Accepted publickey"    /var/log/auth.log
28     Log    ${lines}
29     Should Not Be Empty    ${lines}
30
31 Get Server Ip
32     [Arguments]    ${server_list}    ${stack_info}    ${key_name}    ${network_name}=public
33     ${server_name}=   Get From Dictionary     ${stack_info}   ${key_name}
34     ${server}=    Get From Dictionary    ${server_list}    ${server_name}
35     Log    Entering Get Openstack Server Ip
36     ${ip}=    Search Addresses    ${server}    ${network_name}
37     Log    Returned Get Openstack Server Ip
38     [Return]    ${ip}
39
40 Find And Reboot The Server
41     [Documentation]    Code to reboot the server by teh heat server name parameter value
42     [Arguments]    ${stack_info}    ${server_list}    ${server_name_parameter}
43     ${server_name}=   Get From Dictionary     ${stack_info}   ${server_name_parameter}
44     ${vfw_server}=    Get From Dictionary    ${server_list}    ${server_name}
45     ${vfw_server_id}=    Get From Dictionary    ${vfw_server}    id
46     Reboot Server    auth   ${vfw_server_id}
47
48
49 Search Addresses
50     [Arguments]   ${server}   ${network_name}
51     ${addresses}   Get From Dictionary   ${server}   addresses
52     ${status}   ${server_ip}=   Run Keyword And Ignore Error   Find Rackspace   ${addresses}   ${network_name}
53     Return From Keyword If   '${status}'=='PASS'   ${server_ip}
54     ${status}   ${server_ip}=   Run Keyword And Ignore Error   Find Openstack   ${addresses}   ${network_name}
55     Return From Keyword If   '${status}'=='PASS'   ${server_ip}
56     ${status}   ${server_ip}=   Run Keyword And Ignore Error   Find Openstack 2   ${addresses}   ${network_name}
57     Return From Keyword If   '${status}'=='PASS'   ${server_ip}
58     Fail  ${server}/${network_name} Not Found
59
60 Find Rackspace
61     [Arguments]   ${addresses}   ${network_name}
62     ${ips}   Get From Dictionary   ${addresses}   ${network_name}
63     ${ip}=   Get V4 IP   ${ips}
64     [Return]   ${ip}
65
66 Find Openstack
67     [Arguments]   ${addresses}   ${network_name}
68     ${network_name}=   Set Variable If    '${network_name}' == 'public'    external   ${network_name}
69     ${ip}=   Get V4 IP Openstack   ${addresses}   ${network_name}
70     [Return]   ${ip}
71
72 Find Openstack 2
73     [Arguments]   ${addresses}   ${network_name}
74     ${network_name}=   Set Variable If    '${network_name}' == 'public'    floating   ${network_name}
75     ${ipmaps}=   Get From Dictionary   ${addresses}   ${GLOBAL_INJECTED_NETWORK}
76     ${ip}=   Get V4 IP Openstack 2  ${ipmaps}   ${network_name}
77     [Return]   ${ip}
78
79 Get V4 IP
80     [Arguments]   ${ipmaps}
81     :FOR   ${ipmap}   IN   @{ipmaps}
82     \    ${ip}   Get From Dictionary   ${ipmap}   addr
83     \    ${version}   Get From Dictionary   ${ipmap}   version
84     \    Return from Keyword if   '${version}' == '4'   ${ip}
85     Fail  No Version 4 IP
86
87 Get V4 IP Openstack
88     [Arguments]   ${addresses}   ${testtype}
89     ${ipmaps}=   Get From Dictionary   ${addresses}   ${testtype}
90     :FOR   ${ipmap}   IN   @{ipmaps}
91     \    ${ip}   Get From Dictionary   ${ipmap}   addr
92     \    ${version}   Get From Dictionary   ${ipmap}   version
93     \    Return from Keyword if   '${version}'=='4'   ${ip}
94     Fail  No Version 4 IP
95
96 Get V4 IP Openstack 2
97     [Arguments]   ${ipmaps}   ${testtype}
98     :FOR   ${ipmap}   IN   @{ipmaps}
99     \    ${type}   Get From Dictionary   ${ipmap}   OS-EXT-IPS:type
100     \    ${ip}   Get From Dictionary   ${ipmap}   addr
101     \    ${version}   Get From Dictionary   ${ipmap}   version
102     \    Return from Keyword if   '${version}'=='4' and '${type}'=='${testtype}'   ${ip}
103     Fail  No Version 4 IP