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 vfeenstr@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)
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 1: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3835/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4720/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4644/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 2: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3836/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4721/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4645/ : SUCCESS
Vinzenz Feenstra has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 3: Verified+1
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 3: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4932/ : ABORTED
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4046/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4856/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 3:
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4936/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4050/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4860/ : SUCCESS
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
Patch Set 3: Code-Review+2
Dan Kenigsberg has submitted this change and it was merged.
Change subject: vdsm: Refactoring the device dict creation ......................................................................
vdsm: Refactoring the device dict creation
The device dictionaries are created on multiple different locations and explicitly. To avoid this duplication we're now moving it to one location where we define an immutable tuple of tuples and generate the dictionaries from there.
Change-Id: I4ce2afa73f1f8d1aea15782fec7fee52ee49d66e Signed-off-by: Vinzenz Feenstra vfeenstr@redhat.com Reviewed-on: http://gerrit.ovirt.org/19733 Reviewed-by: Dan Kenigsberg danken@redhat.com --- M vdsm/vm.py 1 file changed, 17 insertions(+), 25 deletions(-)
Approvals: Vinzenz Feenstra: Verified Dan Kenigsberg: Looks good to me, approved
vdsm-patches@lists.fedorahosted.org