delegate path handling to local and remote
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
80087d4f59
commit
fec3cca3b0
1 changed files with 12 additions and 38 deletions
|
@ -52,25 +52,13 @@ class Context(object):
|
||||||
self.log = logging.getLogger(self.target_host)
|
self.log = logging.getLogger(self.target_host)
|
||||||
self.log.addFilter(self)
|
self.log.addFilter(self)
|
||||||
|
|
||||||
# Base and Temp Base
|
# Local base directory
|
||||||
self.base_path = (base_path or
|
self.base_path = (base_path or
|
||||||
os.path.abspath(os.path.join(os.path.dirname(__file__),
|
os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
os.pardir, os.pardir)))
|
os.pardir, os.pardir)))
|
||||||
|
|
||||||
# Local input
|
# Local temp directory
|
||||||
self.cache_path = os.path.join(self.base_path, "cache",
|
# FIXME: if __cdist_out_dir can be given from the outside, the same directory will be used for all hosts
|
||||||
self.target_host)
|
|
||||||
self.conf_path = os.path.join(self.base_path, "conf")
|
|
||||||
|
|
||||||
self.global_explorer_path = os.path.join(self.conf_path, "explorer")
|
|
||||||
self.manifest_path = os.path.join(self.conf_path, "manifest")
|
|
||||||
self.type_base_path = os.path.join(self.conf_path, "type")
|
|
||||||
self.lib_path = os.path.join(self.base_path, "lib")
|
|
||||||
|
|
||||||
self.initial_manifest = (initial_manifest or
|
|
||||||
os.path.join(self.manifest_path, "init"))
|
|
||||||
|
|
||||||
# Local output
|
|
||||||
if '__cdist_out_dir' in os.environ:
|
if '__cdist_out_dir' in os.environ:
|
||||||
self.out_path = os.environ['__cdist_out_dir']
|
self.out_path = os.environ['__cdist_out_dir']
|
||||||
self.temp_dir = None
|
self.temp_dir = None
|
||||||
|
@ -78,31 +66,17 @@ class Context(object):
|
||||||
self.temp_dir = tempfile.mkdtemp()
|
self.temp_dir = tempfile.mkdtemp()
|
||||||
self.out_path = os.path.join(self.temp_dir, "out")
|
self.out_path = os.path.join(self.temp_dir, "out")
|
||||||
|
|
||||||
self.bin_path = os.path.join(self.out_path, "bin")
|
self.local = local.Local(self.target_host, self.base_path, self.out_path)
|
||||||
self.global_explorer_out_path = os.path.join(self.out_path, "explorer")
|
|
||||||
self.object_base_path = os.path.join(self.out_path, "object")
|
|
||||||
|
|
||||||
# Remote directory base
|
self.initial_manifest = (initial_manifest or
|
||||||
if '__cdist_remote_out_dir' in os.environ:
|
os.path.join(self.local.manifest_path, "init"))
|
||||||
self.remote_base_path = os.environ['__cdist_remote_out_dir']
|
|
||||||
else:
|
|
||||||
self.remote_base_path = "/var/lib/cdist"
|
|
||||||
|
|
||||||
self.remote_conf_path = os.path.join(self.remote_base_path, "conf")
|
# Remote
|
||||||
self.remote_object_path = os.path.join(self.remote_base_path, "object")
|
self.remote_base_path = os.environ.get('__cdist_remote_out_dir', "/var/lib/cdist")
|
||||||
|
self.remote_exec = os.environ.get('__remote_exec', "ssh -o User=root -q")
|
||||||
self.remote_type_path = os.path.join(self.remote_conf_path, "type")
|
self.remote_copy = os.environ.get('__remote_copy', "scp -o User=root -q")
|
||||||
self.remote_global_explorer_path = os.path.join(self.remote_conf_path, "explorer")
|
self.remote = remote.Remote(self.target_host, self.remote_base_path,
|
||||||
|
self.remote_exec, self.remote_copy)
|
||||||
if '__remote_exec' in os.environ:
|
|
||||||
self.remote_exec = os.environ['__remote_exec']
|
|
||||||
else:
|
|
||||||
self.remote_exec = "ssh -o User=root -q"
|
|
||||||
|
|
||||||
if '__remote_copy' in os.environ:
|
|
||||||
self.remote_copy = os.environ['__remote_copy']
|
|
||||||
else:
|
|
||||||
self.remote_copy = "scp -o User=root -q"
|
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Remove temp stuff"""
|
"""Remove temp stuff"""
|
||||||
|
|
Loading…
Reference in a new issue