cleanup object_run() finally
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
484b947eca
commit
f121934769
1 changed files with 44 additions and 55 deletions
|
@ -104,16 +104,17 @@ class ConfigInstall:
|
|||
|
||||
################################################################################
|
||||
|
||||
def object_run(self, cdist_object, mode):
|
||||
def object_run(self, cdist_object):
|
||||
"""Run gencode or code for an object"""
|
||||
log.debug("Running %s from %s", mode, cdist_object)
|
||||
|
||||
requirements = cdist_object.requirements
|
||||
# Catch requirements, which re-call us
|
||||
if cdist_object.ran:
|
||||
return
|
||||
|
||||
type = cdist_object.type
|
||||
|
||||
# FIXME: ensure objects are not run multiple times!
|
||||
# FIXME: probably mark objects!
|
||||
for requirement in requirements:
|
||||
for requirement in cdist_object.requirements:
|
||||
log.debug("Object %s requires %s", cdist_object, requirement)
|
||||
self.object_run(requirement, mode=mode)
|
||||
|
||||
|
@ -128,12 +129,7 @@ class ConfigInstall:
|
|||
env["__object_fq"] = cdist_object.name
|
||||
env["__type"] = type.name
|
||||
|
||||
if mode == "gencode":
|
||||
paths = [
|
||||
type.gencode
|
||||
type.gencode_remote
|
||||
]
|
||||
|
||||
# gencode
|
||||
for cmd in ["local", "remote"]:
|
||||
bin = getattr(type, "gencode_" + cmd)
|
||||
|
||||
|
@ -157,27 +153,22 @@ class ConfigInstall:
|
|||
else:
|
||||
# Add header and make executable - identically to 0o700
|
||||
os.chmod(outfile, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR)
|
||||
cdist_object.changed=True
|
||||
|
||||
# FIXME: use new interface
|
||||
# Mark object as changed
|
||||
open(os.path.join(self.path.object_dir(cdist_object), "changed"), "w").close()
|
||||
# code local
|
||||
code_local = cdist_object.code_local
|
||||
if os.path.isfile(code_local):
|
||||
cdist.exec.run_or_fail([code_local])
|
||||
|
||||
|
||||
if mode == "code":
|
||||
local_dir = self.path.object_dir(cdist_object)
|
||||
remote_dir = self.path.remote_object_dir(cdist_object)
|
||||
|
||||
bin = os.path.join(local_dir, "code-local")
|
||||
if os.path.isfile(bin):
|
||||
cdist.exec.run_or_fail([bin])
|
||||
|
||||
|
||||
local_remote_code = os.path.join(local_dir, "code-remote")
|
||||
remote_remote_code = os.path.join(remote_dir, "code-remote")
|
||||
# code remote
|
||||
local_remote_code = cdist_object.code_remote
|
||||
remote_remote_code = cdist_object.code_remote_remote
|
||||
if os.path.isfile(local_remote_code):
|
||||
self.path.transfer_file(local_remote_code, remote_remote_code)
|
||||
self.context.transfer_file(local_remote_code, remote_remote_code)
|
||||
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True)
|
||||
|
||||
cdist_object.ran = True
|
||||
|
||||
### Cleaned / check functions: Round 1 :-) #################################
|
||||
def run_type_explorer(self, cdist_object):
|
||||
"""Run type specific explorers for objects"""
|
||||
|
@ -239,11 +230,9 @@ class ConfigInstall:
|
|||
def stage_run(self):
|
||||
"""The final (and real) step of deployment"""
|
||||
log.info("Generating and executing code")
|
||||
# Now do the final steps over the existing objects
|
||||
for cdist_object in cdist.core.Object.list_objects():
|
||||
log.debug("Run object: %s", cdist_object)
|
||||
self.object_run(cdist_object, mode="gencode")
|
||||
self.object_run(cdist_object, mode="code")
|
||||
self.object_run(cdist_object)
|
||||
|
||||
def deploy_to(self):
|
||||
"""Mimic the old deploy to: Deploy to one host"""
|
||||
|
|
Loading…
Reference in a new issue