add helper methods to get paths from code/gencode

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
remotes/origin/feature_files_export
Nico Schottelius 13 years ago
parent 74c280911b
commit 4a5100692a
  1. 40
      bin/cdist

@ -266,6 +266,11 @@ class Cdist:
"""Returns the remote dir to the object parameter""" """Returns the remote dir to the object parameter"""
return os.path.join(self.remote_object_dir(cdist_object), "parameter") return os.path.join(self.remote_object_dir(cdist_object), "parameter")
def object_code_paths(self, cdist_object):
"""Return paths to code scripts of object"""
return [os.path.join(object_dir(cdist_object), "code-local"),
os.path.join(object_dir(cdist_object), "code-remote")]
def list_objects(self, starting_point = False): def list_objects(self, starting_point = False):
"""Return list of existing objects""" """Return list of existing objects"""
@ -285,6 +290,11 @@ class Cdist:
"""Return directory that holds the explorers of a type""" """Return directory that holds the explorers of a type"""
return os.path.join(TYPE_DIR, type, "explorer") return os.path.join(TYPE_DIR, type, "explorer")
def type_gencode_paths(self, type):
"""Return paths to gencode scripts of type"""
return [os.path.join(TYPE_DIR, type, "gencode-local"),
os.path.join(TYPE_DIR, type, "gencode-remote")]
def type_manifest_path(self, type): def type_manifest_path(self, type):
"""Return path to manifest of type""" """Return path to manifest of type"""
return os.path.join(TYPE_DIR, type, "manifest") return os.path.join(TYPE_DIR, type, "manifest")
@ -390,7 +400,6 @@ class Cdist:
def run_initial_manifest(self): def run_initial_manifest(self):
"""Run the initial manifest""" """Run the initial manifest"""
# FIXME: add support for __manifest::
env = { "__manifest" : MANIFEST_DIR } env = { "__manifest" : MANIFEST_DIR }
self.run_manifest(self.initial_manifest, extra_env=env) self.run_manifest(self.initial_manifest, extra_env=env)
@ -446,6 +455,26 @@ class Cdist:
self.shell_run_or_debug_fail(manifest, [manifest], env=env) self.shell_run_or_debug_fail(manifest, [manifest], env=env)
def object_run(self, cdist_object, mode):
"""Run gencode or code for an object"""
# FIXME: Check requirements and execute those before
requirements = list_object_requirements(cdist_object)
for requirement in requirements:
object_run(requirement, mode=mode)
# Find and run all available gencode scripts
if mode == "gencode":
base_path = object_dir
if mode == "code":
# FIXME: to be implemented
# cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object_self"
# cdist-object-code-run "$__cdist_target_host" "$__cdist_object_self"
self.run_type_explorer(cdist_object)
self.run_type_manifest(cdist_object)
def deploy_to(self): def deploy_to(self):
"""Mimic the old deploy to: Deploy to one host""" """Mimic the old deploy to: Deploy to one host"""
@ -470,14 +499,9 @@ class Cdist:
# Now do the final steps over the existing objects # Now do the final steps over the existing objects
for cdist_object in objects: for cdist_object in objects:
# FIXME: Check requirements and execute those before object_run(cdist_object, mode="gencode")
object_run(cdist_object, mode="code")
# FIXME: to be implemented
# cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object_self"
# cdist-object-code-run "$__cdist_target_host" "$__cdist_object_self"
self.run_type_explorer(cdist_object)
self.run_type_manifest(cdist_object)

Loading…
Cancel
Save