[Template]
+;vm_id = centos8
+
;vm = template.pixelpark.com
;vmware_cfg_version = vmx-14
;max_wait_for_finish_install = 3600
+[Cobbler]
+
+# distro = CentOS-8.1-x86_64
+
+# host = cobbler.pixelpark.com
+
+# ssh_port = 22
+
+# ssh_user = root
+
+# ssh_timeout = 30
+
+# root_dir = /var/lib/cobbler
+
+# profile =
+
+# profile_repos = pp-centos8-baseos
+
+# nameservers = 93.188.109.11, 93.188.109.12, 93.188.109.13
+
+# dns_search = pixelpark.net, pixelpark.com, pixelpark.de
+
+
; vim: filetype=dosini
# Third party modules
import paramiko
+from paramiko.ssh_exception import SSHException
# Own modules
from .xlate import XLATOR
-__version__ = '0.3.7'
+__version__ = '0.3.8'
LOG = logging.getLogger(__name__)
proc = CompletedProcess(cmd, retcode, output, err, start_dt=start_dt, end_dt=end_dt)
+ except SSHException as e:
+ msg = _("Could not connect via {w} to {user}@{host}: {e}").format(
+ w='SSH', user=self.ssh_user, host=self.host, e=e)
+ raise ExpectedCobblerError(msg)
+
finally:
if ssh:
if self.verbose > 2:
local=str(local_file), host=self.host, remote=str(remote_file)))
sftp.put(str(local_file), str(remote_file))
+ except SSHException as e:
+ msg = _("Could not connect via {w} to {user}@{host}: {e}").format(
+ w='SCP', user=self.ssh_user, host=self.host, e=e)
+ raise ExpectedCobblerError(msg)
+
finally:
sftp = None
if ssh:
proc = self.exec_cobbler('version', no_simulate=True)
+ if proc.returncode != 0:
+ err = _('No error message')
+ if proc.stderr:
+ err = proc.stderr
+ elif proc.stdout:
+ err = proc.stdout
+ msg = _("Could not get version of cobbler: {}").format(err)
+ raise ExpectedCobblerError(msg)
+
first_line = proc.stdout.splitlines()[0]
cobbler_version = re.sub(r'^\s*cobbler\s+', '', first_line, flags=re.IGNORECASE).strip()
LOG.info(_("Version of {} is:").format("Cobbler") + " {!r}".format(cobbler_version))
+ rdir = self.config.cobbler_rootdir
+ if self.verbose > 1:
+ msg = _("Checking existence of remote directory {!r} ...").format(str(rdir))
+ LOG.debug(msg)
+
+ cmd = textwrap.dedent("""\
+ if [ -d {rdir!r} ] ; then
+ exit 0
+ fi
+ exit 7
+ """).format(rdir=str(rdir))
+
+ proc = self.exec_ssh(cmd)
+ if proc.returncode != 0:
+ msg = _(
+ "Cobbler root directory {rdir!r} on host {host!r} does not "
+ "exists or is not a directory.").format(rdir=str(rdir), host=self.host)
+ raise ExpectedCobblerError(msg)
+
return cobbler_version
# -------------------------------------------------------------------------