diff --git a/nova/pci/device.py b/nova/pci/device.py index 176e08a11a40..a7cb201cfdb3 100644 --- a/nova/pci/device.py +++ b/nova/pci/device.py @@ -95,29 +95,3 @@ def free(devobj, instance=None): instance['pci_devices'].remove(existed) else: instance.pci_devices.objects.remove(existed) - - -def update_device(devobj, dev_dict): - """Sync the content from device dictionary to device object. - - The resource tracker updates the available devices periodically. - To avoid meaningless syncs with the database, we update the device - object only if a value changed. - """ - - # Note(yjiang5): status/instance_uuid should only be updated by - # functions like claim/allocate etc. The id is allocated by - # database. The extra_info is created by the object. - no_changes = ('status', 'instance_uuid', 'id', 'extra_info') - map(lambda x: dev_dict.pop(x, None), - [key for key in no_changes]) - - for k, v in dev_dict.items(): - if k in devobj.fields.keys(): - devobj[k] = v - else: - # Note (yjiang5) extra_info.update does not update - # obj_what_changed, set it explicitely - extra_info = devobj.extra_info - extra_info.update({k: v}) - devobj.extra_info = extra_info diff --git a/nova/pci/manager.py b/nova/pci/manager.py index 1711d1d66da5..f1216901eb45 100644 --- a/nova/pci/manager.py +++ b/nova/pci/manager.py @@ -143,7 +143,7 @@ class PciDevTracker(object): # by force in future. self.stale[new_value['address']] = new_value else: - device.update_device(existed, new_value) + existed.update_device(new_value) for dev in [dev for dev in devices if dev['address'] in new_addrs - exist_addrs]: @@ -185,7 +185,7 @@ class PciDevTracker(object): device.free(dev, instance) stale = self.stale.pop(dev['address'], None) if stale: - device.update_device(dev, stale) + dev.update_device(stale) self.stats.add_device(dev) def _free_instance(self, instance):