LOG.debug(_("Completed SSH process:") + "\n{}".format(proc))
return proc
+ # -------------------------------------------------------------------------
+ def scp_to(self, local_file, remote_file):
+
+ ssh = None
+ proc = None
+
+ try:
+
+ if self.verbose > 2:
+ LOG.debug(_("Initializing {} ...").format('paramiko SSHClient'))
+ ssh = paramiko.SSHClient()
+ if self.verbose > 2:
+ LOG.debug(_("Loading SSH system host keys."))
+ ssh.load_system_host_keys()
+ if self.verbose > 2:
+ LOG.debug(_("Setting SSH missing host key policy to {}.").format('AutoAddPolicy'))
+ ssh.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
+
+ if self.verbose > 1:
+ LOG.debug(_("Connecting to {h!r}, port {p} as {u!r} per SSH ...").format(
+ h=self.host, p=self.ssh_port, u=self.ssh_user))
+ ssh.connect(
+ self.host, port=self.ssh_port, timeout=self.ssh_timeout,
+ username=self.ssh_user, key_filename=self.private_ssh_key)
+
+ sftp = ssh.open_sftp()
+
+ if self.verbose > 1:
+ LOG.debug(_("SCP of {local!r} to {host}@{remote} ...").format(
+ local=str(local_file), host=self.host, remote=str(remote_file)))
+ sftp.put(str(local_file), str(remote_file))
+
+ finally:
+ sftp = None
+ if ssh:
+ if self.verbose > 2:
+ LOG.debug(_("Closing SSH connection."))
+ ssh.close()
+
# -------------------------------------------------------------------------
def get_cobbler_version(self):
"""Trying to evaluate the version of Cobbler on the cobbler host."""
msg = _("Kickstart script {!r} has to be copied.").format(str(local_ks))
LOG.warn(msg)
+ self.scp_to(local_ks, remote_ks)
+
# -------------------------------------------------------------------------
def ensure_profile(self):
"""Ensure the existence and the correctnes of the given profile."""