Fix port creation with generated payload.

Drivers nested_macvlan_vif and sriov have _get_port_request helper
method for generating payload used for port creation. There was
inconsistency in it's usage. In this patch we stright this up.

Implements: blueprint switch-to-openstacksdk
Change-Id: Iab77c0ba67d836c49f91aa9d896d47448e734e79
This commit is contained in:
Roman Dobosz
2020-01-30 11:00:30 +01:00
parent f2a0cf951c
commit f2eb7ef686
3 changed files with 6 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
vm_port = self._get_parent_port(pod)
if not container_port:
container_port = neutron.create_port(req).get('port')
container_port = neutron.create_port({'port': req}).get('port')
_tag_neutron_port(container_port['id'])
container_mac = container_port['mac_address']

View File

@@ -133,7 +133,7 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
amount_value = requests[sriov_resource_name]
total_amount += int(amount_value)
except KeyError:
continue
continue
return total_amount
@@ -159,7 +159,7 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
if driver in constants.USERSPACE_DRIVERS:
break
except KeyError:
continue
continue
def _get_port_request(self, pod, project_id, subnets, security_groups):
port_req_body = {
@@ -177,4 +177,4 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
if security_groups:
port_req_body['security_groups'] = security_groups
return {'port': port_req_body}
return port_req_body

View File

@@ -58,7 +58,7 @@ class TestNestedMacvlanPodVIFDriver(test_base.TestCase):
m_driver._get_port_request.assert_called_once_with(
pod, project_id, subnets, security_groups)
neutron.create_port.assert_called_once_with(port_request)
neutron.create_port.assert_called_once_with({'port': port_request})
m_driver._get_parent_port.assert_called_once_with(pod)
m_driver._try_update_port.assert_called_once()
m_to_vif.assert_called_once_with(container_port['port'], subnets)
@@ -83,7 +83,7 @@ class TestNestedMacvlanPodVIFDriver(test_base.TestCase):
m_driver, pod, project_id, subnets, security_groups)
m_driver._get_port_request.assert_called_once_with(
pod, project_id, subnets, security_groups)
neutron.create_port.assert_called_once_with(port_request)
neutron.create_port.assert_called_once_with({'port': port_request})
m_driver._try_update_port.assert_not_called()
m_to_vif.assert_not_called()