cleanup run_type_explorer()

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-07 12:43:17 +02:00
parent e301b74610
commit 480c1bbb35
2 changed files with 38 additions and 35 deletions

View file

@ -54,33 +54,6 @@ class ConfigInstall:
def cleanup(self): def cleanup(self):
self.path.cleanup() self.path.cleanup()
def run_type_explorer(self, cdist_object):
"""Run type specific explorers for objects"""
type = cdist_object.type
self.path.transfer_type_explorers(type)
cmd = []
cmd.append("__explorer=" + cdist.path.REMOTE_GLOBAL_EXPLORER_DIR)
cmd.append("__type_explorer=" + self.path.remote_type_explorer_dir(type))
cmd.append("__object=" + self.path.remote_object_dir(cdist_object))
cmd.append("__object_id=" + self.path.get_object_id_from_object(cdist_object))
cmd.append("__object_fq=" + cdist_object)
# Need to transfer at least the parameters for objects to be useful
self.path.transfer_object_parameter(cdist_object)
explorers = self.path.list_type_explorers(type)
for explorer in explorers:
remote_cmd = cmd + [os.path.join(self.path.remote_type_explorer_dir(type), explorer)]
output = os.path.join(self.path.type_explorer_output_dir(cdist_object), explorer)
output_fd = open(output, mode='w')
log.debug("%s exploring %s using %s storing to %s",
cdist_object, explorer, remote_cmd, output)
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True)
output_fd.close()
def run_initial_manifest(self): def run_initial_manifest(self):
@ -202,6 +175,35 @@ class ConfigInstall:
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True)
### Cleaned / check functions: Round 1 :-) ################################# ### Cleaned / check functions: Round 1 :-) #################################
def run_type_explorer(self, cdist_object):
"""Run type specific explorers for objects"""
type = cdist_object.type
# FIXME
self.path.transfer_type_explorers(type)
cmd = []
cmd.append("__explorer=" + self.context.remote_global_explorer_dir)
cmd.append("__type_explorer=" + type.explorer_remote_dir)
cmd.append("__object=" + object.path_remote)
cmd.append("__object_id=" + object.object_id)
cmd.append("__object_fq=" + cdist_object)
# Need to transfer at least the parameters for objects to be useful
self.path.transfer_object_parameter(cdist_object)
explorers = self.path.list_type_explorers(type)
for explorer in explorers:
remote_cmd = cmd + [os.path.join(type.explorer_remote_dir, explorer)]
output = os.path.join(cdist_object.explorer_output_dir(), explorer)
output_fd = open(output, mode='w')
log.debug("%s exploring %s using %s storing to %s",
cdist_object, explorer, remote_cmd, output)
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True)
output_fd.close()
def link_emulator(self): def link_emulator(self):
"""Link emulator to types""" """Link emulator to types"""
src = os.path.abspath(self.exec_path) src = os.path.abspath(self.exec_path)

View file

@ -30,8 +30,8 @@ log = logging.getLogger(__name__)
import cdist.exec import cdist.exec
class Path: class Context:
"""Class that handles path related configurations""" """Storing context dependent information"""
def __init__(self, target_host, initial_manifest=False, debug=False): def __init__(self, target_host, initial_manifest=False, debug=False):
@ -44,13 +44,14 @@ class Path:
self.base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) self.base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
# Input directories # Input directories
self.conf_dir = os.path.join(self.base_dir, "conf") self.cache_dir = os.path.join(self.base_dir, "cache", target_host)
self.cache_base_dir = os.path.join(self.base_dir, "cache")
self.cache_dir = os.path.join(self.cache_base_dir, target_host)
self.global_explorer_dir = os.path.join(self.conf_dir, "explorer")
self.lib_dir = os.path.join(self.base_dir, "lib")
self.manifest_dir = os.path.join(self.conf_dir, "manifest") self.manifest_dir = os.path.join(self.conf_dir, "manifest")
self.type_base_dir = os.path.join(self.conf_dir, "type")
# Probably unused paths
# self.conf_dir = os.path.join(self.base_dir, "conf")
# self.global_explorer_dir = os.path.join(self.conf_dir, "explorer")
# self.lib_dir = os.path.join(self.base_dir, "lib")
# self.type_base_dir = os.path.join(self.conf_dir, "type")
# Mostly static, but can be overwritten on user demand # Mostly static, but can be overwritten on user demand
if initial_manifest: if initial_manifest: