Skip to content

Commit 3bcb53c

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Made MySQL installation optional"
2 parents 86c8544 + e570bdf commit 3bcb53c

31 files changed

Lines changed: 700 additions & 94 deletions

packstack/installer/utils/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
from .decorators import retry
55
from .network import get_localhost_ip, host2ip, force_ip, device_from_ip
66
from .shell import ScriptRunner, execute
7+
from .shortcuts import host_iter, hosts
78
from .strings import COLORS, color_text, mask_string
89

910

1011
__all__ = ('SortedDict',
1112
'retry',
12-
'ScriptRunner', 'execute',
1313
'get_localhost_ip', 'host2ip', 'force_ip', 'device_from_ip',
14+
'ScriptRunner', 'execute',
15+
'host_iter', 'hosts',
1416
'COLORS', 'color_text', 'mask_string')
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
3+
4+
def host_iter(config):
5+
for key, value in config.iteritems():
6+
if key.endswith("_HOST"):
7+
host = value.split('/')[0]
8+
yield key, host
9+
if key.endswith("_HOSTS"):
10+
for i in value.split(","):
11+
host = i.strip().split('/')[0]
12+
yield key, host
13+
14+
15+
def hosts(config):
16+
result = set()
17+
for key, host in host_iter(config):
18+
result.add(host)
19+
return result

packstack/modules/common.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
# -*- coding: utf-8 -*-
22

3-
from .ospluginutils import gethostlist
3+
from ..installer import utils
4+
5+
6+
def filtered_hosts(config, exclude=True, dbhost=True):
7+
"""
8+
Returns list of hosts which need installation taking into account
9+
CONFIG_MYSQL_INSTAL if parameter dbhost is True and EXCLUDE_SERVERS
10+
if parameter exclude is True.
11+
"""
12+
exclset = set([i.strip()
13+
for i in config.get('EXCLUDE_SERVERS', '').split(',')
14+
if i.strip()])
15+
result = set()
16+
dbinst = config.get('CONFIG_MYSQL_INSTALL') == 'y'
17+
for hosttype, hostname in utils.host_iter(config):
18+
if dbhost and not dbinst and hosttype == 'CONFIG_MYSQL_HOST':
19+
continue
20+
result.add(hostname)
21+
if exclude:
22+
result = result - exclset
23+
return result
424

525

626
def is_all_in_one(config):
727
"""
828
Returns True if packstack is running allinone setup, otherwise
929
returns False.
1030
"""
11-
return len(gethostlist(config)) == 1
31+
return len(filtered_hosts(config, exclude=False)) == 1

packstack/plugins/mysql_001.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import logging
77

88
from packstack.installer import validators
9-
from packstack.installer import basedefs
109
from packstack.installer import utils
1110

1211
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile
@@ -82,23 +81,30 @@ def initSequences(controller):
8281

8382

8483
def createmanifest(config):
85-
host = controller.CONF['CONFIG_MYSQL_HOST']
84+
if config['CONFIG_MYSQL_INSTALL'] == 'y':
85+
install = True
86+
suffix = 'install'
87+
else:
88+
install = False
89+
suffix = 'noinstall'
90+
91+
# In case we are not installing MySQL server, mysql* manifests have
92+
# to be run from Keystone host
93+
host = install and config['CONFIG_MYSQL_HOST'] \
94+
or config['CONFIG_KEYSTONE_HOST']
8695
manifestfile = "%s_mysql.pp" % host
87-
manifestdata = [getManifestTemplate("mysql.pp")]
96+
manifestdata = [getManifestTemplate('mysql_%s.pp' % suffix)]
8897

