from .xlate import XLATOR
-__version__ = '1.6.8'
+__version__ = '1.7.1'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
if self.abort:
LOG.warn(_("Aborting after creation of template VM."))
LOG.warn(_("You are responsible yourself to cleaning up the VM!!!"))
-# else:
-# self.post_install_tasks_ssh()
-# if self.postinstall_errors:
-# self.vsphere.purge_vm(self.tpl_vm, max_wait=self.config.max_wait_for_purge_vm)
-# return 10
-# else:
-# self.poweroff_vm()
+ else:
+ self.post_install_tasks_ssh()
+ if self.postinstall_errors:
+ self.vsphere.purge_vm(self.tpl_vm, max_wait=self.config.max_wait_for_purge_vm)
+ return 10
+ else:
+ self.poweroff_vm()
# self.change_mac_address()
return 0
printf "Current host FQDN: "
hostname -f
+ echo
+ echo "-----------------------------------------------------------"
if [ -f /root/original-ks.cfg ] ; then
- echo
- echo "Kickstart configuration:"
- echo
- echo "-----------------------------------------------------------"
- cat /root/original-ks.cfg
- echo "-----------------------------------------------------------"
- echo
- echo "Removing /root/original-ks.cfg ..."
- rm -v /root/original-ks.cfg
+ echo "Moving /root/original-ks.cfg => /var/log/anaconda/ ..."
+ mv -v /root/original-ks.cfg /var/log/anaconda/
else
- echo
- echo "-----------------------------------------------------------"
echo "File /root/original-ks.cfg not found."
fi
- if [ -v /root/anaconda-ks.cfg ] ; then
- echo
- echo "Removing /root/anaconda-ks.cfg ..."
- rm -v /root/anaconda-ks.cfg
+ echo
+ echo "-----------------------------------------------------------"
+ if [ -f /root/anaconda-ks.cfg ] ; then
+ echo "Moving /root/anaconda-ks.cfg => /var/log/anaconda/ ..."
+ mv -v /root/anaconda-ks.cfg /var/log/anaconda/
else
- echo
- echo "-----------------------------------------------------------"
echo "File /root/anakonda-ks.cfg not found."
fi
- if [ -f /var/log/post-install.log ] ; then
- echo
- echo "Post install log:"
- echo
- echo "-----------------------------------------------------------"
- cat /var/log/post-install.log
- echo "-----------------------------------------------------------"
- echo
- echo "Removing /var/log/post-install.log ..."
- rm -v /var/log/post-install.log
- else
- echo
- echo "-----------------------------------------------------------"
- echo "File /var/log/post-install.log not found."
- fi
+ for f in /var/log/boot.log /var/log/cron /var/log/dnf*.log /var/log/hawkey.log /var/log/messages /var/log/secure /var/log/wtmp /var/log/vmware-*.log* ; do
+ if [ -f "${f}" ] ; then
+ echo "Truncating ${f} ..."
+ cp /dev/null "${f}"
+ fi
+ done
""")
ssh.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
LOG.debug(_("Connecting to {h!r}, port {p} as {u!r} per SSH ...").format(
- h=self.config.template_vm, p=self.ssh_port, u=self.ssh_user))
+ h=self.tpl_ip, p=self.ssh_port, u=self.ssh_user))
ssh.connect(
- self.config.template_vm, port=self.ssh_port, timeout=self.ssh_timeout,
+ self.tpl_ip, port=self.ssh_port, timeout=self.ssh_timeout,
username=self.ssh_user, key_filename=self.private_ssh_key)
LOG.debug(_("Executing postinstall tasks ..."))
cur_duration = cur_time - start_waiting
print('', flush=True)
- LOG.info(_("Last actions before powering off VM {!r} ...").format(self.config.template_vm))
+ LOG.info(_("Last actions before powering off VM {!r} ...").format(self.tpl_ip))
ssh = None
if power_state.strip().lower() != "poweredon":
raise ExpectedHandlerError(
_("Cannot shut down VM {h!r}, is currently in state {s!r}.").format(
- h=self.config.template_vm, s=power_state))
+ h=self.tpl_ip, s=power_state))
- LOG.info(_("Powering off VM {!r} per SSH ...").format(self.config.template_vm))
+ LOG.info(_("Powering off VM {!r} per SSH ...").format(self.tpl_ip))
try:
ssh.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
LOG.debug(_("Connecting to {h!r}, port {p} as {u!r} per SSH ...").format(
- h=self.config.template_vm, p=self.ssh_port, u=self.ssh_user))
+ h=self.tpl_ip, p=self.ssh_port, u=self.ssh_user))
ssh.connect(
- self.config.template_vm, port=self.ssh_port, timeout=self.ssh_timeout,
+ self.tpl_ip, port=self.ssh_port, timeout=self.ssh_timeout,
username=self.ssh_user, key_filename=self.private_ssh_key)
LOG.debug(_("Executing {} ...").format('poweroff'))
print('', flush=True)
LOG.info(_(
"Template VM {h!r} was shutting down in {t:0.1f} seconds.").format(
- h=self.config.template_vm, t=cur_diff))
+ h=self.tpl_ip, t=cur_diff))
return
if cur_diff >= self.config.max_wait_for_shutdown_vm:
break
print('', flush=True)
raise ExpectedHandlerError(_(
"VM {h!r} was not shut down after {t:0.1f} seconds, current state is {s!r}.").format(
- h=self.config.template_vm, t=cur_diff, s=power_state))
+ h=self.tpl_ip, t=cur_diff, s=power_state))
# -------------------------------------------------------------------------
def change_mac_address(self):