Sandro Bonazzola has uploaded a new change for review. Change subject: packaging: setup: avoid endless loop when setVmTicket fails ......................................................................
packaging: setup: avoid endless loop when setVmTicket fails - avoid endless loop when setVmTicket fails - use private variable for range iterations (pylint warned about unused variable i) Change-Id: I664fb5ce7620bda4f8e8d6d46a0b024aecae149a Signed-off-by: Sandro Bonazzola <[email protected]> --- M src/plugins/ovirt-hosted-engine-setup/vm/runvm.py 1 file changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/39/17539/1 diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py index 077dcb4..9d34a8c 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py @@ -26,6 +26,7 @@ import string import random import gettext +import time from otopi import util @@ -45,6 +46,9 @@ VM configuration plugin. """ + TICKET_MAX_TRIES = 10 + TICKET_DELAY = 1 + def __init__(self, context): super(Plugin, self).__init__(context=context) self._vdscommand = [] @@ -54,8 +58,8 @@ _('Generating a temporary VNC password.') ) return '%s%s' % ( - ''.join([random.choice(string.digits) for i in range(4)]), - ''.join([random.choice(string.letters) for i in range(4)]), + ''.join([random.choice(string.digits) for _i in range(4)]), + ''.join([random.choice(string.letters) for _i in range(4)]), ) def _generateUserMessage(self, console_type): @@ -75,8 +79,8 @@ 'You can now connect to the VM with the following command:\n' '\t{remote} --spice-ca-file={ca_cert} ' 'spice://localhost?tls-port=5900 ' - '"--spice-host-subject=${subject}"\nUse temporary password ' - '"{password}" to connect to spice console.' + '--spice-host-subject="{subject}"\nUse temporary password ' + '"{password}" to connect to vnc console.' ).format( remote=self.command.get('remote-viewer'), ca_cert=ohostedcons.FileLocations.LIBVIRT_CA_CERT, @@ -108,7 +112,9 @@ raiseOnError=True ) password_set = False - while not password_set: + tries = self.TICKET_MAX_TRIES + while not password_set and tries > 0: + tries -= 1 waiter.wait() try: cmd = self._vdscommand + [ @@ -126,6 +132,7 @@ password_set = True except RuntimeError as e: self.logger.debug(str(e)) + time.sleep(self.TICKET_DELAY) self.dialog.note( self._generateUserMessage( self.environment[ -- To view, visit http://gerrit.ovirt.org/17539 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I664fb5ce7620bda4f8e8d6d46a0b024aecae149a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
