Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: detect display port at runtime
......................................................................

packaging: setup: detect display port at runtime

previously the tool wrongly assumed that the SPICE and
the VNC port was always 5900.
Now displayPort and secureDisplayPort are detected at runtime
querying the status of the VM.

Change-Id: I8ae46b061b2a3ad0190f798cb141a41431120839
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
1 file changed, 27 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/69/19869/1

diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py 
b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
index fd656e1..4615048 100644
--- a/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
+++ b/src/plugins/ovirt-hosted-engine-setup/vm/runvm.py
@@ -63,22 +63,45 @@
         )
 
     def _generateUserMessage(self, console_type):
+        displayPort = 5900
+        displaySecurePort = 5901
+        serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI]
+        try:
+            stats = serv.s.getVmStats(
+                self.environment[ohostedcons.VMEnv.VM_UUID]
+            )
+            self.logger.debug(stats)
+            if not stats['status']['code'] == 0:
+                self.logger.error(stats['status']['message'])
+            else:
+                statsList = stats['statsList'][0]
+                displaySecurePort = statsList['displaySecurePort']
+                displayPort = statsList['displayPort']
+        except Exception:
+            self.logger.debug(
+                'Error getting VM stats',
+                exc_info=True,
+            )
         if console_type == 'vnc':
             return _(
                 'You can now connect to the VM with the following command:\n'
-                '\t{remote} vnc://localhost:5900\nUse temporary password '
-                '"{password}" to connect to vnc console.\n'
+                '\t{remote} vnc://localhost:{displayPort}\n'
+                'Use temporary password "{password}" '
+                'to connect to vnc console.\n'
             ).format(
                 remote=self.command.get('remote-viewer'),
                 password=self.environment[
                     ohostedcons.VMEnv.VM_PASSWD
                 ],
+                displayPort=displayPort
             )
         elif console_type == 'qxl':
+            if displaySecurePort < 0:
+                displaySecurePort = displayPort
             return _(
                 '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://localhost?tls-port={displaySecurePort} '
                 '--spice-host-subject="{subject}"\nUse temporary password '
                 '"{password}" to connect to spice console.'
             ).format(
@@ -88,6 +111,7 @@
                 password=self.environment[
                     ohostedcons.VMEnv.VM_PASSWD
                 ],
+                displaySecurePort=displaySecurePort
             )
 
         else:


-- 
To view, visit http://gerrit.ovirt.org/19869
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ae46b061b2a3ad0190f798cb141a41431120839
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to