[OVN] Accept OVS system-id as non UUID formatted string
Accept OVS system-id non UUID formatted strings. The OVN metadata agent will generate a unique UUID from the OVS system-id. If this string is a UUID, this value will be used. If not, the OVN metadata agent will generate a UUID based on the provided string. This patch amends [1]. [1]https://review.opendev.org/c/openstack/neutron/+/819634 Closes-Bug: #1952550 Change-Id: I42a8a767a6ef9454419b26f80339394759644faf
This commit is contained in:
parent
0baf23d521
commit
79037c9516
@ -48,6 +48,8 @@ OVN_VIF_PORT_TYPES = ("", "external", )
|
|||||||
MetadataPortInfo = collections.namedtuple('MetadataPortInfo', ['mac',
|
MetadataPortInfo = collections.namedtuple('MetadataPortInfo', ['mac',
|
||||||
'ip_addresses'])
|
'ip_addresses'])
|
||||||
|
|
||||||
|
OVN_METADATA_UUID_NAMESPACE = uuid.UUID('d34bf9f6-da32-4871-9af8-15a4626b41ab')
|
||||||
|
|
||||||
|
|
||||||
def _sync_lock(f):
|
def _sync_lock(f):
|
||||||
"""Decorator to block all operations for a global sync call."""
|
"""Decorator to block all operations for a global sync call."""
|
||||||
@ -206,13 +208,12 @@ class MetadataAgent(object):
|
|||||||
try:
|
try:
|
||||||
self.chassis_id = uuid.UUID(self.chassis)
|
self.chassis_id = uuid.UUID(self.chassis)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
LOG.exception('Chassis name %s is not a correctly formatted UUID '
|
# OVS system-id could be a non UUID formatted string.
|
||||||
'string', self.chassis)
|
self.chassis_id = uuid.uuid5(OVN_METADATA_UUID_NAMESPACE,
|
||||||
raise ConfigException()
|
self.chassis)
|
||||||
|
|
||||||
self.ovn_bridge = self._get_ovn_bridge()
|
self.ovn_bridge = self._get_ovn_bridge()
|
||||||
LOG.debug("Loaded chassis %s and ovn bridge %s.",
|
LOG.debug("Loaded chassis name %s (UUID: %s) and ovn bridge %s.",
|
||||||
self.chassis, self.ovn_bridge)
|
self.chassis, self.chassis_id, self.ovn_bridge)
|
||||||
|
|
||||||
@_sync_lock
|
@_sync_lock
|
||||||
def resync(self):
|
def resync(self):
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
import uuid
|
||||||
|
|
||||||
from neutron_lib import constants as n_const
|
from neutron_lib import constants as n_const
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_config import fixture as config_fixture
|
from oslo_config import fixture as config_fixture
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from neutron.agent.linux import ip_lib
|
from neutron.agent.linux import ip_lib
|
||||||
from neutron.agent.linux.ip_lib import IpAddrCommand as ip_addr
|
from neutron.agent.linux.ip_lib import IpAddrCommand as ip_addr
|
||||||
@ -268,3 +270,24 @@ class TestMetadataAgent(base.BaseTestCase):
|
|||||||
mock.ANY, 'namespace', 80, mock.ANY,
|
mock.ANY, 'namespace', 80, mock.ANY,
|
||||||
bind_address=n_const.METADATA_V4_IP, network_id='1')
|
bind_address=n_const.METADATA_V4_IP, network_id='1')
|
||||||
mock_checksum.assert_called_once_with('namespace')
|
mock_checksum.assert_called_once_with('namespace')
|
||||||
|
|
||||||
|
def test__load_config(self):
|
||||||
|
# Chassis name UUID formatted string. OVN bridge "br-ovn".
|
||||||
|
valid_uuid_str = uuidutils.generate_uuid()
|
||||||
|
self.agent.ovs_idl.db_get.return_value.execute.side_effect = [
|
||||||
|
{'system-id': valid_uuid_str}, {'ovn-bridge': 'br-ovn'}]
|
||||||
|
self.agent._load_config()
|
||||||
|
self.assertEqual(valid_uuid_str, self.agent.chassis)
|
||||||
|
self.assertEqual(uuid.UUID(valid_uuid_str), self.agent.chassis_id)
|
||||||
|
self.assertEqual('br-ovn', self.agent.ovn_bridge)
|
||||||
|
|
||||||
|
# Chassis name non UUID formatted string. OVN bridge not defined,
|
||||||
|
# "br-int" assigned by default.
|
||||||
|
self.agent.ovs_idl.db_get.return_value.execute.side_effect = [
|
||||||
|
{'system-id': 'RandomName1'}, {}]
|
||||||
|
self.agent._load_config()
|
||||||
|
generated_uuid = uuid.uuid5(agent.OVN_METADATA_UUID_NAMESPACE,
|
||||||
|
'RandomName1')
|
||||||
|
self.assertEqual('RandomName1', self.agent.chassis)
|
||||||
|
self.assertEqual(generated_uuid, self.agent.chassis_id)
|
||||||
|
self.assertEqual('br-int', self.agent.ovn_bridge)
|
||||||
|
Loading…
Reference in New Issue
Block a user