from .xlate import XLATOR
-__version__ = '0.4.1'
+__version__ = '0.4.2'
LOG = logging.getLogger(__name__)
dsc=dsc, rdir=str(rdir), host=self.host)
raise ExpectedCobblerError(msg)
+ # -------------------------------------------------------------------------
+ def ensure_remote_directory(self, rdir, desc=None):
+
+ if self.verbose:
+ msg = _("Ensuring existence of remote directory {!r} ...").format(str(rdir))
+ LOG.debug(msg)
+
+ verb = ''
+ if self.verbose:
+ verb = " --verbose"
+
+ cmd = textwrap.dedent("""\
+ if [ -d {rdir!r} ] ; then
+ exit 0
+ fi
+ if [ -e {rdir!r} ] ; then
+ echo "Path {rdir!r} exists, but is not a directory." >&2
+ exit 7
+ fi
+ mkdir --parents{verb} {rdir!r}
+ """).format(rdir=str(rdir), verb=verb)
+
+ proc = self.exec_ssh(cmd)
+ if proc.returncode == 0:
+ if proc.stdout:
+ LOG.debug(_("Output:") + "\n{}".format(proc.stdout))
+ else:
+ dsc = _('Remote directory')
+ if desc:
+ dsc = desc
+ err = _('No error message')
+ if proc.stderr:
+ err = proc.stderr
+ elif proc.stdout:
+ err = proc.stdout
+ msg = _(
+ "{dsc} {rdir!r} on host {host!r} could not be created: {err}").format(
+ dsc=dsc, rdir=str(rdir), host=self.host, err=err)
+ raise ExpectedCobblerError(msg)
+
# -------------------------------------------------------------------------
def get_distro_list(self):
"""Trying to get a list of all configured distros."""
from .xlate import XLATOR
-__version__ = '1.5.0'
+__version__ = '1.5.1'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
terminal_has_colors=self.terminal_has_colors, initialized=False)
self.cobbler.initialized = True
+ if not self.config.os_id:
+ msg = _("No ID for Operating system defined, please check the configuration.")
+ raise HandlerError(msg)
+ cur_ts = datetime.datetime.now()
+ cur_ts_str = cur_ts.strftime('%Y-%m-%d-%H-%M-%S')
+ self.tpl_vm_hostname = self.config.os_id + '-' + cur_ts_str
+
if initialized:
self.initialized = True
self.vsphere.initialized = True
# -------------------------------------------------------------------------
@property
- def tpl_vm_hostname_base(self):
+ def tpl_vm_fqdn(self):
+ """The FQDN of the template VM."""
+ if not self.tpl_vm_hostname:
+ return None
+ if not self.config:
+ return self.tpl_vm_hostname
+ if not self.config.tpl_vm_domain:
+ return self.tpl_vm_hostname
+ return self.tpl_vm_hostname + '.' + self.config.tpl_vm_domain
+
+ # -------------------------------------------------------------------------
+ def as_dict(self, short=True):
+ """
+ Transforms the elements of the object into a dict
+
+ @param short: don't include local properties in resulting dict.
+ @type short: bool
+
+ @return: structure as dict
+ @rtype: dict
+ """
+
+ res = super(CrTplHandler, self).as_dict(short=short)
+ res['tpl_vm_fqdn'] = self.tpl_vm_fqdn
+ return res
# -------------------------------------------------------------------------
def __call__(self):