From c24b20de0871eab0b6e2334a2479898db4dbef2d Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 14 Oct 2011 16:42:14 +0200 Subject: [PATCH 1/4] make nico happy Signed-off-by: Steven Armstrong --- lib/cdist/context.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/cdist/context.py b/lib/cdist/context.py index ed1fd31d..cf314409 100644 --- a/lib/cdist/context.py +++ b/lib/cdist/context.py @@ -41,8 +41,6 @@ class Context(object): debug=False): self.debug = debug - if self.debug: - os.environ['__debug'] = 'yes' self.target_host = target_host From c38959699f5cbd23809e6e6516a8eac3d4982cfc Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 14 Oct 2011 23:42:16 +0200 Subject: [PATCH 2/4] test for: transfer_type_explorers_only_once Signed-off-by: Steven Armstrong --- lib/cdist/test/explorer/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/cdist/test/explorer/__init__.py b/lib/cdist/test/explorer/__init__.py index a3a0c9f8..e6858812 100644 --- a/lib/cdist/test/explorer/__init__.py +++ b/lib/cdist/test/explorer/__init__.py @@ -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') From 814b46f0c7f5a26a200b8fe01a8a292b127da02c Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 14 Oct 2011 23:44:27 +0200 Subject: [PATCH 3/4] /transfered_explorers/explorers_transferred/ Signed-off-by: Steven Armstrong --- lib/cdist/core/type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/core/type.py b/lib/cdist/core/type.py index 8cf21ce7..6c3cd757 100644 --- a/lib/cdist/core/type.py +++ b/lib/cdist/core/type.py @@ -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 From 325a13088cfc80765644e30eebbe77b8087aacdc Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 14 Oct 2011 23:47:05 +0200 Subject: [PATCH 4/4] implement that type explorers are only transfered once Signed-off-by: Steven Armstrong --- lib/cdist/core/explorer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cdist/core/explorer.py b/lib/cdist/core/explorer.py index 9dd5d210..7a868b31 100644 --- a/lib/cdist/core/explorer.py +++ b/lib/cdist/core/explorer.py @@ -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: - 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) + 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."""