refactor: remove duplicated logic

Remove _update_port_pci_binding_profile and replace its usage with
_get_pci_device_profile.

Change-Id: I34dae6fdb746205f0baa4997e69eec55634bec4d
This commit is contained in:
Balazs Gibizer
2022-03-20 09:47:10 +01:00
parent de10013328
commit 8d2776fb34

View File

@@ -3693,25 +3693,6 @@ class API:
return None
return device
def _update_port_pci_binding_profile(self, pci_dev, binding_profile):
"""Update the binding profile dict with new PCI device data.
:param pci_dev: The PciDevice object to update the profile with.
:param binding_profile: The dict to update.
"""
binding_profile.update({'pci_slot': pci_dev.address})
if binding_profile.get('card_serial_number'):
binding_profile.update({
'card_serial_number': pci_dev.card_serial_number})
if binding_profile.get('pf_mac_address'):
binding_profile.update({
'pf_mac_address': pci_utils.get_mac_by_pci_address(
pci_dev.parent_addr)})
if binding_profile.get('vf_num'):
binding_profile.update({
'vf_num': pci_utils.get_vf_num_by_pci_address(
pci_dev.address)})
def _update_port_binding_for_instance(
self, context, instance, host, migration=None,
provider_mappings=None):
@@ -3780,8 +3761,9 @@ class API:
else:
pci_dev = self._get_port_pci_dev(context, instance, p)
if pci_dev:
self._update_port_pci_binding_profile(pci_dev,
binding_profile)
binding_profile.update(
self._get_pci_device_profile(pci_dev)
)
updates[constants.BINDING_PROFILE] = binding_profile
# NOTE(gibi): during live migration the conductor already sets the