-
Notifications
You must be signed in to change notification settings - Fork 46
/
install.py
117 lines (98 loc) · 3.65 KB
/
install.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
import os
import re
import copy
import tempfile
from fabfile.config import *
from fabfile.utils.fabos import *
from fabfile.tasks.install import yum_install, apt_install
@task
@parallel(pool_size=20)
@roles('all')
def install_storage_pkg_all(pkg):
"""Installs any rpm/deb in storage-master/storage-compute nodes."""
execute('install_storage_pkg_node', pkg, env.host_string)
@task
def install_storage_pkg_node(pkg, *args):
"""Installs any rpm/deb in storage-master/storage-compute node."""
for host_string in args:
with settings(host_string=host_string, warn_only=True):
build = get_build('contrail-storage-packages')
if build and build in pkg:
print "Package %s already installed in the node(%s)." % (pkg, host_string)
continue
pkg_name = os.path.basename(pkg)
temp_dir= tempfile.mkdtemp()
run('mkdir -p %s' % temp_dir)
put(pkg, '%s/%s' % (temp_dir, pkg_name))
if pkg.endswith('.rpm'):
run("yum --disablerepo=* -y localinstall %s/%s" % (temp_dir, pkg_name))
elif pkg.endswith('.deb'):
run("dpkg -i %s/%s" % (temp_dir, pkg_name))
@task
@EXECUTE_TASK
@roles('storage-master')
def install_storage_master():
"""Installs storage pkgs in all nodes defined in storage-master role."""
execute("install_storage_master_node", env.host_string)
@task
def install_storage_master_node(*args):
"""Installs storage pkgs in one or list of nodes. USAGE:fab install_openstack_storage_node:user@1.1.1.1,user@2.2.2.2"""
for host_string in args:
with settings(host_string=host_string):
pkg = ['contrail-storage']
if detect_ostype() == 'Ubuntu':
apt_install(pkg)
else:
yum_install(pkg)
@task
@EXECUTE_TASK
@roles('webui')
def install_storage_webui():
"""Installs storage webui pkgs in all nodes defined in webui role."""
if env.roledefs['webui']:
execute("install_storage_webui_node", env.host_string)
@task
def install_storage_webui_node(*args):
"""Installs storage pkgs in one or list of nodes. USAGE:fab install_storage_webui:user@1.1.1.1,user@2.2.2.2"""
for host_string in args:
with settings(host_string=host_string):
pkg = ['contrail-web-storage']
if detect_ostype() == 'Ubuntu':
apt_install(pkg)
else:
yum_install(pkg)
@task
@EXECUTE_TASK
@roles('storage-compute')
def install_storage_compute():
"""Installs storage pkgs in all nodes defined in storage-compute role."""
execute("install_storage_compute_node", env.host_string)
@task
def install_storage_compute_node(*args):
"""Installs storage pkgs in one or list of nodes. USAGE:fab install_compute_storage_node:user@1.1.1.1,user@2.2.2.2"""
for host_string in args:
with settings(host_string=host_string):
pkg = ['contrail-storage']
if detect_ostype() == 'Ubuntu':
apt_install(pkg)
else:
yum_install(pkg)
@task
@EXECUTE_TASK
@roles('all')
def create_storage_repo():
execute('create_storage_repo_node', env.host_string)
@task
def create_storage_repo_node(*args):
for host_string in args:
with settings(host_string=host_string, warn_only=True):
run("sudo /opt/contrail/contrail_packages/setup_storage.sh")
@roles('build')
@task
def install_storage():
"""Installs required storage packages in nodes as per the role definition.
"""
execute(create_storage_repo)
execute(install_storage_master)
execute(install_storage_compute)
execute(install_storage_webui)