forked from redhat-openstack/packstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprescript_000.py
More file actions
226 lines (212 loc) · 12.1 KB
/
Copy pathprescript_000.py
File metadata and controls
226 lines (212 loc) · 12.1 KB
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
"""
Plugin responsible for setting OpenStack global options
"""
import logging
import uuid
from packstack.installer import validators
from packstack.modules.common import filtered_hosts
from packstack.modules.ospluginutils import (getManifestTemplate,
appendManifestFile)
# Controller object will be initialized from main flow
controller = None
# Plugin name
PLUGIN_NAME = "OS-PRESCRIPT"
logging.debug("plugin %s loaded", __name__)
def initConfig(controllerObject):
global controller
controller = controllerObject
paramsList = [{"CMD_OPTION" : "os-mysql-install",
"USAGE" : "Set to 'y' if you would like Packstack to install MySQL",
"PROMPT" : "Should Packstack install MySQL DB",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_MYSQL_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-glance-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Image Service (Glance)",
"PROMPT" : "Should Packstack install OpenStack Image Service (Glance)",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_GLANCE_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-cinder-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Block Storage (Cinder)",
"PROMPT" : "Should Packstack install OpenStack Block Storage (Cinder) service",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CINDER_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-nova-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Compute (Nova)",
"PROMPT" : "Should Packstack install OpenStack Compute (Nova) service",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NOVA_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-neutron-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Networking (Neutron)",
"PROMPT" : "Should Packstack install OpenStack Networking (Neutron) service",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NEUTRON_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-horizon-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Dashboard (Horizon)",
"PROMPT" : "Should Packstack install OpenStack Dashboard (Horizon)",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HORIZON_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-swift-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Object Storage (Swift)",
"PROMPT" : "Should Packstack install OpenStack Object Storage (Swift)",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_SWIFT_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-ceilometer-install",
"USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Metering (Ceilometer)",
"PROMPT" : "Should Packstack install OpenStack Metering (Ceilometer)",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CEILOMETER_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-heat-install",
"USAGE" : "Set to 'y' if you would like Packstack to install Heat",
"PROMPT" : "Should Packstack install Heat",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "n",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_HEAT_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "os-client-install",
"USAGE" : "Set to 'y' if you would like Packstack to install the OpenStack Client packages. An admin \"rc\" file will also be installed",
"PROMPT" : "Should Packstack install OpenStack client tools",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : "y",
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_CLIENT_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "ntp-severs",
"USAGE" : "Comma separated list of NTP servers. Leave plain if Packstack should not install ntpd on instances.",
"PROMPT" : "Enter a comma separated list of NTP server(s). Leave plain if Packstack should not install ntpd on instances.",
"OPTION_LIST" : [],
"DEFAULT_VALUE" : '',
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NTP_SERVERS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "nagios-install",
"USAGE" : "Set to 'y' if you would like Packstack to install Nagios to monitor openstack hosts",
"PROMPT" : "Should Packstack install Nagios to monitor openstack hosts",
"OPTION_LIST" : ["y", "n"],
"VALIDATORS" : [validators.validate_options],
"DEFAULT_VALUE" : 'n',
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "CONFIG_NAGIOS_INSTALL",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
{"CMD_OPTION" : "exclude-servers",
"USAGE" : "Comma separated list of servers to be excluded from installation in case you are running Packstack the second time with the same answer file and don't want Packstack to touch these servers. Leave plain if you don't need to exclude any server.",
"PROMPT" : "Enter a comma separated list of server(s) to be excluded. Leave plain if you don't need to exclude any server.",
"OPTION_LIST" : [],
"DEFAULT_VALUE" : '',
"MASK_INPUT" : False,
"LOOSE_VALIDATION": False,
"CONF_NAME" : "EXCLUDE_SERVERS",
"USE_DEFAULT" : False,
"NEED_CONFIRM" : False,
"CONDITION" : False },
]
groupDict = { "GROUP_NAME" : "GLOBAL",
"DESCRIPTION" : "Global Options",
"PRE_CONDITION" : lambda x: 'yes',
"PRE_CONDITION_MATCH" : "yes",
"POST_CONDITION" : False,
"POST_CONDITION_MATCH" : True}
controller.addGroup(groupDict, paramsList)
def initSequences(controller):
osclientsteps = [
{'title': 'Adding pre install manifest entries', 'functions':[createmanifest]},
]
controller.addSequence("Running pre install scripts", [], [], osclientsteps)
if controller.CONF['CONFIG_NTP_SERVERS']:
ntp_step = [{'functions': [create_ntp_manifest],
'title': 'Installing time synchronization via NTP'}]
controller.addSequence('Installing time synchronization via NTP', [], [], ntp_step)
else:
controller.MESSAGES.append('Time synchronization installation '
'was skipped. Please note that '
'unsynchronized time on server '
'instances might be problem for '
'some OpenStack components.')
def createmanifest(config):
for hostname in filtered_hosts(config):
manifestfile = "%s_prescript.pp" % hostname
manifestdata = getManifestTemplate("prescript.pp")
appendManifestFile(manifestfile, manifestdata)
def create_ntp_manifest(config):
srvlist = [i.strip()
for i in config['CONFIG_NTP_SERVERS'].split(',')
if i.strip()]
config['CONFIG_NTP_SERVERS'] = ' '.join(srvlist)
definiton = '\n'.join(['server %s' % i for i in srvlist])
config['CONFIG_NTP_SERVER_DEF'] = '%s\n' % definiton
marker = uuid.uuid4().hex[:16]
for hostname in filtered_hosts(config):
manifestdata = getManifestTemplate('ntpd.pp')
appendManifestFile('%s_ntpd.pp' % hostname,
manifestdata,
marker=marker)