89-
def append_for(module):
90-
# Modules have be appended to the existing mysql.pp
98+
def append_for(module, suffix):
99+
# Modules have to be appended to the existing mysql.pp
91100
# otherwise pp will fail for some of them saying that
92101
# Mysql::Config definition is missing.
93-
manifestdata.append(getManifestTemplate("mysql_%s.pp" % module))
94-
95-
if controller.CONF['CONFIG_NOVA_INSTALL'] == "y":
96-
append_for("nova")
97-
if controller.CONF['CONFIG_CINDER_INSTALL'] == "y":
98-
append_for("cinder")
99-
if controller.CONF['CONFIG_GLANCE_INSTALL'] == "y":
100-
append_for("glance")
101-
if controller.CONF['CONFIG_NEUTRON_INSTALL'] == 'y':
102-
append_for("neutron")
102+
template = "mysql_%s_%s.pp" % (module, suffix)
103+
manifestdata.append(getManifestTemplate(template))
104+
105+
append_for("keystone", suffix)
106+
for mod in ['nova', 'cinder', 'glance', 'neutron']:
107+
if config['CONFIG_%s_INSTALL' % mod.upper()] == 'y':
108+
append_for(mod, suffix)
103109

104110
appendManifestFile(manifestfile, "\n".join(manifestdata), 'pre')

packstack/plugins/postscript_949.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44

55
import logging
66

7-
from packstack.installer import validators
8-
from packstack.installer import basedefs, output_messages
9-
from packstack.installer import utils
10-
11-
from packstack.modules.ospluginutils import gethostlist,\
12-
getManifestTemplate, \
13-
appendManifestFile
7+
from packstack.modules.common import filtered_hosts
8+
from packstack.modules.ospluginutils import (getManifestTemplate,
9+
appendManifestFile)
1410

1511
# Controller object will be initialized from main flow
1612
controller = None
@@ -42,8 +38,9 @@ def initSequences(controller):
4238
]
4339
controller.addSequence("Running post install scripts", [], [], osclientsteps)
4440

41+
4542
def createmanifest(config):
46-
for hostname in gethostlist(controller.CONF):
43+
for hostname in filtered_hosts(config):
4744
manifestfile = "%s_postscript.pp" % hostname
4845
manifestdata = getManifestTemplate("postscript.pp")
4946
appendManifestFile(manifestfile, manifestdata, 'postscript')

packstack/plugins/prescript_000.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
"""
44

55
import logging
6-
import os
76
import uuid
87

9-
from packstack.installer import exceptions
10-
from packstack.installer import utils
118
from packstack.installer import validators
12-
from packstack.modules.ospluginutils import gethostlist,\
13-
getManifestTemplate, \
14-
appendManifestFile
9+
10+
from packstack.modules.common import filtered_hosts
11+
from packstack.modules.ospluginutils import (getManifestTemplate,
12+
appendManifestFile)
1513

1614
# Controller object will be initialized from main flow
1715
controller = None
@@ -25,7 +23,18 @@ def initConfig(controllerObject):
2523
global controller
2624
controller = controllerObject
2725

28-
paramsList = [
26+
paramsList = [{"CMD_OPTION" : "os-mysql-install",
27+
"USAGE" : "Set to 'y' if you would like Packstack to install MySQL",
28+
"PROMPT" : "Should Packstack install MySQL DB",
29+
"OPTION_LIST" : ["y", "n"],
30+
"VALIDATORS" : [validators.validate_options],
31+
"DEFAULT_VALUE" : "y",
32+
"MASK_INPUT" : False,
33+
"LOOSE_VALIDATION": False,
34+
"CONF_NAME" : "CONFIG_MYSQL_INSTALL",
35+
"USE_DEFAULT" : False,
36+
"NEED_CONFIRM" : False,
37+
"CONDITION" : False },
2938
{"CMD_OPTION" : "os-glance-install",
3039
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Image Service (Glance)",
3140
"PROMPT" : "Should Packstack install OpenStack Image Service (Glance)",
@@ -171,7 +180,7 @@ def initSequences(controller):
171180
'some OpenStack components.')
172181

173182
def createmanifest(config):
174-
for hostname in gethostlist(controller.CONF):
183+
for hostname in filtered_hosts(config):
175184
manifestfile = "%s_prescript.pp" % hostname
176185
manifestdata = getManifestTemplate("prescript.pp")
177186
appendManifestFile(manifestfile, manifestdata)
@@ -186,7 +195,7 @@ def create_ntp_manifest(config):
186195
config['CONFIG_NTP_SERVER_DEF'] = '%s\n' % definiton
187196

188197
marker = uuid.uuid4().hex[:16]
189-
for hostname in gethostlist(config):
198+
for hostname in filtered_hosts(config):
190199
manifestdata = getManifestTemplate('ntpd.pp')
191200
appendManifestFile('%s_ntpd.pp' % hostname,
192201
manifestdata,

packstack/plugins/provision_700.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
"""
44

