allow manifest to return env for usage from external

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-11-06 22:32:18 +01:00
parent 28bf0c3ed8
commit 6482863c5d

View file

@ -78,21 +78,23 @@ 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 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):
def env_type_manifest(self, cdist_object):
env = os.environ.copy()
env.update(self.env)
env.update({
@ -103,4 +105,10 @@ class Manifest(object):
'__type': cdist_object.cdist_type.absolute_path,
'__cdist_manifest': script,
})
self.local.run_script(script, env=env)
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):
self.local.run_script(script, env=self.env_type_manifest(cdist_object))