Browse Source

Fix handling of FQDN in port binding delete

When a port binding resource update comes in from the provisioning
queue, its host will always be the FQDN (if Neutron/Nova have been
configured to use FQDN hostnames.) If use_fqdn is false, we already
use the short host name on create and in tracking existing neutron
and CVX resources, but on delete, we're correctly querying the DB
with the FQDN, but then continuing to use the FQDN in forcing the
CVX update and generating the data for the HTTP DELETE call.

The proposed fix is to override the force_resource_update and
_delete_neutron_resource methods to correct the hostname in those
calls if necessary.

Change-Id: Ifaca6c22770991a6195f69dd245c865ebf978138
(cherry picked from commit 02e953f96c)
changes/32/788932/1
Mitchell Jameson 3 months ago
parent
commit
7efb01e1a8
  1. 15
      networking_arista/ml2/arista_resources.py
  2. 90
      networking_arista/tests/unit/ml2/test_mechanism_arista.py

15
networking_arista/ml2/arista_resources.py

@ -496,6 +496,21 @@ class PortBindings(AristaResourcesBase):
endpoint = 'region/%(region)s/portbinding'
get_db_resources = staticmethod(db_lib.get_port_bindings)
@staticmethod
def maybe_strip_fqdn(id):
port_id, binding = id
if type(binding) != tuple:
binding = utils.hostname(binding)
return (port_id, binding)
def force_resource_update(self, id):
id = self.maybe_strip_fqdn(id)
super(PortBindings, self).force_resource_update(id)
def _delete_neutron_resource(self, id):
id = self.maybe_strip_fqdn(id)
super(PortBindings, self)._delete_neutron_resource(id)
@classmethod
def get_resource_ids(cls, resource):
resource_ids = set()

90
networking_arista/tests/unit/ml2/test_mechanism_arista.py

@ -15,6 +15,7 @@
import mock
from neutron.tests.common import helpers
from neutron_lib import constants as n_const
from oslo_config import cfg
@ -871,6 +872,95 @@ class BasicMechDriverTestCase(ml2_test_base.MechTestBase):
self.assertPortBindingDeleted((port['id'], port_host))
class FQDNFalseTestCase(ml2_test_base.MechTestBase):
def setUp(self):
cfg.CONF.set_override('use_fqdn', False, "ml2_arista")
super(FQDNFalseTestCase, self).setUp()
self.fqdnHost = 'fqdnhost.full.domain.com'
helpers.register_ovs_agent(
host=self.fqdnHost, bridge_mappings={self.physnet: 'br-eth1'})
def test_fqdn_false(self):
network_tenant = 'net-ten'
net_dict = {'network': {'name': 'net',
'tenant_id': network_tenant,
'admin_state_up': True,
'shared': False,
'provider:physical_network': self.physnet,
'provider:network_type': 'vlan'}}
network, _ = self.create_network(net_dict)
# Create VM port
device_id = 'vm-1'
port_tenant = 'port-ten'
port_host = self.fqdnHost
port_dict = {'name': 'port1',
'tenant_id': port_tenant,
'network_id': network['id'],
'admin_state_up': True,
'fixed_ips': [],
'device_id': device_id,
'device_owner': 'compute:',
'binding:host_id': port_host}
port, _ = self.create_port(port_dict)
self.assertTenantCreated(port_tenant)
self.assertVmCreated(device_id)
self.assertVmPortCreated(port['id'])
self.assertPortBindingCreated((port['id'], 'fqdnhost'))
# Delete VM port
self.delete_port(port['id'])
self.assertTenantDeleted(port_tenant)
self.assertVmDeleted(device_id)
self.assertVmPortDeleted(port['id'])
self.assertPortBindingDeleted((port['id'], 'fqdnhost'))
class FQDNTrueTestCase(ml2_test_base.MechTestBase):
def setUp(self):
super(FQDNTrueTestCase, self).setUp()
self.fqdnHost = 'fqdnhost.full.domain.com'
helpers.register_ovs_agent(
host=self.fqdnHost, bridge_mappings={self.physnet: 'br-eth1'})
def test_fqdn_true(self):
network_tenant = 'net-ten'
net_dict = {'network': {'name': 'net',
'tenant_id': network_tenant,
'admin_state_up': True,
'shared': False,
'provider:physical_network': self.physnet,
'provider:network_type': 'vlan'}}
network, _ = self.create_network(net_dict)
# Create VM port
device_id = 'vm-1'
port_tenant = 'port-ten'
port_host = self.fqdnHost
port_dict = {'name': 'port1',
'tenant_id': port_tenant,
'network_id': network['id'],
'admin_state_up': True,
'fixed_ips': [],
'device_id': device_id,
'device_owner': 'compute:',
'binding:host_id': port_host}
port, _ = self.create_port(port_dict)
self.assertTenantCreated(port_tenant)
self.assertVmCreated(device_id)
self.assertVmPortCreated(port['id'])
self.assertPortBindingCreated((port['id'], self.fqdnHost))
# Delete VM port
self.delete_port(port['id'])
self.assertTenantDeleted(port_tenant)
self.assertVmDeleted(device_id)
self.assertVmPortDeleted(port['id'])
self.assertPortBindingDeleted((port['id'], self.fqdnHost))
class BasicHpbMechDriverTestCase(ml2_test_base.MechTestBase):
def setUp(self):

Loading…
Cancel
Save