Consider baremetal device_owner as compute for nova notify
Interface should be correctly removed from ironic when port-delete. Nova should receive notify when baremetal port deleted. Change-Id: I3d53bff8278dabafd929ecbea0b4b3b441c9e1cf Partial-Bug: #1606229
This commit is contained in:
parent
1c3d44a640
commit
8b69189fdd
|
@ -142,6 +142,8 @@ DVR_FIP_LL_CIDR = '169.254.64.0/18'
|
||||||
L3_HA_NET_CIDR = '169.254.192.0/18'
|
L3_HA_NET_CIDR = '169.254.192.0/18'
|
||||||
METADATA_CIDR = '169.254.169.254/32'
|
METADATA_CIDR = '169.254.169.254/32'
|
||||||
|
|
||||||
|
DEVICE_OWNER_BAREMETAL_PREFIX = "baremetal:"
|
||||||
|
|
||||||
# Neutron-lib migration shim. This will wrap any constants that are moved
|
# Neutron-lib migration shim. This will wrap any constants that are moved
|
||||||
# to that library in a deprecation warning, until they can be updated to
|
# to that library in a deprecation warning, until they can be updated to
|
||||||
# import directly from their new location.
|
# import directly from their new location.
|
||||||
|
|
|
@ -27,6 +27,7 @@ from neutron._i18n import _LE, _LI, _LW
|
||||||
from neutron.callbacks import events
|
from neutron.callbacks import events
|
||||||
from neutron.callbacks import registry
|
from neutron.callbacks import registry
|
||||||
from neutron.callbacks import resources
|
from neutron.callbacks import resources
|
||||||
|
from neutron.common import constants as n_const
|
||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.notifiers import batch_notifier
|
from neutron.notifiers import batch_notifier
|
||||||
|
@ -84,8 +85,9 @@ class Notifier(object):
|
||||||
def _is_compute_port(self, port):
|
def _is_compute_port(self, port):
|
||||||
try:
|
try:
|
||||||
if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
|
if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
|
||||||
and port['device_owner'].startswith(
|
and port['device_owner'].startswith((
|
||||||
constants.DEVICE_OWNER_COMPUTE_PREFIX)):
|
constants.DEVICE_OWNER_COMPUTE_PREFIX,
|
||||||
|
n_const.DEVICE_OWNER_BAREMETAL_PREFIX))):
|
||||||
return True
|
return True
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -22,11 +22,13 @@ from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from sqlalchemy.orm import attributes as sql_attr
|
from sqlalchemy.orm import attributes as sql_attr
|
||||||
|
|
||||||
|
from neutron.common import constants
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.notifiers import nova
|
from neutron.notifiers import nova
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
DEVICE_OWNER_COMPUTE = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
|
DEVICE_OWNER_COMPUTE = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
|
||||||
|
DEVICE_OWNER_BAREMETAL = constants.DEVICE_OWNER_BAREMETAL_PREFIX + 'fake'
|
||||||
|
|
||||||
|
|
||||||
class TestNovaNotify(base.BaseTestCase):
|
class TestNovaNotify(base.BaseTestCase):
|
||||||
|
@ -321,6 +323,21 @@ class TestNovaNotify(base.BaseTestCase):
|
||||||
{}, returned_obj)
|
{}, returned_obj)
|
||||||
self.assertEqual(expected_event, event)
|
self.assertEqual(expected_event, event)
|
||||||
|
|
||||||
|
def test_delete_baremetal_port_notify(self):
|
||||||
|
device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
|
||||||
|
port_id = 'bee50827-bcee-4cc8-91c1-a27b0ce54222'
|
||||||
|
returned_obj = {'port':
|
||||||
|
{'device_owner': DEVICE_OWNER_BAREMETAL,
|
||||||
|
'id': port_id,
|
||||||
|
'device_id': device_id}}
|
||||||
|
|
||||||
|
expected_event = {'server_uuid': device_id,
|
||||||
|
'name': nova.VIF_DELETED,
|
||||||
|
'tag': port_id}
|
||||||
|
event = self.nova_notifier.create_port_changed_event('delete_port',
|
||||||
|
{}, returned_obj)
|
||||||
|
self.assertEqual(expected_event, event)
|
||||||
|
|
||||||
@mock.patch('novaclient.client.Client')
|
@mock.patch('novaclient.client.Client')
|
||||||
def test_endpoint_types(self, mock_client):
|
def test_endpoint_types(self, mock_client):
|
||||||
nova.Notifier()
|
nova.Notifier()
|
||||||
|
|
Loading…
Reference in New Issue