Update Robot Framework format - step 18
[integration/test.git] / tools / deployment / openstack_ha / deploy / 03_keystone_setup.robot
1 *** Settings ***
2 Documentation       Test suite to verify packet flows between vm instances.
3
4 Library             SSHLibrary
5 Library             OperatingSystem
6 Library             RequestsLibrary
7 Resource            ../libraries/OpenStackInstallUtils.robot
8 Resource            ../libraries/OpenStackOperations.robot
9 Resource            ../libraries/SystemUtils.robot
10 Resource            ../libraries/Utils.robot
11
12 Suite Setup         OpenStackInstallUtils.Get All Ssh Connections
13 Suite Teardown      Close All Connections
14
15
16 *** Test Cases ***
17 Install Identity
18     Create And Configure Keystone Db    ${OS_CONTROL_1_IP}    root    mysql    ${OS_CONTROL_1_HOSTNAME}
19     IF    2 < ${NUM_CONTROL_NODES}
20         Create And Configure Keystone Db Other Nodes    ${OS_CONTROL_2_IP}    root    mysql    ${OS_CONTROL_2_HOSTNAME}
21     END
22     IF    2 < ${NUM_CONTROL_NODES}
23         Create And Configure Keystone Db Other Nodes    ${OS_CONTROL_3_IP}    root    mysql    ${OS_CONTROL_3_HOSTNAME}
24     END
25     IF    3 < ${NUM_CONTROL_NODES}
26         Create And Configure Keystone Db Other Nodes    ${OS_CONTROL_4_IP}    root    mysql    ${OS_CONTROL_4_HOSTNAME}
27     END
28     IF    4 < ${NUM_CONTROL_NODES}
29         Create And Configure Keystone Db Other Nodes    ${OS_CONTROL_5_IP}    root    mysql    ${OS_CONTROL_5_HOSTNAME}
30     END
31     IF    2 > ${NUM_CONTROL_NODES}
32         Install Configure Keystone    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_HOSTNAME}
33     END
34     IF    2 < ${NUM_CONTROL_NODES}
35         Install Configure Keystone    ${OS_CONTROL_1_IP}    ${HAPROXY_HOSTNAME}
36     END
37     IF    2 < ${NUM_CONTROL_NODES}
38         Install Configure Keystone    ${OS_CONTROL_2_IP}    ${HAPROXY_HOSTNAME}
39     END
40     IF    2 < ${NUM_CONTROL_NODES}
41         Install Configure Keystone    ${OS_CONTROL_3_IP}    ${HAPROXY_HOSTNAME}
42     END
43     IF    3 < ${NUM_CONTROL_NODES}
44         Install Configure Keystone    ${OS_CONTROL_4_IP}    ${HAPROXY_HOSTNAME}
45     END
46     IF    4 < ${NUM_CONTROL_NODES}
47         Install Configure Keystone    ${OS_CONTROL_5_IP}    ${HAPROXY_HOSTNAME}
48     END
49     ${token}=    Run Command    ${OS_CONTROL_1_IP}    openssl rand -hex 10
50     IF    2 < ${NUM_CONTROL_NODES}
51         Set Admin Token    ${OS_CONTROL_1_IP}    ${token}
52     END
53     IF    2 < ${NUM_CONTROL_NODES}
54         Set Admin Token    ${OS_CONTROL_2_IP}    ${token}
55     END
56     IF    2 < ${NUM_CONTROL_NODES}
57         Set Admin Token    ${OS_CONTROL_3_IP}    ${token}
58     END
59     IF    3 < ${NUM_CONTROL_NODES}
60         Set Admin Token    ${OS_CONTROL_4_IP}    ${token}
61     END
62     IF    4 < ${NUM_CONTROL_NODES}
63         Set Admin Token    ${OS_CONTROL_5_IP}    ${token}
64     END
65     Keystone Manage Setup    ${OS_CONTROL_1_IP}    keystone    keystone
66     IF    2 < ${NUM_CONTROL_NODES}
67         Copy Fernet Keys    ${OS_CONTROL_1_IP}    ${OS_CONTROL_2_IP}
68     END
69     IF    2 < ${NUM_CONTROL_NODES}
70         Copy Fernet Keys    ${OS_CONTROL_1_IP}    ${OS_CONTROL_3_IP}
71     END
72     IF    3 < ${NUM_CONTROL_NODES}
73         Copy Fernet Keys    ${OS_CONTROL_1_IP}    ${OS_CONTROL_4_IP}
74     END
75     IF    4 < ${NUM_CONTROL_NODES}
76         Copy Fernet Keys    ${OS_CONTROL_1_IP}    ${OS_CONTROL_5_IP}
77     END
78     IF    2 < ${NUM_CONTROL_NODES}
79         Chown File    ${OS_CONTROL_2_IP}    /etc/keystone/fernet-keys    keystone    keystone
80     END
81     IF    2 < ${NUM_CONTROL_NODES}
82         Chown File    ${OS_CONTROL_3_IP}    /etc/keystone/fernet-keys    keystone    keystone
83     END
84     IF    3 < ${NUM_CONTROL_NODES}
85         Chown File    ${OS_CONTROL_4_IP}    /etc/keystone/fernet-keys    keystone    keystone
86     END
87     IF    4 < ${NUM_CONTROL_NODES}
88         Chown File    ${OS_CONTROL_5_IP}    /etc/keystone/fernet-keys    keystone    keystone
89     END
90     Start Keystone    ${OS_CONTROL_1_IP}
91     IF    2 < ${NUM_CONTROL_NODES}    Start Keystone    ${OS_CONTROL_2_IP}
92     IF    2 < ${NUM_CONTROL_NODES}    Start Keystone    ${OS_CONTROL_3_IP}
93     IF    2 < ${NUM_CONTROL_NODES}
94         Generic HAProxy Entry    ${HAPROXY_IP}    ${HAPROXY_IP}    35357    keystone-admin
95     END
96     IF    2 < ${NUM_CONTROL_NODES}
97         Generic HAProxy Entry    ${HAPROXY_IP}    ${HAPROXY_IP}    5000    keystone-public
98     END
99     IF    2 > ${NUM_CONTROL_NODES}    Create stackrc    ${OS_CONTROL_1_HOSTNAME}
100     IF    2 < ${NUM_CONTROL_NODES}    Create stackrc    ${HAPROXY_HOSTNAME}
101     IF    2 > ${NUM_CONTROL_NODES}
102         Setup And Bootstrap    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_HOSTNAME}
103     END
104     IF    2 < ${NUM_CONTROL_NODES}
105         Setup And Bootstrap    ${OS_CONTROL_1_IP}    ${HAPROXY_HOSTNAME}
106     END
107     Create Project Service
108
109
110 *** Keywords ***
111 Create And Configure Keystone Db
112     [Arguments]    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    ${host_name}
113     Create Database for Mysql    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    keystone
114     Grant Privileges To Mysql Database
115     ...    ${os_node_cxn}
116     ...    ${mysql_user}
117     ...    ${mysql_pass}
118     ...    keystone.*
119     ...    keystone
120     ...    ${host_name}
121     ...    keystone
122     Grant Privileges To Mysql Database
123     ...    ${os_node_cxn}
124     ...    ${mysql_user}
125     ...    ${mysql_pass}
126     ...    keystone.*
127     ...    keystone
128     ...    localhost
129     ...    keystone
130     IF    2 < ${NUM_CONTROL_NODES}
131         Grant Privileges To Mysql Database
132         ...    ${os_node_cxn}
133         ...    ${mysql_user}
134         ...    ${mysql_pass}
135         ...    keystone.*
136         ...    keystone
137         ...    ${HAPROXY_HOSTNAME}
138         ...    keystone
139     END
140
141 Create And Configure Keystone Db Other Nodes
142     [Arguments]    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    ${host_name}
143     Grant Privileges To Mysql Database
144     ...    ${os_node_cxn}
145     ...    ${mysql_user}
146     ...    ${mysql_pass}
147     ...    keystone.*
148     ...    keystone
149     ...    ${host_name}
150     ...    keystone
151     Grant Privileges To Mysql Database
152     ...    ${os_node_cxn}
153     ...    ${mysql_user}
154     ...    ${mysql_pass}
155     ...    keystone.*
156     ...    keystone
157     ...    localhost
158     ...    keystone
159     Grant Privileges To Mysql Database
160     ...    ${os_node_cxn}
161     ...    ${mysql_user}
162     ...    ${mysql_pass}
163     ...    keystone.*
164     ...    keystone
165     ...    ${HAPROXY_HOSTNAME}
166     ...    keystone
167
168 Install Configure Keystone
169     [Arguments]    ${os_node_cxn}    ${host_name}
170     IF    '${OS_APPS_PRE_INSTALLED}' == 'no'
171         Install Rpm Package    ${os_node_cxn}    openstack-keystone httpd mod_wsgi rsync
172     END
173     Crudini Edit
174     ...    ${os_node_cxn}
175     ...    /etc/keystone/keystone.conf
176     ...    database
177     ...    connection
178     ...    "mysql+pymysql://keystone:keystone@${host_name}/keystone"
179     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    token    provider    fernet
180     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    catalog    driver    sql
181     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    identity    driver    sql
182     IF    2 < ${NUM_CONTROL_NODES}
183         Crudini Edit
184         ...    ${os_node_cxn}
185         ...    /etc/keystone/keystone.conf
186         ...    DEFAULT
187         ...    transport_url
188         ...    "rabbit://openstack:rabbit@${OS_CONTROL_1_HOSTNAME},openstack:rabbit@${OS_CONTROL_2_HOSTNAME},openstack:rabbit@${OS_CONTROL_3_HOSTNAME}"
189     END
190     IF    2 > ${NUM_CONTROL_NODES}
191         Crudini Edit
192         ...    ${os_node_cxn}
193         ...    /etc/keystone/keystone.conf
194         ...    DEFAULT
195         ...    transport_url
196         ...    "rabbit://openstack:rabbit@${host_name}"
197     END
198     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    oslo_messaging_rabbit    rabbit_max_retries    0
199     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    oslo_messaging_rabbit    rabbit_ha_queues    true
200     Create Softlink    ${os_node_cxn}    /usr/share/keystone/wsgi-keystone.conf    /etc/httpd/conf.d/
201
202 Start Keystone
203     [Arguments]    ${os_node_cxn}
204     Enable Service    ${os_node_cxn}    httpd
205     Start Service    ${os_node_cxn}    httpd
206
207 Set Admin Token
208     [Arguments]    ${os_node_cxn}    ${token}
209     Crudini Edit    ${os_node_cxn}    /etc/keystone/keystone.conf    DEFAULT    admin_token    ${token}
210
211 Copy Fernet Keys
212     [Arguments]    ${os_node_cxn}    ${target_ip}
213     Rsync Directory    ${os_node_cxn}    ${target_ip}    /etc/keystone/fernet-keys    /etc/keystone
214
215 Setup And Bootstrap
216     [Arguments]    ${os_node_cxn}    ${host_name}
217     Run Command As User    ${os_node_cxn}    "keystone-manage db_sync"    keystone
218     Keystone Manage Bootstrap    ${os_node_cxn}    ${host_name}    RegionOne
219
220 Create stackrc
221     [Arguments]    ${haproxy_ip}
222     Create Local File    /tmp/stackrc
223     Write To Local File    /tmp/stackrc    "export OS_USERNAME=admin"
224     Append To Local File    /tmp/stackrc    "export OS_PASSWORD=admin"
225     Append To Local File    /tmp/stackrc    "export OS_PROJECT_NAME=admin"
226     Append To Local File    /tmp/stackrc    "export OS_USER_DOMAIN_NAME=Default"
227     Append To Local File    /tmp/stackrc    "export OS_PROJECT_DOMAIN_NAME=Default"
228     Append To Local File    /tmp/stackrc    "export OS_AUTH_URL=http://${haproxy_ip}:35357/v3"
229     Append To Local File    /tmp/stackrc    "export OS_IDENTITY_API_VERSION=3"
230     Append To Local File    /tmp/stackrc    "export OS_IMAGE_API_VERSION=2"
231
232 Create Project Service
233     Create Project    default    "ServiceProject"    service    rc_file=/tmp/stackrc
234
235 Keystone Manage Setup
236     [Arguments]    ${os_node_cxn}    ${keystone_user}    ${keystone_password}
237     Switch Connection    ${os_node_cxn}
238     ${output}    ${rc}=    Execute Command
239     ...    sudo keystone-manage fernet_setup --keystone-user ${keystone_user} --keystone-group ${keystone_password}
240     ...    return_rc=True
241     ...    return_stdout=True
242     Log    ${output}
243     Should Not Be True    ${rc}
244
245 Keystone Manage Bootstrap
246     [Arguments]    ${os_node_cxn}    ${host_name}    ${region_name}
247     Switch Connection    ${os_node_cxn}
248     ${output}    ${rc}=    Execute Command
249     ...    sudo keystone-manage bootstrap --bootstrap-password admin --bootstrap-admin-url http://${host_name}:35357/v3/ --bootstrap-internal-url http://${host_name}:5000/v3/ --bootstrap-public-url http://${host_name}:5000/v3/ --bootstrap-region-id ${region_name}
250     ...    return_rc=True
251     ...    return_stdout=True
252     Log    ${output}
253     Should Not Be True    ${rc}