name variable target_host for consistency and easy handling
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
c8ce7e98ec
commit
1a96f88656
1 changed files with 11 additions and 8 deletions
19
bin/cdist
19
bin/cdist
|
@ -66,8 +66,8 @@ log = logging.getLogger()
|
||||||
class Cdist:
|
class Cdist:
|
||||||
"""Cdist main class to hold arbitrary data"""
|
"""Cdist main class to hold arbitrary data"""
|
||||||
|
|
||||||
def __init__(self, hostname, initial_manifest=False):
|
def __init__(self, target_host, initial_manifest=False):
|
||||||
self.hostname = hostname
|
self.target_host = target_host
|
||||||
|
|
||||||
# log.info("foobar")
|
# log.info("foobar")
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class Cdist:
|
||||||
|
|
||||||
def remote_run_or_fail(self, *args, **kargs):
|
def remote_run_or_fail(self, *args, **kargs):
|
||||||
"""Run something on the remote side and fail is something breaks"""
|
"""Run something on the remote side and fail is something breaks"""
|
||||||
newargs = ["ssh", "root@" + self.hostname]
|
newargs = ["ssh", "root@" + self.target_host]
|
||||||
newargs.extend(*args)
|
newargs.extend(*args)
|
||||||
self.run_or_fail(newargs, **kargs)
|
self.run_or_fail(newargs, **kargs)
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ class Cdist:
|
||||||
|
|
||||||
def transfer_dir(self, source, destination):
|
def transfer_dir(self, source, destination):
|
||||||
self.remove_remote_dir(destination)
|
self.remove_remote_dir(destination)
|
||||||
self.run_or_fail(["scp", "-qr", source, "root@" + self.hostname + ":" + destination])
|
self.run_or_fail(["scp", "-qr", source, "root@" + self.target_host + ":" + destination])
|
||||||
|
|
||||||
def global_explorer_output_path(self, explorer):
|
def global_explorer_output_path(self, explorer):
|
||||||
"""Returns path of the output for a global explorer"""
|
"""Returns path of the output for a global explorer"""
|
||||||
|
@ -185,20 +185,23 @@ class Cdist:
|
||||||
def run_initial_manifest(self):
|
def run_initial_manifest(self):
|
||||||
"""Run the initial manifest"""
|
"""Run the initial manifest"""
|
||||||
log.info("Running the initial manifest")
|
log.info("Running the initial manifest")
|
||||||
self.shell_run_or_debug_fail(self.initial_manifest, [self.initial_manifest])
|
env = os.environ.copy()
|
||||||
|
env['__target_host'] = self.target_host
|
||||||
|
|
||||||
|
self.shell_run_or_debug_fail(self.initial_manifest,
|
||||||
|
[self.initial_manifest],
|
||||||
|
env=env)
|
||||||
|
|
||||||
|
|
||||||
def deploy_to(self):
|
def deploy_to(self):
|
||||||
"""Mimic the old deploy to: Deploy to one host"""
|
"""Mimic the old deploy to: Deploy to one host"""
|
||||||
log.info("Deploying to host " + self.hostname)
|
log.info("Deploying to host " + self.target_host)
|
||||||
self.init_deploy()
|
self.init_deploy()
|
||||||
self.global_explore()
|
self.global_explore()
|
||||||
self.run_initial_manifest()
|
self.run_initial_manifest()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
hostname=sys.argv[1]
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='cdist ' + VERSION)
|
parser = argparse.ArgumentParser(description='cdist ' + VERSION)
|
||||||
parser.add_argument('host', nargs='+', help='one or more hosts to operate on')
|
parser.add_argument('host', nargs='+', help='one or more hosts to operate on')
|
||||||
parser.add_argument('-d', '--debug', help='set log level to debug',
|
parser.add_argument('-d', '--debug', help='set log level to debug',
|
||||||
|
|
Loading…
Reference in a new issue