Follow up on Update binding:profile for SR-IOV ports

This patch addresses comments from https://review.openstack.org/#/c/242573

- Only load PCI mappings when there is at least one port of type SR-IOV.
- Fixed exception message on neutron port update.

Change-Id: I88586c66a2b2b84a2ff4a5c00857d3da19148268
Partial-bug: #1512880
This commit is contained in:
Ludovic Beliveau 2016-07-28 15:03:07 -04:00
parent 30c554ffba
commit 3db49d339e
1 changed files with 7 additions and 2 deletions

View File

@ -2242,7 +2242,7 @@ class API(base_api.NetworkAPI):
search_opts = {'device_id': instance.uuid,
'tenant_id': instance.project_id}
data = neutron.list_ports(**search_opts)
pci_mapping = self._get_pci_mapping_for_migration(context, instance)
pci_mapping = None
port_updates = []
ports = data['ports']
for p in ports:
@ -2258,6 +2258,10 @@ class API(base_api.NetworkAPI):
# allocated.
vnic_type = p.get('binding:vnic_type')
if vnic_type in network_model.VNIC_TYPES_SRIOV:
if not pci_mapping:
pci_mapping = self._get_pci_mapping_for_migration(context,
instance)
binding_profile = p.get('binding:profile', {})
pci_slot = binding_profile.get('pci_slot')
new_dev = pci_mapping.get(pci_slot)
@ -2283,7 +2287,8 @@ class API(base_api.NetworkAPI):
neutron.update_port(port_id, {'port': updates})
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Unable to update host of port %s"),
LOG.exception(_LE("Unable to update binding details "
"for port %s"),
port_id, instance=instance)
def update_instance_vnic_index(self, context, instance, vif, index):