Change in vdsm[master]: devices: move Graphics Device utility functions

fromani at redhat.com fromani at redhat.com
Tue Oct 28 14:17:48 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: devices: move Graphics Device utility functions
......................................................................

devices: move Graphics Device utility functions

After the move of the Graphics Device into vmdevices.py,
we can now move the utility function to cope with legacy
configuration.

Change-Id: Ifd345f8f0eb477f6bda417c418f79900aeee53a5
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices.py
2 files changed, 27 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/34558/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index f9e334a..52cbf3b 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1120,7 +1120,7 @@
         self.conf.update(params)
         if 'smp' not in self .conf:
             self.conf['smp'] = '1'
-        self._initLegacyConf()  # restore placeholders for BC sake
+        vmdevices.initLegacyConf(self.conf)  # restore placeholders for BC sake
         self.cif = cif
         self.log = SimpleLogAdapter(self.log, {"vmId": self.conf['vmId']})
         self._destroyed = False
@@ -4711,7 +4711,7 @@
                     break
 
         # the first graphic device is duplicated in the legacy conf
-        self._updateLegacyConf()
+        vmdevices.updateLegacyConf(self.conf)
 
     def _getUnderlyingNetworkInterfaceInfo(self):
         """
@@ -5200,30 +5200,6 @@
         newChain = [x for x in device['volumeChain']
                     if x['volumeID'] in volumes]
         device['volumeChain'] = drive.volumeChain = newChain
-
-    def _initLegacyConf(self):
-        self.conf['displayPort'] = vmdevices.Graphics.LIBVIRT_PORT_AUTOSELECT
-        self.conf['displaySecurePort'] = \
-            vmdevices.Graphics.LIBVIRT_PORT_AUTOSELECT
-        self.conf['displayIp'] = vmdevices._getNetworkIp(
-            self.conf.get('displayNetwork'))
-
-        dev = self._getFirstGraphicsDevice()
-        if dev:
-            # proper graphics device always take precedence
-            self.conf['display'] = 'qxl' if dev['device'] == 'spice' else 'vnc'
-
-    def _updateLegacyConf(self):
-        dev = self._getFirstGraphicsDevice()
-        if 'port' in dev:
-            self.conf['displayPort'] = dev['port']
-        if 'tlsPort' in dev:
-            self.conf['displaySecurePort'] = dev['tlsPort']
-
-    def _getFirstGraphicsDevice(self):
-        for dev in self.conf.get('devices', ()):
-            if dev.get('type') == vmdevices.GRAPHICS:
-                return dev
 
     def getDiskDevices(self):
         return self._devices[vmdevices.DISK]
diff --git a/vdsm/virt/vmdevices.py b/vdsm/virt/vmdevices.py
index 3c3303c..93c3ae3 100644
--- a/vdsm/virt/vmdevices.py
+++ b/vdsm/virt/vmdevices.py
@@ -363,6 +363,31 @@
         return graphics
 
 
+def initLegacyConf(conf):
+    conf['displayPort'] = Graphics.LIBVIRT_PORT_AUTOSELECT
+    conf['displaySecurePort'] = Graphics.LIBVIRT_PORT_AUTOSELECT
+    conf['displayIp'] = _getNetworkIp(conf.get('displayNetwork'))
+
+    dev = _getFirstGraphicsDevice(conf)
+    if dev:
+        # proper graphics device always take precedence
+        conf['display'] = 'qxl' if dev['device'] == 'spice' else 'vnc'
+
+
+def updateLegacyConf(conf):
+    dev = _getFirstGraphicsDevice(conf)
+    if 'port' in dev:
+        conf['displayPort'] = dev['port']
+    if 'tlsPort' in dev:
+        conf['displaySecurePort'] = dev['tlsPort']
+
+
+def _getFirstGraphicsDevice(conf):
+    for dev in conf.get('devices', ()):
+        if dev.get('type') == GRAPHICS:
+            return dev
+
+
 def _getNetworkIp(network):
     try:
         nets = netinfo.networks()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd345f8f0eb477f6bda417c418f79900aeee53a5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list