Merge branch 'master' into install
Conflicts: lib/cdist/config.py lib/cdist/path.py Merged changes from config.py to config_install.py Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
commit
54fb9e6c3f
14 changed files with 201 additions and 218 deletions
|
|
@ -24,7 +24,9 @@ import datetime
|
|||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
<<<<<<< HEAD
|
||||
import cdist.config_install
|
||||
>>>>>>> master
|
||||
|
||||
class Config(cdist.config_install.ConfigInstall):
|
||||
pass
|
||||
|
|
@ -35,6 +37,9 @@ def config(args):
|
|||
|
||||
time_start = datetime.datetime.now()
|
||||
|
||||
os.environ['__remote_exec'] = "ssh -o User=root -q"
|
||||
os.environ['__remote_copy'] = "scp -o User=root -q"
|
||||
|
||||
for host in args.host:
|
||||
c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug)
|
||||
if args.parallel:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -32,6 +33,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
|
|||
args[0][:0] = [ "/bin/sh", "-e" ]
|
||||
|
||||
if remote_prefix:
|
||||
remote_prefix = os.environ['__remote_exec'].split()
|
||||
remote_prefix.append(os.environ['target_host'])
|
||||
args[0][:0] = remote_prefix
|
||||
|
||||
log.debug("Shell exec cmd: %s", args)
|
||||
|
|
@ -43,6 +46,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
|
|||
subprocess.check_call(*args, **kargs)
|
||||
except subprocess.CalledProcessError:
|
||||
log.error("Code that raised the error:\n")
|
||||
|
||||
if remote_prefix:
|
||||
run_or_fail(["cat", script], remote_prefix=remote_prefix)
|
||||
|
||||
|
|
@ -60,6 +64,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
|
|||
|
||||
def run_or_fail(*args, remote_prefix=False, **kargs):
|
||||
if remote_prefix:
|
||||
remote_prefix = os.environ['__remote_exec'].split()
|
||||
remote_prefix.append(os.environ['target_host'])
|
||||
args[0][:0] = remote_prefix
|
||||
|
||||
log.debug("Exec: " + " ".join(*args))
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ class Path:
|
|||
|
||||
def __init__(self,
|
||||
target_host,
|
||||
remote_user,
|
||||
remote_prefix,
|
||||
initial_manifest=False,
|
||||
base_dir=None,
|
||||
debug=False):
|
||||
|
|
@ -72,9 +70,6 @@ class Path:
|
|||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.target_host = target_host
|
||||
|
||||
self.remote_user = remote_user
|
||||
self.remote_prefix = remote_prefix
|
||||
|
||||
# Input directories
|
||||
self.conf_dir = os.path.join(self.base_dir, "conf")
|
||||
self.cache_base_dir = os.path.join(self.base_dir, "cache")
|
||||
|
|
@ -135,28 +130,24 @@ class Path:
|
|||
# FIXME: belongs to here - clearify remote*
|
||||
def remote_mkdir(self, directory):
|
||||
"""Create directory on remote side"""
|
||||
cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=self.remote_prefix)
|
||||
cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=True)
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
def remove_remote_dir(self, destination):
|
||||
cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=self.remote_prefix)
|
||||
cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=True)
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
def transfer_dir(self, source, destination):
|
||||
"""Transfer directory and previously delete the remote destination"""
|
||||
self.remove_remote_dir(destination)
|
||||
cdist.exec.run_or_fail(["scp", "-qr", source,
|
||||
self.remote_user + "@" +
|
||||
self.target_host + ":" +
|
||||
destination])
|
||||
cdist.exec.run_or_fail(os.environ['__remote_copy'].split() +
|
||||
["-r", source, self.target_host + ":" + destination])
|
||||
|
||||
# FIXME: belongs to here - clearify remote*
|
||||
def transfer_file(self, source, destination):
|
||||
"""Transfer file"""
|
||||
cdist.exec.run_or_fail(["scp", "-q", source,
|
||||
self.remote_user + "@" +
|
||||
self.target_host + ":" +
|
||||
destination])
|
||||
cdist.exec.run_or_fail(os.environ['__remote_copy'].split() +
|
||||
[source, self.target_host + ":" + destination])
|
||||
|
||||
# FIXME: Explorer or stays
|
||||
def global_explorer_output_path(self, explorer):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue