-
Notifications
You must be signed in to change notification settings - Fork 46
/
provision.py
341 lines (315 loc) · 18.3 KB
/
provision.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
from fabfile.config import *
from fabfile.utils.fabos import *
from fabfile.utils.host import *
from fabfile.utils.interface import *
from fabfile.utils.multitenancy import *
from fabfile.utils.migration import *
from fabfile.utils.storage import *
from fabfile.utils.analytics import *
@task
@EXECUTE_TASK
@roles('webui')
def setup_webui_storage(mode):
"""Provisions storage webui services."""
for entry in env.roledefs['webui']:
#Get the webui host
webui_host = entry
#Get webui ip based on host
storage_webui_ip = hstr_to_ip(webui_host)
#get webui host password
storage_webui_host_password = env.passwords[entry]
#Get the storage master host
storage_master = env.roledefs['storage-master'][0]
#Get the storage master ip address (assuming ceph-rest-api server running)
storage_master_ip = hstr_to_ip(storage_master)
with settings(host_string = storage_webui_ip, password = storage_webui_host_password):
with cd(INSTALLER_DIR):
# Argument details
# storage-setup-mode - setup/unconfigure/reconfigure
# storage-webui-ip - Storage WebUI IP
# storage-master-ip - storage master node where ceph-rest-api server is running
cmd= "PASSWORD=%s setup-vnc-storage-webui --storage-setup-mode %s --storage-webui-ip %s --storage-master-ip %s --storage-disk-config %s --storage-ssd-disk-config %s"\
%(storage_webui_host_password, mode, storage_webui_ip, storage_master_ip, ' '.join(get_storage_disk_config()), ' '.join(get_storage_ssd_disk_config()), )
print cmd
run(cmd)
#end setup_webui_storage
@task
@EXECUTE_TASK
@roles('storage-master')
def setup_master_storage(mode):
"""Provisions storage master services."""
host_string = env.host_string
if host_string == env.roledefs['storage-master'][0]:
storage_host_entries=[]
storage_pass_list=[]
storage_host_list=[]
storage_hostnames=[]
collector_pass_list=[]
collector_host_list=[]
cfg_host_list=[]
storage_os_pass_list=[]
storage_os_host_list=[]
index = 0
for entry in env.roledefs['storage-master']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
if index != 0:
storage_os_pass_list.append(storage_host_password)
storage_os_host_list.append(storage_data_ip)
index = index + 1
for entry in env.roledefs['storage-compute']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry and entry != env.roledefs['storage-master'][0]:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
for entry in env.roledefs['collector']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
collector_pass_list.append(env.passwords[entry])
collector_host = get_control_host_string(entry)
collector_data_ip=get_data_ip(collector_host)[0]
collector_host_list.append(collector_data_ip)
index = 0
for entry in env.roledefs['cfgm']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if index != 0:
cfg_host = get_control_host_string(entry)
cfg_data_ip=get_data_ip(cfg_host)[0]
cfg_host_list.append(cfg_data_ip)
index = index + 1
if cfg_host_list == []:
cfg_host_list.append('none')
if storage_os_host_list == []:
storage_os_host_list.append('none')
if storage_os_pass_list == []:
storage_os_pass_list.append('none')
storage_master=env.roledefs['storage-master'][0]
storage_master_ip=get_data_ip(storage_master)[0]
cfm = env.roledefs['cfgm'][0]
cfm_ip = get_data_ip(cfm)[0]
storage_master_password=env.passwords[env.roledefs['storage-master'][0]]
with settings(host_string = storage_master, password = storage_master_password):
with cd(INSTALLER_DIR):
# Argument details
# storage-setup-mode - setup/unconfigure/reconfigure - First time setup/Remove all configuration/Do a reconfigure
# storage-master - Storage master IP
# storage-hostnames - hostnames of all the nodes (storage master + storage compute)
# storage-host-tokens - password for all the nodes (storage master + storage compute)
# storage-disk-config - Disk list for Ceph combined pool or HDD pool
# storage-chassis-config - Chassis information list in the form
# of 'host1:id0 host2:id0 host3:id1'
# storage-ssd-disk-config - Disk list for Ceph SSD pool
# storage-journal-config - OSD journal disk list
# storage-local-disk-config - Disk list for local LVM pool
# storage-local-ssd-disk-config - Disk list for local LVM SSD pool
# storage-local-nfs-disk-config - NFS storage list
# storage-directory-config - Directory list for Ceph
# live-migration - Enable/Disable live migration
# collector-hosts - hosts of all collector nodes
# collector-host-tokens - password for all collector nodes
# cfg-host - first config node address (similar to storage-master)
# cinder-vip - cinder internal vip address
# config-hosts - config node address list (except cfg-host)
# storage-os-hosts - storage openstack hosts (except storage-master)
# storage-os-host-tokens - storage openstack hosts passwd list
cmd= "PASSWORD=%s setup-vnc-storage --storage-setup-mode %s --storage-master %s --storage-hostnames %s --storage-hosts %s --storage-host-tokens %s --storage-disk-config %s --storage-ssd-disk-config %s --storage-journal-config %s --storage-local-disk-config %s --storage-local-ssd-disk-config %s --storage-nfs-disk-config %s --storage-directory-config %s --storage-chassis-config %s --live-migration %s --collector-hosts %s --collector-host-tokens %s --cfg-host %s --cinder-vip %s --config-hosts %s --storage-os-hosts %s --storage-os-host-tokens %s" \
%(storage_master_password, mode, storage_master_ip, ' '.join(storage_hostnames), ' '.join(storage_host_list), ' '.join(storage_pass_list), ' '.join(get_storage_disk_config()), ' '.join(get_storage_ssd_disk_config()), ' '.join(get_storage_journal_config()), ' '.join(get_storage_local_disk_config()), ' '.join(get_storage_local_ssd_disk_config()), ' '.join(get_storage_nfs_disk_config()), ' '.join(get_storage_directory_config()), ' '.join(get_storage_chassis_config()), get_live_migration_opts(), ' '.join(collector_host_list), ' '.join(collector_pass_list), cfm_ip, get_cinder_ha_vip(), ' '.join(cfg_host_list), ' '.join(storage_os_host_list), ' '.join(storage_os_pass_list))
print cmd
run(cmd)
#end setup_storage_master
@task
@EXECUTE_TASK
@roles('storage-master')
def setup_nfs_live_migration(mode):
"""Provisions nfs vm for live migration and live migration related configuration."""
host_string = env.host_string
if host_string == env.roledefs['storage-master'][0]:
storage_host_entries=[]
storage_pass_list=[]
storage_host_list=[]
storage_hostnames=[]
for entry in env.roledefs['storage-master']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
for entry in env.roledefs['storage-compute']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry and entry != env.roledefs['storage-master'][0]:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
storage_master=env.roledefs['storage-master'][0]
storage_master_ip=get_data_ip(storage_master)[0]
storage_master_password=env.passwords[env.roledefs['storage-master'][0]]
cfm = env.roledefs['cfgm'][0]
cfm_ip = get_data_ip(cfm)[0]
if storage_master_ip != cfm_ip:
with settings(host_string = storage_master, password = storage_master_password):
run('mkdir -p %s' %(os.path.dirname(get_ceph_nfs_migration_image())))
put(get_ceph_nfs_migration_image(), os.path.dirname(get_ceph_nfs_migration_image()))
with settings(host_string = storage_master, password = storage_master_password):
with cd(INSTALLER_DIR):
# Argument details
# storage-setup-mode - setup/unconfigure/reconfigure - First time nfs livemigration configurations/Unconfigure/Reconfigure
# storage-master - Storage master IP
# storage-hostnames - hostnames of all the nodes (storage master + storage compute)
# storage-host-tokens - password for all the nodes (storage master + storage compute)
# live-migration - Enable/Disable live migration
# nfs-live-migration - NFS Livemigration configuration (Image path, subnet, host)
cmd= "PASSWORD=%s setup-vnc-livemigration --storage-setup-mode %s --storage-master %s --storage-hostnames %s --storage-hosts %s --storage-host-tokens %s --storage-disk-config %s --storage-directory-config %s --live-migration %s --nfs-live-migration %s" \
%(storage_master_password, mode, storage_master_ip, ' '.join(storage_hostnames), ' '.join(storage_host_list), ' '.join(storage_pass_list), ' '.join(get_storage_disk_config()), ' '.join(get_storage_directory_config()), get_live_migration_opts(), get_nfs_live_migration_opts())
print cmd
run(cmd)
#end setup_nfs_live_migration_services
@task
def setup_add_storage_compute_node(*args):
"""Add a storage compute services in one or list of nodes"""
host_string = env.roledefs['storage-master'][0]
storage_host_entries=[]
storage_pass_list=[]
storage_host_list=[]
storage_hostnames=[]
storage_os_pass_list=[]
storage_os_host_list=[]
index = 0
for entry in env.roledefs['storage-master']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
if index != 0:
storage_os_pass_list.append(storage_host_password)
storage_os_host_list.append(storage_data_ip)
index = index + 1
new_host_entry = args[0]
for entry in env.roledefs['storage-compute']:
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry and entry != env.roledefs['storage-master'][0]:
storage_hostnames.append(sthostname)
storage_host_password=env.passwords[entry]
storage_pass_list.append(storage_host_password)
storage_host = get_control_host_string(entry)
storage_data_ip=get_data_ip(storage_host)[0]
storage_host_list.append(storage_data_ip)
if new_host_entry == entry:
new_storage_hostnames = sthostname
if storage_os_host_list == []:
storage_os_host_list.append('none')
if storage_os_pass_list == []:
storage_os_pass_list.append('none')
storage_master=env.roledefs['storage-master'][0]
storage_master_ip=get_data_ip(storage_master)[0]
storage_master_password=env.passwords[env.roledefs['storage-master'][0]]
with settings(host_string = storage_master, password = storage_master_password):
with cd(INSTALLER_DIR):
# Argument details
# storage-setup-mode - addnode - Add a new node
# storage-master - Storage master IP
# storage-hostnames - hostnames of all the nodes (storage master + storage compute)
# storage-host-tokens - password for all the nodes (storage master + storage compute)
# storage-disk-config - Disk list for Ceph combined pool or HDD pool
# storage-chassis-config - Chassis information list in the form
# of 'host1:id0 host2:id0 host3:id1'
# storage-ssd-disk-config - Disk list for Ceph SSD pool
# storage-journal-config - OSD journal disk list
# storage-local-disk-config - Disk list for local LVM pool
# storage-local-ssd-disk-config - Disk list for local LVM SSD pool
# storage-local-nfs-disk-config - NFS storage list
# storage-directory-config - Directory list for Ceph
# cinder-vip - cinder internal vip address
# storage-os-hosts - storage openstack hosts (except storage-master)
# storage-os-host-tokens - storage openstack hosts passwd list
cmd= "PASSWORD=%s setup-vnc-storage --storage-setup-mode addnode --add-storage-node %s --storage-master %s --storage-hostnames %s --storage-hosts %s --storage-host-tokens %s --storage-disk-config %s --storage-ssd-disk-config %s --storage-journal-config %s --storage-local-disk-config %s --storage-local-ssd-disk-config %s --storage-nfs-disk-config %s --storage-directory-config %s --storage-chassis-config %s --live-migration %s --cinder-vip %s --storage-os--hosts %s --storage-os-host-tokens %s" \
%(storage_master_password, new_storage_hostnames, storage_master_ip, ' '.join(storage_hostnames), ' '.join(storage_host_list), ' '.join(storage_pass_list), ' '.join(get_storage_disk_config()), ' '.join(get_storage_ssd_disk_config()), ' '.join(get_storage_journal_config()), ' '.join(get_storage_local_disk_config()), ' '.join(get_storage_local_ssd_disk_config()), ' '.join(get_storage_nfs_disk_config()), ' '.join(get_storage_directory_config()), ' '.join(get_storage_chassis_config()), get_live_migration_opts(), get_cinder_ha_vip(), ' '.join(storage_os_host_list), ' '.join(storage_os_pass_list))
print cmd
run(cmd)
@task
@EXECUTE_TASK
@roles('storage-compute')
def setup_compute_storage():
"""Provisions storage compute services."""
execute("setup_storage_compute_node", env.host_string)
@task
def setup_storage_compute_node(*args):
"""Provisions storage compute services in one or list of nodes"""
#dummy for now
return
@task
@roles('build')
def unconfigure_storage():
"""UnProvisions required contrail services in all nodes as per the role definition.
"""
execute("setup_master_storage", "unconfigure")
execute(setup_compute_storage)
execute("setup_webui_storage", "unconfigure")
#end unconfigure_storage
@task
@roles('build')
def storage_chassis_configure():
"""ReProvisions required contrail services in all nodes as per the role definition.
"""
execute("setup_master_storage", "chassis_configure")
execute(setup_compute_storage)
#end storage_chassis_configure
@task
@roles('build')
def reconfigure_storage():
"""ReProvisions required contrail services in all nodes as per the role definition.
"""
execute("setup_master_storage", "reconfigure")
execute(setup_compute_storage)
execute("setup_webui_storage", "reconfigure")
#end reconfigure_storage
@task
@roles('build')
def setup_storage():
"""Provisions required contrail services in all nodes as per the role definition.
"""
execute("setup_master_storage", "setup")
execute(setup_compute_storage)
execute("setup_webui_storage", "setup")
#end setup_storage
@task
@roles('build')
def setup_nfs_livem():
"""Provisions required contrail services in all nodes as per the role definition.
"""
execute("setup_nfs_live_migration", "setup")
#end setup_nfs_livem
@task
@roles('build')
def setup_nfs_livem_global():
"""Provisions required contrail services in all nodes as per the role definition.
"""
execute("setup_nfs_live_migration", "setup_global")
#end setup_nfs_livem_global
@task
@roles('build')
def unconfigure_nfs_livem():
"""UnProvisions required contrail services in all nodes as per the role definition.
"""
execute("setup_nfs_live_migration", "unconfigure")
#end unconfigure_nfs_livem