From 6482863c5d1bc7c75e6b0babe05524ff9bd6cbf0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 6 Nov 2012 22:32:18 +0100 Subject: [PATCH] allow manifest to return env for usage from external Signed-off-by: Nico Schottelius --- cdist/core/manifest.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 61d92992..324374c3 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -78,29 +78,37 @@ class Manifest(object): self.env.update({'__cdist_debug': "yes" }) - def run_initial_manifest(self, script): + def env_initial_manifest(self, script): env = os.environ.copy() env.update(self.env) env['__manifest'] = self.local.manifest_path env['__cdist_manifest'] = script + + return env + + def run_initial_manifest(self, script): self.log.info("Running initial manifest " + self.local.manifest_path) if not os.path.isfile(self.local.manifest_path): raise cdist.Error("Initial manifest is missing") - self.local.run_script(script, env=env) + self.local.run_script(script, env=self.env_initial_manifest(script)) + + def env_type_manifest(self, cdist_object): + env = os.environ.copy() + env.update(self.env) + env.update({ + '__manifest': self.local.manifest_path, + '__object': cdist_object.absolute_path, + '__object_id': cdist_object.object_id, + '__object_name': cdist_object.name, + '__type': cdist_object.cdist_type.absolute_path, + '__cdist_manifest': script, + }) + + return env def run_type_manifest(self, cdist_object): script = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path) if os.path.isfile(script): - env = os.environ.copy() - env.update(self.env) - env.update({ - '__manifest': self.local.manifest_path, - '__object': cdist_object.absolute_path, - '__object_id': cdist_object.object_id, - '__object_name': cdist_object.name, - '__type': cdist_object.cdist_type.absolute_path, - '__cdist_manifest': script, - }) - self.local.run_script(script, env=env) + self.local.run_script(script, env=self.env_type_manifest(cdist_object))