Merge remote-tracking branch 'steven/master'

This commit is contained in:
Nico Schottelius 2011-10-14 23:52:00 +02:00
commit 72e930ac1c
4 changed files with 23 additions and 7 deletions

View file

@ -41,8 +41,6 @@ class Context(object):
debug=False):
self.debug = debug
if self.debug:
os.environ['__debug'] = 'yes'
self.target_host = target_host

View file

@ -105,10 +105,14 @@ class Explorer(object):
def transfer_type_explorers(self, cdist_type):
"""Transfer the type explorers for the given type to the remote side."""
if cdist_type.explorers:
if cdist_type.explorers_transferred:
log.debug("Skipping retransfer of type explorers for: %s", cdist_type)
else:
source = os.path.join(self.local.type_path, cdist_type.explorer_path)
destination = os.path.join(self.remote.type_path, cdist_type.explorer_path)
self.remote.mkdir(destination)
self.remote.transfer(source, destination)
cdist_type.explorers_transferred = True
def transfer_object_parameters(self, cdist_object):
"""Transfer the parameters for the given object to the remote side."""

View file

@ -67,7 +67,7 @@ class Type(object):
self.gencode_remote_path = os.path.join(self.name, "gencode-remote")
self.manifest_path = os.path.join(self.name, "manifest")
self.transferred_explorers = False
self.explorers_transferred = False
self.__explorers = None
self.__required_parameters = None

View file

@ -95,6 +95,20 @@ class ExplorerClassTestCase(unittest.TestCase):
destination = os.path.join(self.remote.type_path, cdist_type.explorer_path)
self.assertEqual(os.listdir(source), os.listdir(destination))
def test_transfer_type_explorers_only_once(self):
cdist_type = core.Type(self.local.type_path, '__test_type')
# first transfer
self.explorer.transfer_type_explorers(cdist_type)
source = os.path.join(self.local.type_path, cdist_type.explorer_path)
destination = os.path.join(self.remote.type_path, cdist_type.explorer_path)
self.assertEqual(os.listdir(source), os.listdir(destination))
# nuke destination folder content, but recreate directory
shutil.rmtree(destination)
os.makedirs(destination)
# second transfer, should not happen
self.explorer.transfer_type_explorers(cdist_type)
self.assertFalse(os.listdir(destination))
def test_transfer_object_parameters(self):
cdist_type = core.Type(self.local.type_path, '__test_type')
cdist_object = core.Object(cdist_type, self.local.object_path, 'whatever')