from .config import CrTplConfiguration
-__version__ = '0.10.10'
+__version__ = '0.10.11'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
echo
echo "Removing /root/original-ks.cfg ..."
rm -v /root/original-ks.cfg
+ 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
+ else
+ echo
+ echo "-----------------------------------------------------------"
+ echo "File /root/anakonda-ks.cfg not found."
fi
if [ -f /var/log/post-install.log ] ; then
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
""")
wait_for_shutdown = 15
- LOG.debug("Waiting for {} seconds for shutting down:".format(wait_for_shutdown))
+ LOG.info("Waiting for {} seconds before shutting down:".format(wait_for_shutdown))
print(' ==> ', end='', flush=True)
start_waiting = time.time()
cur_duration = 0
last_dot = cur_time
+ i = 0
while cur_duration <= wait_for_shutdown:
time.sleep(0.1)
cur_time = time.time()
if (cur_time - last_dot) >= 1:
print('.', end='', flush=True)
last_dot = cur_time
+ i += 1
+ if not i % 60:
+ print('\n ', end='', flush=True)
cur_duration = cur_time - start_waiting
print('', flush=True)
""")
vm = self.get_temp_tpl_vm()
- guest_state = vm.guest.guestState
- LOG.debug("Current state of template VM is {!r}".format(guest_state))
- if guest_state.strip().lower() == "notrunning":
+ power_state = vm.runtime.powerState
+ LOG.debug("Current state of template VM is {!r}".format(power_state))
+ if power_state.strip().lower() == "poweredoff":
LOG.info("Template VM is already shut off.")
return
- if guest_state.strip().lower() != "running":
+ 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=guest_state))
+ h=self.config.template_vm, s=power_state))
LOG.info("Powering off VM {!r} per SSH ...".format(self.config.template_vm))
LOG.debug("Waiting for successful shut down of VM ...")
if self.verbose <= 3:
print(' ==> ', end='', flush=True)
+ if self.verbose > 3:
+ LOG.debug("Current state of template VM is {!r}".format(power_state))
- while guest_state.strip().lower() != "notrunning":
+ while power_state.strip().lower() != "poweredoff":
time.sleep(0.2)
dot = '.'
- if guest_state.lower().strip() != 'running':
+ if power_state.lower().strip() != 'poweredon':
dot = 'S'
cur_time = time.time()
last_dot = cur_time
vm = self.get_temp_tpl_vm()
- guest_state = vm.guest.guestState
+ power_state = vm.runtime.powerState
if self.verbose > 3:
LOG.debug("Still waiting for completing shutdown, current state is {!r}.".format(
- guest_state))
- if guest_state.strip().lower() == "notrunning":
+ power_state))
+ if power_state.strip().lower() == "poweredoff":
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))
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=guest_state))
+ h=self.config.template_vm, t=cur_diff, s=power_state))
# -------------------------------------------------------------------------
def change_mac_address(self):