forked from ungleich-public/cdist
integrate parser
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
c5d960438c
commit
979174a568
1 changed files with 36 additions and 50 deletions
86
bin/cdist
86
bin/cdist
|
@ -20,13 +20,13 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import argparse
|
||||||
import subprocess # execute stuff
|
|
||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import shutil
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
# Given paths from installation
|
# Given paths from installation
|
||||||
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
|
@ -37,6 +37,7 @@ MANIFEST_DIR = os.path.join(CONF_DIR, "manifest")
|
||||||
REMOTE_BASE_DIR = "/var/lib/cdist"
|
REMOTE_BASE_DIR = "/var/lib/cdist"
|
||||||
REMOTE_CONF_DIR = os.path.join(REMOTE_BASE_DIR, "conf")
|
REMOTE_CONF_DIR = os.path.join(REMOTE_BASE_DIR, "conf")
|
||||||
REMOTE_GLOBAL_EXPLORER_DIR = os.path.join(REMOTE_CONF_DIR, "explorer")
|
REMOTE_GLOBAL_EXPLORER_DIR = os.path.join(REMOTE_CONF_DIR, "explorer")
|
||||||
|
VERSION = "2.0.0"
|
||||||
|
|
||||||
|
|
||||||
#class Context(object):
|
#class Context(object):
|
||||||
|
@ -64,7 +65,6 @@ log = logging.getLogger()
|
||||||
|
|
||||||
class Cdist:
|
class Cdist:
|
||||||
"""Cdist main class to hold arbitrary data"""
|
"""Cdist main class to hold arbitrary data"""
|
||||||
version="2.0.0"
|
|
||||||
|
|
||||||
def __init__(self, hostname, initial_manifest=False):
|
def __init__(self, hostname, initial_manifest=False):
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
|
@ -195,47 +195,33 @@ class Cdist:
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
hostname=sys.argv[1]
|
hostname=sys.argv[1]
|
||||||
|
|
||||||
for host in sys.argv[1:]:
|
parser = argparse.ArgumentParser(description='cdist ' + VERSION)
|
||||||
c = Cdist(host)
|
parser.add_argument('host', nargs='+', help='one or more hosts to operate on')
|
||||||
c.deploy_to()
|
parser.add_argument('-d', '--debug', help='set log level to debug',
|
||||||
print(c.list_global_explorers())
|
action='store_true')
|
||||||
c.cleanup()
|
parser.add_argument('-i', '--initial-manifest',
|
||||||
|
help='path to a cdist manifest or - to read from stdin',
|
||||||
|
dest='manifest', required=True)
|
||||||
|
parser.add_argument('-p', '--parallel',
|
||||||
|
help='operate on multiple hosts in parallel',
|
||||||
|
action='store_true', dest='parallel')
|
||||||
|
parser.add_argument('-s', '--sequential',
|
||||||
|
help='operate on multiple hosts sequentially',
|
||||||
|
action='store_false', dest='parallel')
|
||||||
|
|
||||||
|
args = parser.parse_args(sys.argv[1:])
|
||||||
|
if args.debug:
|
||||||
|
logging.root.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print(args)
|
||||||
|
import cdist
|
||||||
|
sys.exit(cdist.main(args))
|
||||||
|
|
||||||
|
for host in sys.argv[1:]:
|
||||||
#!/usr/bin/env python3
|
c = Cdist(host)
|
||||||
# -*- coding: utf-8 -*-
|
c.deploy_to()
|
||||||
|
print(c.list_global_explorers())
|
||||||
import logging
|
c.cleanup()
|
||||||
# TODO: configure logging based on config and/or user given arguments
|
except KeyboardInterrupt:
|
||||||
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
|
sys.exit(0)
|
||||||
log = logging.getLogger()
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
parser = argparse.ArgumentParser(description='Some helpfull blabla')
|
|
||||||
parser.add_argument('host', nargs='+', help='one or more hosts to operate on')
|
|
||||||
parser.add_argument('-i', '--initial-manifest',
|
|
||||||
help='path to a cdist manifest or - to read from stdin',
|
|
||||||
dest='manifest', required=True)
|
|
||||||
parser.add_argument('-p', '--parallel',
|
|
||||||
help='operate on multiple hosts in parallel',
|
|
||||||
action='store_true', dest='parallel')
|
|
||||||
parser.add_argument('-s', '--sequential',
|
|
||||||
help='operate on multiple hosts sequentially',
|
|
||||||
action='store_false', dest='parallel')
|
|
||||||
parser.add_argument('-d', '--debug', help='set log level to debug',
|
|
||||||
action='store_true')
|
|
||||||
|
|
||||||
args = parser.parse_args(sys.argv[1:])
|
|
||||||
if args.debug:
|
|
||||||
logging.root.setLevel(logging.DEBUG)
|
|
||||||
log.debug('Look ma, now whe\'re showing debug messages')
|
|
||||||
|
|
||||||
try:
|
|
||||||
print(args)
|
|
||||||
#import cdist
|
|
||||||
#sys.exit(cdist.main(args))
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
Loading…
Reference in a new issue