Deploy Openstack Using Robot Keywords
[integration/test.git] / tools / deployment / openstack_ha / deploy / 07_csit_setup.robot
1 *** Settings ***
2 Documentation     Suite that configures the nodes to execute CSIT
3 Suite Setup       OpenStackInstallUtils.Get All Ssh Connections
4 Suite Teardown    Close All Connections
5 Library           SSHLibrary
6 Library           OperatingSystem
7 Library           RequestsLibrary
8 Resource          ../../../../csit/libraries/OpenStackInstallUtils.robot
9 Resource          ../../../../csit/libraries/OpenStackOperations.robot
10 Resource          ../../../../csit/libraries/SystemUtils.robot
11 Resource          ../../../../csit/libraries/Utils.robot
12
13 *** Test Cases ***
14 Create Jenkins User
15     #Generate Ssh Keys For VMs
16     #Local Install Rpm Package    sshpass
17     #Create Keypair    vm_keys    /tmp/vm_key    rc_file=/tmp/stackrc
18     #Run Keyword If    2 > ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_1_IP}    jenkins
19     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_1_IP}    jenkins
20     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_2_IP}    jenkins
21     #Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_3_IP}    jenkins
22     #Run Keyword If    3 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_4_IP}    jenkins
23     #Run Keyword If    4 < ${NUM_CONTROL_NODES}    Create Csit User    ${OS_CONTROL_5_IP}    jenkins
24     Run Keyword If    0 < ${NUM_COMPUTE_NODES}    Create Csit User    ${OS_COMPUTE_1_IP}    jenkins
25     Run Keyword If    1 < ${NUM_COMPUTE_NODES}    Create Csit User    ${OS_COMPUTE_2_IP}    jenkins
26
27 Create Required Image and Flavor
28     Run Command In Local Node    export https_proxy=${PROXY_TEST};wget https://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img -O /tmp/cirros35.img;unset https_proxy
29     Create Image    cirros    /tmp/cirros35.img    rc_file=/tmp/stackrc
30     Create Image    cirros-0.3.5-x86_64-disk    /tmp/cirros35.img    rc_file=/tmp/stackrc
31     Create Flavor    cirros    128    0    rc_file=/tmp/stackrc
32     Create Flavor    m1.nano    128    0    rc_file=/tmp/stackrc
33     Run Command In Local Node    export https_proxy=${PROXY_TEST};export http_proxy=${PROXY_TEST};wget "https://download.fedoraproject.org/pub/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2" -O /tmp/fedora.qcow2;unset https_proxy;unset http_proxy
34     Create Image    fedora    /tmp/fedora.qcow2    rc_file=/tmp/stackrc
35     Create Flavor    fedora    2048    6    rc_file=/tmp/stackrc
36     Install Rpm Package    ${OS_CONTROL_1_IP}    wget
37     Download Scapy For Test    ${OS_CONTROL_1_IP}
38
39 *** Keywords ***
40 Set Password
41     [Arguments]    ${os_node_cxn}    ${user_name}
42     Switch Connection    ${os_node_cxn}
43     Write Commands Until Expected Prompt    sudo passwd ${user_name}    d:    30s
44     Write Commands Until Expected Prompt    ${user_name}    d:    30s
45     Write Commands Until Expected Prompt    ${user_name}    ${OS_NODE_PROMPT}    30s
46
47 Set Required Prompt
48     [Arguments]    ${os_node_cxn}    ${user_name}
49     Append To File    ${os_node_cxn}    /home/${user_name}/.bashrc    'PS1="[\\u@\\h \\W]>"'
50
51 Create Csit User
52     [Arguments]    ${os_node_cxn}    ${user_name}
53     Run Command    ${os_node_cxn}    sudo useradd ${user_name} -d /home/${user_name}
54     Run Command    ${os_node_cxn}    echo "${user_name} ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/${user_name}
55     Set Password    ${os_node_cxn}    ${user_name}
56     Set Required Prompt    ${os_node_cxn}    ${user_name}
57     Setup Passwordless Ssh    jenkins    ${os_node_cxn}
58
59 Setup Passwordless Ssh
60     [Arguments]    ${user_name}    ${node_ip}
61     Run Command In Local Node    sshpass -p ${user_name} ssh-copy-id ${user_name}@${node_ip} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
62     Run Command In Local Node    scp /tmp/vm_key ${user_name}@${node_ip}:~
63     Run Command In Local Node    scp /tmp/vm_key.pub ${user_name}@${node_ip}:~
64
65 Generate Ssh Keys For Vms
66     Run Command In Local Node    ssh-keygen -t rsa -N "" -f /tmp/vm_key
67
68 Download Scapy For Test
69     [Arguments]    ${os_node_cxn}
70     Run Command    ${os_node_cxn}    export https_proxy=${PROXY_TEST};export http_proxy=${PROXY_TEST};wget scapy.net -O /tmp/scapy-master.zip;unset https_proxy;unset http_proxy
71     Install Rpm Package    ${os_node_cxn}    unzip
72     Run Command    ${os_node_cxn}    cd /tmp;unzip /tmp/scapy-master.zip