Vinzenz Feenstra has uploaded a new change for review. Change subject: vdsm: Refactoring the device dict creation ......................................................................
vdsm: Refactoring the device dict creation The device dictionaries are created on two different locations and explicitly. Since we have the DeviceMapping already, we can use this to generate the dictionary of device lists. Change-Id: I4ce2afa73f1f8d1aea15782fec7fee52ee49d66e Signed-off-by: Vinzenz Feenstra <vfeen...@redhat.com> --- M vdsm/vm.py 1 file changed, 5 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/33/19733/1 diff --git a/vdsm/vm.py b/vdsm/vm.py index d23cd21..cce643a 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -2082,6 +2082,8 @@ (REDIR_DEVICES, RedirDevice), (SMARTCARD_DEVICES, SmartCardDevice)) + def _makeDeviceDict(self): + return dict((dev, []) for dev, _ in self.DeviceMapping) def _makeChannelPath(self, deviceName): return constants.P_LIBVIRT_VMCHANNELS + self.id + '.' + deviceName @@ -2136,12 +2138,7 @@ self.stopDisksStatsCollection() self._vmCreationEvent = threading.Event() self._pathsPreparedEvent = threading.Event() - self._devices = {DISK_DEVICES: [], NIC_DEVICES: [], - SOUND_DEVICES: [], VIDEO_DEVICES: [], - CONTROLLER_DEVICES: [], GENERAL_DEVICES: [], - BALLOON_DEVICES: [], REDIR_DEVICES: [], - WATCHDOG_DEVICES: [], CONSOLE_DEVICES: [], - SMARTCARD_DEVICES: []} + self._devices = self._makeDeviceDict() self._connection = libvirtconnection.get(cif) if 'vmName' not in self.conf: @@ -2240,12 +2237,7 @@ return removables def getConfDevices(self): - devices = {DISK_DEVICES: [], NIC_DEVICES: [], - SOUND_DEVICES: [], VIDEO_DEVICES: [], - CONTROLLER_DEVICES: [], GENERAL_DEVICES: [], - BALLOON_DEVICES: [], REDIR_DEVICES: [], - WATCHDOG_DEVICES: [], CONSOLE_DEVICES: [], - SMARTCARD_DEVICES: []} + devices = self._makeDeviceDict() for dev in self.conf.get('devices'): try: devices[dev['type']].append(dev) @@ -3116,7 +3108,7 @@ self._qemuguestSocketFile.decode('utf-8'), _QEMU_GA_DEVICE_NAME) domxml.appendInput() - domxml.appendGraphics() + domxml.appendGraphics() self._appendDevices(domxml) -- To view, visit http://gerrit.ovirt.org/19733 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ce2afa73f1f8d1aea15782fec7fee52ee49d66e Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra <vfeen...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches