finish merge of context and config_install
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
1015810391
commit
35bfa2fcdc
1 changed files with 11 additions and 4 deletions
|
@ -23,6 +23,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
@ -46,8 +47,6 @@ class ConfigInstall:
|
||||||
debug=False):
|
debug=False):
|
||||||
|
|
||||||
self.target_host = target_host
|
self.target_host = target_host
|
||||||
# FIXME: should this be setup here?
|
|
||||||
os.environ['__target_host'] = self.target_host
|
|
||||||
|
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
|
||||||
|
@ -92,12 +91,16 @@ class ConfigInstall:
|
||||||
self.remote_base_path = os.environ['__cdist_remote_out_dir']
|
self.remote_base_path = os.environ['__cdist_remote_out_dir']
|
||||||
else:
|
else:
|
||||||
self.remote_base_path = "/var/lib/cdist"
|
self.remote_base_path = "/var/lib/cdist"
|
||||||
|
|
||||||
self.remote_conf_path = os.path.join(self.remote_base_path, "conf")
|
self.remote_conf_path = os.path.join(self.remote_base_path, "conf")
|
||||||
self.remote_object_path = os.path.join(self.remote_base_path, "object")
|
self.remote_object_path = os.path.join(self.remote_base_path, "object")
|
||||||
|
|
||||||
self.remote_type_path = os.path.join(self.remote_conf_path, "type")
|
self.remote_type_path = os.path.join(self.remote_conf_path, "type")
|
||||||
self.remote_global_explorer_path = os.path.join(self.remote_conf_path, "explorer")
|
self.remote_global_explorer_path = os.path.join(self.remote_conf_path, "explorer")
|
||||||
|
|
||||||
|
# Setup env to be used by others
|
||||||
|
self.__init_env()
|
||||||
|
|
||||||
# Create directories
|
# Create directories
|
||||||
self.__init_local_paths()
|
self.__init_local_paths()
|
||||||
self.__init_remote_paths()
|
self.__init_remote_paths()
|
||||||
|
@ -120,6 +123,10 @@ class ConfigInstall:
|
||||||
os.mkdir(self.global_explorer_out_path)
|
os.mkdir(self.global_explorer_out_path)
|
||||||
os.mkdir(self.bin_path)
|
os.mkdir(self.bin_path)
|
||||||
|
|
||||||
|
def __init_env(self):
|
||||||
|
"""Environment usable for other stuff"""
|
||||||
|
os.environ['__target_host'] = self.target_host
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# Do not use in __del__:
|
# Do not use in __del__:
|
||||||
# http://docs.python.org/reference/datamodel.html#customization
|
# http://docs.python.org/reference/datamodel.html#customization
|
||||||
|
@ -274,7 +281,7 @@ class ConfigInstall:
|
||||||
self.transfer_object_parameter(cdist_object)
|
self.transfer_object_parameter(cdist_object)
|
||||||
|
|
||||||
for explorer in cdist_type.explorers:
|
for explorer in cdist_type.explorers:
|
||||||
remote_cmd = cmd + [os.path.join(self.remote_base_path,
|
remote_cmd = cmd + [os.path.join(self.remote_type_path,
|
||||||
cdist_type.explorer_path, explorer)]
|
cdist_type.explorer_path, explorer)]
|
||||||
output = os.path.join(self.object_base_path,
|
output = os.path.join(self.object_base_path,
|
||||||
cdist_object.explorer_path, explorer)
|
cdist_object.explorer_path, explorer)
|
||||||
|
@ -385,6 +392,7 @@ class ConfigInstall:
|
||||||
log.debug("Skipping retransfer for explorers of %s", cdist_type)
|
log.debug("Skipping retransfer for explorers of %s", cdist_type)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
log.debug("Ensure no retransfer for %s", cdist_type)
|
||||||
# Do not retransfer
|
# Do not retransfer
|
||||||
cdist_type.transferred_explorers = True
|
cdist_type.transferred_explorers = True
|
||||||
|
|
||||||
|
@ -402,7 +410,6 @@ class ConfigInstall:
|
||||||
self.remote_mkdir(dst)
|
self.remote_mkdir(dst)
|
||||||
self.transfer_path(src, dst)
|
self.transfer_path(src, dst)
|
||||||
|
|
||||||
|
|
||||||
def remote_mkdir(self, directory):
|
def remote_mkdir(self, directory):
|
||||||
"""Create directory on remote side"""
|
"""Create directory on remote side"""
|
||||||
cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=True)
|
cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=True)
|
||||||
|
|
Loading…
Reference in a new issue