Merge remote-tracking branch 'telmich/master'

This commit is contained in:
Steven Armstrong 2011-10-07 16:43:07 +02:00
commit cde4d87ab7
3 changed files with 33 additions and 27 deletions

View file

@ -1,14 +1,6 @@
2.0.3:
- fix emulator
- introduce tests:
- does $require work?
- $whatever should fail if there is no global explorer directory
- emulator may only be called with __ as prefix - fail otherwise!
- Create GlobalExplorer
- base_dir passing in config/config_install superseeded by __cdist_base_dir?
--------------------------------------------------------------------------------

View file

@ -26,3 +26,7 @@ Tests needed:
- Fail if cache_dir cannot be created from current out_dir
- transfer_type_explorers: Explorers are not transferred twice
- transfer_type_explorers: No transfer tried if there are no type_explorers
- does $require work?
- $whatever should fail if there is no global explorer directory
- emulator may only be called with __ as prefix - fail otherwise!

View file

@ -174,18 +174,22 @@ class ConfigInstall:
def run_type_explorer(self, cdist_object):
"""Run type specific explorers for objects"""
type = cdist_object.type
self.transfer_type_explorers(type)
cdist_type = cdist_object.type
self.transfer_type_explorers(cdist_type)
cmd = []
cmd.append("__explorer=" + self.context.remote_global_explorer_path)
cmd.append("__type_explorer=" + type.explorer_remote_path)
cmd.append("__object=" + object.path_remote)
cmd.append("__object_id=" + object.object_id)
cmd.append("__object_fq=" + cdist_object)
cmd.append("__type_explorer=" + os.path.join(
self.context.remote_type_path,
cdist_type.explorer_path))
cmd.append("__object=" + os.path.join(
self.context.remote_object_path,
cdist_object.path))
cmd.append("__object_id=" + cdist_object.object_id)
cmd.append("__object_fq=" + cdist_object.name)
# Need to transfer at least the parameters for objects to be useful
self.path.transfer_object_parameter(cdist_object)
self.transfer_object_parameter(cdist_object)
explorers = self.path.list_type_explorers(type)
for explorer in explorers:
@ -232,7 +236,8 @@ class ConfigInstall:
def stage_run(self):
"""The final (and real) step of deployment"""
log.info("Generating and executing code")
for cdist_object in cdist.core.Object.list_objects(self.context.object_base_path):
for cdist_object in cdist.core.Object.list_objects(self.context.object_base_path,
self.context.type_base_path):
log.debug("Run object: %s", cdist_object)
self.object_run(cdist_object)
@ -259,7 +264,8 @@ class ConfigInstall:
new_objects_created = True
while new_objects_created:
new_objects_created = False
for cdist_object in cdist.core.Object.list_objects(self.context.object_base_path):
for cdist_object in cdist.core.Object.list_objects(self.context.object_base_path,
self.context.type_base_path):
if cdist_object.prepared:
log.debug("Skipping rerun of object %s", cdist_object)
continue
@ -278,7 +284,7 @@ class ConfigInstall:
cdist_object.parameter_path)
# Synchronise parameter dir afterwards
self.transfer_path(local_path, remote_path)
self.context.transfer_path(src, dst)
def transfer_global_explorers(self):
"""Transfer the global explorers"""
@ -286,22 +292,26 @@ class ConfigInstall:
self.transfer_path(self.context.global_explorer_path,
self.remote_global_explorer_path)
def transfer_type_explorers(self, type):
def transfer_type_explorers(self, cdist_type):
"""Transfer explorers of a type, but only once"""
if type.transferred_explorers:
log.debug("Skipping retransfer for explorers of %s", type)
if cdist_type.transferred_explorers:
log.debug("Skipping retransfer for explorers of %s", cdist_type)
return
else:
# Do not retransfer
type.transferred_explorers = True
cdist_type.transferred_explorers = True
explorers = type.explorers()
explorers = cdist_type.explorers
if len(explorers) > 0:
rel_path = os.path.join(type.explorer_path(), explorer)
rel_path = cdist_type.explorer_path
src = os.path.join(self.context.type_base_path, rel_path)
dst = os.path.join(self.context.remote_type_path, rel_path)
# Ensure that the path exists
self.remote_mkdir(dst)
self.transfer_path(src, dst)
# Ensure full path until type exists:
# /var/lib/cdist/conf/type/__directory/explorer
# /var/lib/cdist/conf/type/__directory may not exist,
# but remote_mkdir uses -p to fix this
self.context.remote_mkdir(dst)
self.context.transfer_path(src, dst)