55
import logging
6-
import os
7-
import re
8-
import uuid
96

10-
from packstack.installer import utils
117
from packstack.installer import validators
128

13-
from packstack.modules.ospluginutils import (
14-
appendManifestFile,
15-
getManifestTemplate,
16-
gethostlist,
17-
)
9+
from packstack.modules.common import is_all_in_one
10+
from packstack.modules.ospluginutils import (appendManifestFile,
11+
getManifestTemplate)
1812

1913

2014
# Controller object will be initialized from main flow
@@ -113,9 +107,6 @@ def initConfig(controllerObject):
113107
],
114108
}
115109

116-
def is_all_in_one(config):
117-
return len(gethostlist(config)) == 1
118-
119110
def allow_provisioning(config):
120111
# Provisioning is currently supported only for all-in-one (due
121112
# to a limitation with how the custom types for OpenStack
@@ -168,7 +159,7 @@ def initSequences(controller):
168159
controller.CONF['CONFIG_PROVISION_TEMPEST'] == 'y'
169160
)
170161
if not provisioning_required:
171-
return
162+
return
172163
marshall_conf_bool(controller.CONF, 'CONFIG_PROVISION_TEMPEST')
173164
marshall_conf_bool(controller.CONF,
174165
'CONFIG_PROVISION_ALL_IN_ONE_OVS_BRIDGE')

packstack/plugins/puppet_950.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from packstack.installer import basedefs, output_messages
1212
from packstack.installer.exceptions import ScriptRuntimeError
1313

