forked from ungleich-public/cdist
support file transfer and begin support for non root logins
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
ca58841696
commit
151022ffd1
1 changed files with 24 additions and 2 deletions
26
bin/cdist
26
bin/cdist
|
@ -97,7 +97,7 @@ def banner():
|
|||
class Cdist:
|
||||
"""Cdist main class to hold arbitrary data"""
|
||||
|
||||
def __init__(self, target_host, initial_manifest=False):
|
||||
def __init__(self, target_host, initial_manifest=False, remote_user="root"):
|
||||
self.target_host = target_host
|
||||
self.remote_prefix = ["ssh", "root@" + self.target_host]
|
||||
|
||||
|
@ -120,6 +120,8 @@ class Cdist:
|
|||
# List of type explorers transferred
|
||||
self.type_explorers_transferred = {}
|
||||
|
||||
self.remote_user = remote_user
|
||||
|
||||
# Mostly static, but can be overwritten on user demand
|
||||
if initial_manifest:
|
||||
self.initial_manifest = initial_manifest
|
||||
|
@ -192,7 +194,17 @@ class Cdist:
|
|||
def transfer_dir(self, source, destination):
|
||||
"""Transfer directory and previously delete the remote destination"""
|
||||
self.remove_remote_dir(destination)
|
||||
self.run_or_fail(["scp", "-qr", source, "root@" + self.target_host + ":" + destination])
|
||||
self.run_or_fail(["scp", "-qr", source,
|
||||
self.remote_user + "@" +
|
||||
self.target_host + ":" +
|
||||
destination])
|
||||
|
||||
def transfer_file(self, source, destination):
|
||||
"""Transfer file"""
|
||||
self.run_or_fail(["scp", "-q", source,
|
||||
self.remote_user + "@" +
|
||||
self.target_host + ":" +
|
||||
destination])
|
||||
|
||||
def global_explorer_output_path(self, explorer):
|
||||
"""Returns path of the output for a global explorer"""
|
||||
|
@ -311,6 +323,16 @@ class Cdist:
|
|||
self.transfer_dir(self.object_parameter_dir(cdist_object),
|
||||
self.remote_object_parameter_dir(cdist_object))
|
||||
|
||||
def transfer_object_code(self, cdist_object):
|
||||
FIXME
|
||||
"""Transfer the object code to the remote destination"""
|
||||
# Create base path before using mkdir -p
|
||||
self.remote_mkdir(self.remote_object_parameter_dir(cdist_object))
|
||||
|
||||
# Synchronise parameter dir afterwards
|
||||
self.transfer_dir(self.object_parameter_dir(cdist_object),
|
||||
self.remote_object_parameter_dir(cdist_object))
|
||||
|
||||
def transfer_global_explorers(self):
|
||||
"""Transfer the global explorers"""
|
||||
self.transfer_dir(GLOBAL_EXPLORER_DIR, REMOTE_GLOBAL_EXPLORER_DIR)
|
||||
|
|
Loading…
Reference in a new issue