|
|
|
@ -273,15 +273,15 @@ class Config:
|
|
|
|
|
host_tags = None |
|
|
|
|
host_base_path, hostdir = cls.create_host_base_dirs( |
|
|
|
|
host, base_root_path) |
|
|
|
|
log.debug("Base root path for target host \"{}\" is \"{}\"".format( |
|
|
|
|
host, host_base_path)) |
|
|
|
|
log.debug("Base root path for target host \"%s\" is \"%s\"", |
|
|
|
|
host, host_base_path) |
|
|
|
|
|
|
|
|
|
hostcnt += 1 |
|
|
|
|
if args.parallel: |
|
|
|
|
pargs = (host, host_tags, host_base_path, hostdir, args, True, |
|
|
|
|
configuration) |
|
|
|
|
log.trace(("Args for multiprocessing operation " |
|
|
|
|
"for host {}: {}".format(host, pargs))) |
|
|
|
|
log.trace("Args for multiprocessing operation for host %s: %s", |
|
|
|
|
host, pargs) |
|
|
|
|
process_args.append(pargs) |
|
|
|
|
else: |
|
|
|
|
try: |
|
|
|
@ -298,10 +298,10 @@ class Config:
|
|
|
|
|
except cdist.Error: |
|
|
|
|
failed_hosts.append(host) |
|
|
|
|
elif args.parallel: |
|
|
|
|
log.trace("Multiprocessing start method is {}".format( |
|
|
|
|
multiprocessing.get_start_method())) |
|
|
|
|
log.trace(("Starting multiprocessing Pool for {} " |
|
|
|
|
"parallel host operation".format(args.parallel))) |
|
|
|
|
log.trace("Multiprocessing start method is %s", |
|
|
|
|
multiprocessing.get_start_method()) |
|
|
|
|
log.trace("Starting multiprocessing Pool for %d parallel host" |
|
|
|
|
" operation", args.parallel) |
|
|
|
|
|
|
|
|
|
results = mp_pool_run(cls.onehost, |
|
|
|
|
process_args, |
|
|
|
@ -396,16 +396,13 @@ class Config:
|
|
|
|
|
|
|
|
|
|
remote_exec, remote_copy, cleanup_cmd = cls._resolve_remote_cmds( |
|
|
|
|
args) |
|
|
|
|
log.debug("remote_exec for host \"{}\": {}".format( |
|
|
|
|
host, remote_exec)) |
|
|
|
|
log.debug("remote_copy for host \"{}\": {}".format( |
|
|
|
|
host, remote_copy)) |
|
|
|
|
log.debug("remote_exec for host \"%s\": %s", host, remote_exec) |
|
|
|
|
log.debug("remote_copy for host \"%s\": %s", host, remote_copy) |
|
|
|
|
|
|
|
|
|
family = cls._address_family(args) |
|
|
|
|
log.debug("address family: {}".format(family)) |
|
|
|
|
log.debug("address family: %s", family) |
|
|
|
|
target_host = cls.resolve_target_addresses(host, family) |
|
|
|
|
log.debug("target_host for host \"{}\": {}".format( |
|
|
|
|
host, target_host)) |
|
|
|
|
log.debug("target_host for host \"%s\": %s", host, target_host) |
|
|
|
|
|
|
|
|
|
local = cdist.exec.local.Local( |
|
|
|
|
target_host=target_host, |
|
|
|
@ -474,8 +471,8 @@ class Config:
|
|
|
|
|
"""Do what is most often done: deploy & cleanup""" |
|
|
|
|
start_time = time.time() |
|
|
|
|
|
|
|
|
|
self.log.info("Starting {} run".format( |
|
|
|
|
'dry' if self.dry_run else 'configuration')) |
|
|
|
|
self.log.info("Starting %s run", |
|
|
|
|
'dry' if self.dry_run else 'configuration') |
|
|
|
|
|
|
|
|
|
self._init_files_dirs() |
|
|
|
|
|
|
|
|
@ -493,9 +490,9 @@ class Config:
|
|
|
|
|
self._remove_files_dirs() |
|
|
|
|
|
|
|
|
|
self.local.save_cache(start_time) |
|
|
|
|
self.log.info("Finished {} run in {:.2f} seconds".format( |
|
|
|
|
self.log.info("Finished %s run in %.2f seconds", |
|
|
|
|
'dry' if self.dry_run else 'successful', |
|
|
|
|
time.time() - start_time)) |
|
|
|
|
time.time() - start_time) |
|
|
|
|
|
|
|
|
|
def cleanup(self): |
|
|
|
|
self.log.debug("Running cleanup commands") |
|
|
|
@ -519,8 +516,8 @@ class Config:
|
|
|
|
|
self.local.object_path, self.local.type_path, |
|
|
|
|
self.local.object_marker_name): |
|
|
|
|
if cdist_object.cdist_type.is_install: |
|
|
|
|
self.log.debug(("Running in config mode, ignoring install " |
|
|
|
|
"object: {0}").format(cdist_object)) |
|
|
|
|
self.log.debug("Running in config mode, ignoring install " |
|
|
|
|
"object: %s", cdist_object) |
|
|
|
|
else: |
|
|
|
|
yield cdist_object |
|
|
|
|
|
|
|
|
@ -565,8 +562,7 @@ class Config:
|
|
|
|
|
return objects_changed |
|
|
|
|
|
|
|
|
|
def _iterate_once_parallel(self): |
|
|
|
|
self.log.debug("Iteration in parallel mode in {} jobs".format( |
|
|
|
|
self.jobs)) |
|
|
|
|
self.log.debug("Iteration in parallel mode in %d jobs", self.jobs) |
|
|
|
|
objects_changed = False |
|
|
|
|
|
|
|
|
|
cargo = [] |
|
|
|
@ -588,8 +584,8 @@ class Config:
|
|
|
|
|
self.object_prepare(cargo[0]) |
|
|
|
|
objects_changed = True |
|
|
|
|
elif cargo: |
|
|
|
|
self.log.trace("Multiprocessing start method is {}".format( |
|
|
|
|
multiprocessing.get_start_method())) |
|
|
|
|
self.log.trace("Multiprocessing start method is %s", |
|
|
|
|
multiprocessing.get_start_method()) |
|
|
|
|
|
|
|
|
|
self.log.trace("Multiprocessing cargo: %s", cargo) |
|
|
|
|
|
|
|
|
@ -603,9 +599,8 @@ class Config:
|
|
|
|
|
"sequentially")) |
|
|
|
|
self.explorer.transfer_type_explorers(cargo_types.pop()) |
|
|
|
|
else: |
|
|
|
|
self.log.trace(("Starting multiprocessing Pool for {} " |
|
|
|
|
"parallel types explorers transferring".format( |
|
|
|
|
nt))) |
|
|
|
|
self.log.trace("Starting multiprocessing Pool for %d " |
|
|
|
|
"parallel types explorers transferring", nt) |
|
|
|
|
args = [ |
|
|
|
|
(ct, ) for ct in cargo_types |
|
|
|
|
] |
|
|
|
@ -614,8 +609,8 @@ class Config:
|
|
|
|
|
self.log.trace(("Multiprocessing for parallel transferring " |
|
|
|
|
"types' explorers finished")) |
|
|
|
|
|
|
|
|
|
self.log.trace(("Starting multiprocessing Pool for {} parallel " |
|
|
|
|
"objects preparation".format(n))) |
|
|
|
|
self.log.trace("Starting multiprocessing Pool for %d parallel " |
|
|
|
|
"objects preparation", n) |
|
|
|
|
args = [ |
|
|
|
|
(c, False, ) for c in cargo |
|
|
|
|
] |
|
|
|
@ -667,10 +662,10 @@ class Config:
|
|
|
|
|
self.object_run(chunk[0]) |
|
|
|
|
objects_changed = True |
|
|
|
|
elif chunk: |
|
|
|
|
self.log.trace("Multiprocessing start method is {}".format( |
|
|
|
|
multiprocessing.get_start_method())) |
|
|
|
|
self.log.trace(("Starting multiprocessing Pool for {} " |
|
|
|
|
"parallel object run".format(n))) |
|
|
|
|
self.log.trace("Multiprocessing start method is %s", |
|
|
|
|
multiprocessing.get_start_method()) |
|
|
|
|
self.log.trace("Starting multiprocessing Pool for %d " |
|
|
|
|
"parallel object run", n) |
|
|
|
|
args = [ |
|
|
|
|
(c, ) for c in chunk |
|
|
|
|
] |
|
|
|
@ -794,9 +789,9 @@ class Config:
|
|
|
|
|
def object_prepare(self, cdist_object, transfer_type_explorers=True): |
|
|
|
|
"""Prepare object: Run type explorer + manifest""" |
|
|
|
|
self._handle_deprecation(cdist_object) |
|
|
|
|
self.log.verbose("Preparing object {}".format(cdist_object.name)) |
|
|
|
|
self.log.verbose( |
|
|
|
|
"Running manifest and explorers for " + cdist_object.name) |
|
|
|
|
self.log.verbose("Preparing object %s", cdist_object.name) |
|
|
|
|
self.log.verbose("Running manifest and explorers for %s", |
|
|
|
|
cdist_object.name) |
|
|
|
|
self.explorer.run_type_explorers(cdist_object, transfer_type_explorers) |
|
|
|
|
try: |
|
|
|
|
self.manifest.run_type_manifest(cdist_object) |
|
|
|
@ -810,13 +805,13 @@ class Config:
|
|
|
|
|
def object_run(self, cdist_object): |
|
|
|
|
"""Run gencode and code for an object""" |
|
|
|
|
try: |
|
|
|
|
self.log.verbose("Running object " + cdist_object.name) |
|
|
|
|
self.log.verbose("Running object %s", cdist_object.name) |
|
|
|
|
if cdist_object.state == core.CdistObject.STATE_DONE: |
|
|
|
|
raise cdist.Error(("Attempting to run an already finished " |
|
|
|
|
"object: %s"), cdist_object) |
|
|
|
|
"object: {}").format(cdist_object)) |
|
|
|
|
|
|
|
|
|
# Generate |
|
|
|
|
self.log.debug("Generating code for %s" % (cdist_object.name)) |
|
|
|
|
self.log.debug("Generating code for %s", cdist_object.name) |
|
|
|
|
cdist_object.code_local = self.code.run_gencode_local(cdist_object) |
|
|
|
|
cdist_object.code_remote = self.code.run_gencode_remote( |
|
|
|
|
cdist_object) |
|
|
|
@ -825,20 +820,20 @@ class Config:
|
|
|
|
|
|
|
|
|
|
# Execute |
|
|
|
|
if cdist_object.code_local or cdist_object.code_remote: |
|
|
|
|
self.log.info("Processing %s" % (cdist_object.name)) |
|
|
|
|
self.log.info("Processing %s", cdist_object.name) |
|
|
|
|
if not self.dry_run: |
|
|
|
|
if cdist_object.code_local: |
|
|
|
|
self.log.trace("Executing local code for %s" |
|
|
|
|
% (cdist_object.name)) |
|
|
|
|
self.log.trace("Executing local code for %s", |
|
|
|
|
cdist_object.name) |
|
|
|
|
self.code.run_code_local(cdist_object) |
|
|
|
|
if cdist_object.code_remote: |
|
|
|
|
self.log.trace("Executing remote code for %s" |
|
|
|
|
% (cdist_object.name)) |
|
|
|
|
self.log.trace("Executing remote code for %s", |
|
|
|
|
cdist_object.name) |
|
|
|
|
self.code.transfer_code_remote(cdist_object) |
|
|
|
|
self.code.run_code_remote(cdist_object) |
|
|
|
|
|
|
|
|
|
# Mark this object as done |
|
|
|
|
self.log.trace("Finishing run of " + cdist_object.name) |
|
|
|
|
self.log.trace("Finishing run of %s", cdist_object.name) |
|
|
|
|
cdist_object.state = core.CdistObject.STATE_DONE |
|
|
|
|
except cdist.Error as e: |
|
|
|
|
raise cdist.CdistObjectError(cdist_object, e) |
|
|
|
|