14-
from packstack.modules.ospluginutils import (gethostlist,
15-
manifestfiles,
14+
from packstack.modules.common import filtered_hosts
15+
from packstack.modules.ospluginutils import (manifestfiles,
1616
scan_puppet_logfile,
1717
validate_puppet_logfile)
1818

@@ -46,15 +46,6 @@ def initConfig(controllerObject):
4646
controller.addGroup(groupDict, paramsList)
4747

4848

49-
def getinstallhostlist(conf):
50-
list = []
51-
exclude_list = map(str.strip, conf['EXCLUDE_SERVERS'].split(','))
52-
for host in gethostlist(conf):
53-
if host not in exclude_list:
54-
list.append(host)
55-
return list
56-
57-
5849
def initSequences(controller):
5950
puppetpresteps = [
6051
{'title': 'Clean Up', 'functions':[runCleanup]},
@@ -76,7 +67,7 @@ def runCleanup(config):
7667

7768

7869
def installdeps(config):
79-
for hostname in getinstallhostlist(controller.CONF):
70+
for hostname in filtered_hosts(config):
8071
server = utils.ScriptRunner(hostname)
8172
for package in ("puppet", "openssh-clients", "tar", "nc"):
8273
server.append("rpm -q %s || yum install -y %s" % (package, package))
@@ -100,9 +91,8 @@ def copyPuppetModules(config):
10091
tar_opts = ""
10192
if platform.linux_distribution()[0] == "Fedora":
10293
tar_opts += "--exclude create_resources "
103-
for hostname in getinstallhostlist(controller.CONF):
94+
for hostname in filtered_hosts(config):
10495
host_dir = controller.temp_map[hostname]
105-
puppet_dir = os.path.join(host_dir, basedefs.PUPPET_MANIFEST_RELATIVE)
10696
server.append("cd %s/puppet" % basedefs.DIR_PROJECT_DIR)
10797
# copy Packstack facts
10898
server.append("tar %s --dereference -cpzf - facts | "
@@ -165,7 +155,7 @@ def waitforpuppet(currently_running):
165155
if hasattr(sys.stdout, "isatty") and sys.stdout.isatty():
166156
sys.stdout.write(("\r").ljust(45 + log_len))
167157

168-
except ScriptRuntimeError, e:
158+
except ScriptRuntimeError:
169159
# the test raises an exception if the file doesn't exist yet
170160
# TO-DO: We need to start testing 'e' for unexpected exceptions
171161
time.sleep(3)
@@ -176,7 +166,7 @@ def waitforpuppet(currently_running):
176166

177167
# check the log file for errors
178168
validate_puppet_logfile(log)
179-
sys.stdout.write(("\r%s : " % log_file).ljust(basedefs.SPACE_LEN))
169+
sys.stdout.write(("\r%s : " % log_file).ljust(space_len))
180170
print ("[ " + utils.color_text(output_messages.INFO_DONE, 'green') + " ]")
181171

182172

@@ -191,7 +181,7 @@ def applyPuppetManifest(config):
191181
waitforpuppet(currently_running)
192182
lastmarker = marker
193183

194-
for hostname in getinstallhostlist(controller.CONF):
184+
for hostname in filtered_hosts(config):
195185
if "%s_" % hostname not in manifest:
196186
continue
197187

packstack/plugins/serverprep_901.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
import os
66
import uuid
77
import logging
8-
import datetime
98
import platform
109

1110
from packstack.installer import basedefs
1211
from packstack.installer import exceptions
1312
from packstack.installer import utils
1413
from packstack.installer import validators
1514

16-
17-
from packstack.modules.ospluginutils import gethostlist
15+
from packstack.modules.common import filtered_hosts
1816

1917
# Controller object will be initialized from main flow
2018
controller = None
@@ -399,10 +397,7 @@ def serverprep(config):
399397
'proxy_pass': sat_proxy_pass.strip(),
400398
'flags': sat_flags}
401399

402-
for hostname in gethostlist(config):
403-
if '/' in hostname:
404-
hostname = hostname.split('/')[0]
405-
400+
for hostname in filtered_hosts(config):
406401
# Subscribe to Red Hat Repositories if configured
407402
if rh_username:
408403
run_rhsm_reg(hostname, rh_username, rh_password, config["CONFIG_RH_BETA_REPO"] == 'y')

packstack/plugins/sshkeys_000.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
import glob
66
import logging
77
import os
8-
import tempfile
98

109
from packstack.installer import processors
1110
from packstack.installer import validators
12-
from packstack.installer import basedefs
1311
from packstack.installer import utils
1412

15-
from packstack.modules.ospluginutils import gethostlist
13+
from packstack.modules.common import filtered_hosts
1614

1715
# Controller object will be initialized from main flow
1816
controller = None
@@ -62,11 +60,9 @@ def initSequences(controller):
6260

6361

6462
def installKeys(config):
65-
with open(controller.CONF["CONFIG_SSH_KEY"]) as fp:
63+
with open(config["CONFIG_SSH_KEY"]) as fp:
6664
sshkeydata = fp.read().strip()
67-
for hostname in gethostlist(controller.CONF):
68-
if '/' in hostname:
69-
hostname = hostname.split('/')[0]
65+
for hostname in filtered_hosts(config):
7066
server = utils.ScriptRunner(hostname)
7167
# TODO replace all that with ssh-copy-id
7268
server.append("mkdir -p ~/.ssh")

0 commit comments

Comments
 (0)