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
changes/23/346823/6
Andrey Shestakov 6 years ago
parent 1c3d44a640
commit 8b69189fdd
  1. 2
      neutron/common/constants.py
  2. 6
      neutron/notifiers/nova.py
  3. 17
      neutron/tests/unit/notifiers/test_nova.py

@ -142,6 +142,8 @@ DVR_FIP_LL_CIDR = '169.254.64.0/18'
L3_HA_NET_CIDR = '169.254.192.0/18'
METADATA_CIDR = '169.254.169.254/32'
DEVICE_OWNER_BAREMETAL_PREFIX = "baremetal:"
# 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
# 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 registry
from neutron.callbacks import resources
from neutron.common import constants as n_const
from neutron import context
from neutron import manager
from neutron.notifiers import batch_notifier
@ -84,8 +85,9 @@ class Notifier(object):
def _is_compute_port(self, port):
try:
if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
and port['device_owner'].startswith(
constants.DEVICE_OWNER_COMPUTE_PREFIX)):
and port['device_owner'].startswith((
constants.DEVICE_OWNER_COMPUTE_PREFIX,
n_const.DEVICE_OWNER_BAREMETAL_PREFIX))):
return True
except (KeyError, AttributeError):
pass

@ -22,11 +22,13 @@ from oslo_config import cfg
from oslo_utils import uuidutils
from sqlalchemy.orm import attributes as sql_attr
from neutron.common import constants
from neutron.db import models_v2
from neutron.notifiers import nova
from neutron.tests import base
DEVICE_OWNER_COMPUTE = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
DEVICE_OWNER_BAREMETAL = constants.DEVICE_OWNER_BAREMETAL_PREFIX + 'fake'
class TestNovaNotify(base.BaseTestCase):
@ -321,6 +323,21 @@ class TestNovaNotify(base.BaseTestCase):
{}, returned_obj)
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')
def test_endpoint_types(self, mock_client):
nova.Notifier()

Loading…
Cancel
Save