forked from ungleich-public/cdist
fixup most arguments for config
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
df7f27f94b
commit
8d1b4236d4
1 changed files with 30 additions and 25 deletions
55
bin/cdist
55
bin/cdist
|
@ -598,46 +598,48 @@ class Cdist:
|
||||||
self.deploy_to()
|
self.deploy_to()
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
|
||||||
def banner(*args):
|
def banner(args):
|
||||||
"""Guess what :-)"""
|
"""Guess what :-)"""
|
||||||
print(BANNER)
|
print(BANNER)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def config(*args):
|
def config(args):
|
||||||
"""Configure remote system"""
|
"""Configure remote system"""
|
||||||
print(*args)
|
print(args)
|
||||||
process = {}
|
process = {}
|
||||||
if len(args.host) == 0:
|
|
||||||
parser.print_help()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
time_start = datetime.datetime.now()
|
if len(args.host) == 0:
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
for host in args.host:
|
time_start = datetime.datetime.now()
|
||||||
c = Cdist(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug)
|
|
||||||
if args.parallel:
|
|
||||||
log.debug("Starting child process for %s", host)
|
|
||||||
process[host] = multiprocessing.Process(target=c.deploy_and_cleanup)
|
|
||||||
process[host].start()
|
|
||||||
log.debug("After process for %s", host)
|
|
||||||
else:
|
|
||||||
c.deploy_and_cleanup()
|
|
||||||
|
|
||||||
|
for host in args.host:
|
||||||
|
c = Cdist(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug)
|
||||||
if args.parallel:
|
if args.parallel:
|
||||||
for p in process.keys():
|
log.debug("Starting child process for %s", host)
|
||||||
log.debug("Joining %s", p)
|
process[host] = multiprocessing.Process(target=c.deploy_and_cleanup)
|
||||||
process[p].join()
|
process[host].start()
|
||||||
|
log.debug("After process for %s", host)
|
||||||
|
else:
|
||||||
|
c.deploy_and_cleanup()
|
||||||
|
|
||||||
time_end = datetime.datetime.now()
|
if args.parallel:
|
||||||
log.info("Total processing time for %s host(s): %s", len(args.host),
|
for p in process.keys():
|
||||||
(time_end - time_start).total_seconds())
|
log.debug("Joining %s", p)
|
||||||
|
process[p].join()
|
||||||
|
|
||||||
|
time_end = datetime.datetime.now()
|
||||||
|
log.info("Total processing time for %s host(s): %s", len(args.host),
|
||||||
|
(time_end - time_start).total_seconds())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Construct parser others can reuse
|
# Construct parser others can reuse
|
||||||
parser = {}
|
parser = {}
|
||||||
# Options _all_ parsers have in common
|
# Options _all_ parsers have in common
|
||||||
parser['most'] = argparse.ArgumentParser(add_help=False)
|
parser['most'] = argparse.ArgumentParser(add_help=False,
|
||||||
|
epilog="Get cdist at http://www.nico.schottelius.org/software/cdist/")
|
||||||
parser['most'].add_argument('-d', '--debug',
|
parser['most'].add_argument('-d', '--debug',
|
||||||
help='Set log level to debug',
|
help='Set log level to debug',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
@ -645,9 +647,12 @@ if __name__ == "__main__":
|
||||||
help='Show version',
|
help='Show version',
|
||||||
action='version',
|
action='version',
|
||||||
version='%(prog)s ' + VERSION)
|
version='%(prog)s ' + VERSION)
|
||||||
|
#version='%(prog)s ' + VERSION)
|
||||||
|
|
||||||
|
|
||||||
# Main subcommand parser
|
# Main subcommand parser
|
||||||
parser['main'] = argparse.ArgumentParser(description='cdist ' + VERSION)
|
parser['main'] = argparse.ArgumentParser(description='cdist ' + VERSION,
|
||||||
|
parents=[parser['most']])
|
||||||
parser['sub'] = parser['main'].add_subparsers()
|
parser['sub'] = parser['main'].add_subparsers()
|
||||||
|
|
||||||
parser['banner'] = parser['sub'].add_parser('banner')
|
parser['banner'] = parser['sub'].add_parser('banner')
|
||||||
|
@ -656,7 +661,7 @@ if __name__ == "__main__":
|
||||||
parser['config'] = parser['sub'].add_parser('config',
|
parser['config'] = parser['sub'].add_parser('config',
|
||||||
aliases=['deploy'],
|
aliases=['deploy'],
|
||||||
parents=[parser['most']])
|
parents=[parser['most']])
|
||||||
parser['config'].add_argument('host', nargs='*',
|
parser['config'].add_argument('host', nargs='+',
|
||||||
help='one or more hosts to operate on')
|
help='one or more hosts to operate on')
|
||||||
parser['config'].add_argument('-c', '--cdist-home',
|
parser['config'].add_argument('-c', '--cdist-home',
|
||||||
help='Change cdist home (default: .. from bin directory)',
|
help='Change cdist home (default: .. from bin directory)',
|
||||||
|
|
Loading…
Reference in a new issue