begin to migrate to '--output-base-path', shrink context
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
b9a6cf7c6a
commit
eaf1721212
4 changed files with 22 additions and 28 deletions
|
@ -41,7 +41,7 @@ class ConfigInstall(object):
|
|||
|
||||
self.local = local
|
||||
self.remote = remote
|
||||
self.log = logging.getLogger(self.context.target_host)
|
||||
self.log = logging.getLogger(self.local.target_host)
|
||||
self.dry_run = dry_run
|
||||
|
||||
self.explorer = core.Explorer(self.target_host, self.local, self.remote)
|
||||
|
@ -113,26 +113,20 @@ class ConfigInstall(object):
|
|||
"""Configure or install ONE system"""
|
||||
|
||||
try:
|
||||
|
||||
local = cdist.local.Local(
|
||||
target_host=host,
|
||||
out_path=FIXME-OUT_PATH,
|
||||
exec_path=sys.argv[0],
|
||||
add_conf_dirs=args.conf_dir,
|
||||
cache_dir=args.cache_dir)
|
||||
initial_manifest=args.manifest,
|
||||
out_base_path=args.out_base_path,
|
||||
add_conf_dirs=args.conf_dir)
|
||||
|
||||
remote = cdist.remote.Remote(
|
||||
target_host=host,
|
||||
remote_exec=args.remote_exec,
|
||||
remote_copy=args.remote_copy)
|
||||
|
||||
|
||||
#initial_manifest=args.manifest,
|
||||
#debug=args.debug)
|
||||
|
||||
c = cls(local, remote)
|
||||
c.run()
|
||||
context.cleanup()
|
||||
|
||||
except cdist.Error as e:
|
||||
context.log.error(e)
|
||||
|
@ -156,8 +150,8 @@ class ConfigInstall(object):
|
|||
|
||||
self._init_files_dirs()
|
||||
|
||||
self.explorer.run_global_explorers(self.context.local.global_explorer_out_path)
|
||||
self.manifest.run_initial_manifest(self.context.initial_manifest)
|
||||
self.explorer.run_global_explorers(self.local.global_explorer_out_path)
|
||||
self.manifest.run_initial_manifest(self.local.initial_manifest)
|
||||
self.iterate_until_finished()
|
||||
|
||||
self.local.save_cache()
|
||||
|
@ -166,8 +160,8 @@ class ConfigInstall(object):
|
|||
|
||||
def object_list(self):
|
||||
"""Short name for object list retrieval"""
|
||||
for cdist_object in core.CdistObject.list_objects(self.context.local.object_path,
|
||||
self.context.local.type_path):
|
||||
for cdist_object in core.CdistObject.list_objects(self.local.object_path,
|
||||
self.local.type_path):
|
||||
yield cdist_object
|
||||
|
||||
def iterate_once(self):
|
||||
|
|
|
@ -27,22 +27,12 @@ import sys
|
|||
class Context(object):
|
||||
"""Hold information about current context"""
|
||||
|
||||
def __init__(self,
|
||||
target_host,
|
||||
remote_copy,
|
||||
remote_exec,
|
||||
initial_manifest=False,
|
||||
add_conf_dirs=None,
|
||||
exec_path=sys.argv[0],
|
||||
debug=False,
|
||||
cache_dir=None):
|
||||
def __init__(self, target_host)
|
||||
|
||||
# Context logging
|
||||
self.log = logging.getLogger(self.target_host)
|
||||
self.log.addFilter(self)
|
||||
|
||||
self.initial_manifest = (initial_manifest or
|
||||
os.path.join(self.local.manifest_path, "init"))
|
||||
|
||||
def filter(self, record):
|
||||
"""Add hostname to logs via logging Filter"""
|
||||
|
|
|
@ -38,11 +38,17 @@ class Local(object):
|
|||
Directly accessing the local side from python code is a bug.
|
||||
|
||||
"""
|
||||
def __init__(self, target_host, exec_path, out_base_path=None, add_conf_dirs=None, cache_dir=None):
|
||||
def __init__(self,
|
||||
target_host,
|
||||
exec_path,
|
||||
initial_manifest=None,
|
||||
out_base_path=None,
|
||||
add_conf_dirs=None)
|
||||
|
||||
self.target_host = target_host
|
||||
self.out_base_path = out_base_path
|
||||
self.exec_path = exec_path
|
||||
self.custom_initial_manifest = initial_manifest
|
||||
|
||||
self._add_conf_dirs = add_conf_dirs
|
||||
|
||||
|
@ -52,6 +58,7 @@ class Local(object):
|
|||
self._init_cache_dir(cache_dir)
|
||||
self._init_conf_dirs()
|
||||
|
||||
|
||||
@property
|
||||
def dist_conf_dir(self):
|
||||
return os.path.abspath(os.path.join(os.path.dirname(cdist.__file__), "conf"))
|
||||
|
@ -86,6 +93,9 @@ class Local(object):
|
|||
# Depending on conf_path
|
||||
self.global_explorer_path = os.path.join(self.conf_path, "explorer")
|
||||
self.manifest_path = os.path.join(self.conf_path, "manifest")
|
||||
self.initial_manifest = (self.custom_initial_manifest or
|
||||
os.path.join(self.manifest_path, "init"))
|
||||
|
||||
self.type_path = os.path.join(self.conf_path, "type")
|
||||
|
||||
def _init_conf_dirs(self):
|
||||
|
|
|
@ -60,13 +60,13 @@ def commandline():
|
|||
parser['configinstall'].add_argument('-c', '--conf-dir',
|
||||
help='Add configuration directory (can be repeated, last one wins)',
|
||||
action='append')
|
||||
parser['configinstall'].add_argument('-C', '--cache-dir',
|
||||
help='Directory to save cache in (usually derived from target host name)')
|
||||
parser['configinstall'].add_argument('-i', '--initial-manifest',
|
||||
help='Path to a cdist manifest or \'-\' to read from stdin.',
|
||||
dest='manifest', required=False)
|
||||
parser['configinstall'].add_argument('-n', '--dry-run',
|
||||
help='Do not execute code', action='store_true')
|
||||
parser['configinstall'].add_argument('-o', '--output-base-path',
|
||||
help='Directory prefix to save cdist output in')
|
||||
parser['configinstall'].add_argument('-p', '--parallel',
|
||||
help='Operate on multiple hosts in parallel',
|
||||
action='store_true', dest='parallel')
|
||||
|
|
Loading…
Reference in a new issue