Revision 3bae85da snf-deploy/snfdeploy/__init__.py
b/snf-deploy/snfdeploy/__init__.py | ||
---|---|---|
13 | 13 |
import imp |
14 | 14 |
import ast |
15 | 15 |
from snfdeploy.lib import * |
16 |
from snfdeploy import fabfile |
|
17 |
from fabric.api import hide, env, settings, local, roles, execute, show |
|
16 | 18 |
|
17 | 19 |
def print_available_actions(command): |
18 | 20 |
|
... | ... | |
243 | 245 |
"everything": ["warnings", "running", "user", "output"] |
244 | 246 |
} |
245 | 247 |
|
246 |
hide = ",".join(level_aliases["everything"])
|
|
247 |
show = None
|
|
248 |
lhide = level_aliases["everything"]
|
|
249 |
lshow = []
|
|
248 | 250 |
|
249 | 251 |
if args.verbose == 1: |
250 |
show = ",".join(levels[:3])
|
|
251 |
hide = ",".join(levels[3:])
|
|
252 |
lshow = levels[:3]
|
|
253 |
lhide = levels[3:]
|
|
252 | 254 |
elif args.verbose == 2: |
253 |
show = ",".join(levels[:4])
|
|
254 |
hide = ",".join(levels[4:])
|
|
255 |
lshow = levels[:4]
|
|
256 |
lhide = levels[4:]
|
|
255 | 257 |
elif args.verbose >= 3 or args.debug: |
256 |
show = ",".join(levels)
|
|
257 |
hide = None
|
|
258 |
lshow = levels
|
|
259 |
lhide = []
|
|
258 | 260 |
|
259 |
if args.ssh_key: |
|
260 |
fabcmd = "fab -i %s " % args.ssh_key |
|
261 |
else: |
|
262 |
fabcmd = "fab " |
|
263 |
|
|
264 |
fabcmd += " --fabfile /usr/share/pyshared/snfdeploy/fabfile.py \ |
|
265 |
setup_env:confdir={0},packages={1},templates={2},cluster_name={3},\ |
|
266 |
autoconf={4},disable_colors={5},key_inject={6} \ |
|
267 |
".format(args.confdir, env.packages, env.templates, args.cluster_name, |
|
268 |
args.autoconf, args.disable_colors, args.key_inject) |
|
261 |
# fabcmd += " --fabfile {4}/fabfile.py \ |
|
262 |
# setup_env:confdir={0},packages={1},templates={2},cluster_name={3},\ |
|
263 |
# autoconf={5},disable_colors={6},key_inject={7} \ |
|
264 |
# ".format(args.confdir, env.packages, env.templates, args.cluster_name, |
|
265 |
# env.lib, args.autoconf, args.disable_colors, args.key_inject) |
|
269 | 266 |
|
270 | 267 |
if nodes: |
271 |
hosts = [env.nodes_info[n].hostname for n in nodes] |
|
272 |
actions = [a + ':hosts="%s"' % ";".join(hosts) for a in actions] |
|
273 |
|
|
274 |
extra = " ".join(actions) |
|
275 |
|
|
276 |
fabcmd += extra |
|
277 |
|
|
278 |
if show: |
|
279 |
fabcmd += " --show %s " % show |
|
280 |
if hide: |
|
281 |
fabcmd += " --hide %s " % hide |
|
282 |
|
|
283 |
# print("snf-deploy run " + " ".join(actions) + " -vvv") |
|
284 |
print(fabcmd) |
|
268 |
ips = [env.nodes_info[n].ip for n in nodes] |
|
285 | 269 |
|
286 |
if not args.dry_run: |
|
287 |
ret = os.system(fabcmd) |
|
288 |
if ret != 0: |
|
289 |
status = "exit with status %s" % ret |
|
290 |
sys.exit(status) |
|
270 |
fabfile.setup_env(args) |
|
271 |
with settings(hide(*lhide), show(*lshow)): |
|
272 |
print " ".join(actions) |
|
273 |
for a in actions: |
|
274 |
fn = getattr(fabfile, a) |
|
275 |
if not args.dry_run: |
|
276 |
if nodes: |
|
277 |
execute(fn, hosts=ips) |
|
278 |
else: |
|
279 |
execute(fn) |
|
291 | 280 |
|
292 | 281 |
|
293 | 282 |
def cluster(args, env): |
... | ... | |
572 | 561 |
def main(): |
573 | 562 |
args = parse_options() |
574 | 563 |
|
575 |
conf = Conf.configure(args.confdir, args.cluster_name, args, args.autoconf)
|
|
564 |
conf = Conf(args)
|
|
576 | 565 |
env = Env(conf) |
577 | 566 |
|
578 | 567 |
create_dir(env.run, False) |
Also available in: Unified diff