Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-07 16:00:32 +02:00
parent c1e7731992
commit e5e2fb866c
3 changed files with 15 additions and 21 deletions

View file

@ -42,7 +42,7 @@ def config(args):
os.environ['__remote_copy'] = "scp -o User=root -q"
for host in args.host:
c = Config(host, initial_manifest=args.manifest, base_dir=args.cdist_home, debug=args.debug)
c = Config(host, initial_manifest=args.manifest, base_path=args.cdist_home, debug=args.debug)
if args.parallel:
log.debug("Creating child process for %s", host)
process[host] = multiprocessing.Process(target=c.deploy_and_cleanup)

View file

@ -70,7 +70,7 @@ class ConfigInstall:
log.debug("%s: Running %s", cdist_object.name, manifest)
if os.path.exists(manifest_path):
env = { "__object" : os.path.join(self.context.object_base_path,
cdist_object.path)
cdist_object.path),
"__object_id": cdist_object.object_id,
"__object_fq": cdist_object.name,
"__type": os.path.join(self.context.type_base_path,
@ -213,16 +213,17 @@ class ConfigInstall:
"""Run global explorers"""
log.info("Running global explorers")
src = cdist.core.GlobalExplorer.base_path
dst = cdist.core.GlobalExplorer.remote_base_path
src_path = cdist.context.global_explorer_path
dst_path = cdist.context.global_explorer_out_path
remote_dst_path = cdist.context.remote_global_explorer_path
self.context.transfer_path(src, dst)
self.context.transfer_path(src_path, remote_dst_path)
for explorer in cdist.core.GlobalExplorer.list_explorers():
output_fd = open(explorer.out_path, mode='w')
for explorer in os.listdir(src_path):
output_fd = open(os.path.join(dst_path, explorer), mode='w')
cmd = []
cmd.append("__explorer=" + cdist.core.GlobalExplorer.remote_base_path)
cmd.append(explorer.remote_path)
cmd.append("__explorer=" + remote_dst_path)
cmd.append(os.path.join(src_path, explorer))
cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True)
output_fd.close()

View file

@ -47,11 +47,10 @@ class Context:
if base_path:
self.base_path = base_path
else:
self.base_path =
os.path.abspath(
os.path.join(os.path.dirname(__file__),
os.pardir,
os.pardir))
self.base_path = os.path.abspath(
os.path.join(os.path.dirname(__file__),
os.pardir,
os.pardir))
# Local input directories
@ -70,7 +69,7 @@ class Context:
# Local output directories
if out_path:
self.out_path = out_path:
self.out_path = out_path
else:
self.out_path = os.path.join(tempfile.mkdtemp(), "out")
@ -92,7 +91,6 @@ class Context:
# Create directories
self.__init_out_paths()
self.__init_remote_paths()
self.__init_env()
def cleanup(self):
# Do not use in __del__:
@ -106,11 +104,6 @@ class Context:
shutil.rmtree(self.cache_path)
shutil.move(self.base_path, self.cache_path)
#def __init_env(self):
# """Setup environment"""
# os.environ['__cdist_out_path'] = self.out_path
# os.environ['__cdist_base_path'] = self.base_path
def __init_out_paths(self):
"""Initialise output directory structure"""