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