Merge "Do not perform port update in case of baremetal instance."
This commit is contained in:
commit
c1f3829cce
|
@ -7225,8 +7225,14 @@ class ComputeManager(manager.Manager):
|
|||
binding_failed or unbound binding:vif_type for any of the instances
|
||||
ports.
|
||||
"""
|
||||
if not utils.is_neutron():
|
||||
# Only update port bindings if compute manager does manage port
|
||||
# bindings instead of the compute driver. For example IronicDriver
|
||||
# manages the port binding for baremetal instance ports, hence,
|
||||
# external intervention with the binding is not desired.
|
||||
if (not utils.is_neutron() or
|
||||
self.driver.manages_network_binding_host_id()):
|
||||
return False
|
||||
|
||||
search_opts = {'device_id': instance.uuid,
|
||||
'fields': ['binding:host_id', 'binding:vif_type']}
|
||||
ports = self.network_api.list_ports(context, **search_opts)
|
||||
|
|
|
@ -7250,6 +7250,19 @@ class ComputeTestCase(BaseTestCase,
|
|||
self.assertTrue(val)
|
||||
mock_list_ports.assert_called_once_with(ctxt, **search_opts)
|
||||
|
||||
def test_require_nw_info_update_for_baremetal(self):
|
||||
"""Tests _require_nw_info_update for baremetal instance,
|
||||
expected behavior is to return False.
|
||||
"""
|
||||
compute_mgr = compute_manager.ComputeManager('ironic.IronicDriver')
|
||||
with mock.patch.object(compute_mgr, 'network_api') as \
|
||||
network_api_mock:
|
||||
ctxt = context.get_admin_context()
|
||||
instance = self._create_fake_instance_obj()
|
||||
val = compute_mgr._require_nw_info_update(ctxt, instance)
|
||||
self.assertFalse(val)
|
||||
network_api_mock.assert_not_called()
|
||||
|
||||
def _heal_instance_info_cache(self,
|
||||
_get_instance_nw_info_raise=False,
|
||||
_get_instance_nw_info_raise_cache=False,
|
||||
|
|
|
@ -1843,6 +1843,19 @@ class ComputeDriver(object):
|
|||
"""
|
||||
return instance.get('host')
|
||||
|
||||
def manages_network_binding_host_id(self):
|
||||
"""Compute driver manages port bindings.
|
||||
|
||||
Used to indicate whether or not the compute driver is responsible
|
||||
for managing port binding details, such as the host_id.
|
||||
By default the ComputeManager will manage port bindings and the
|
||||
host_id associated with a binding using the network API.
|
||||
However, some backends, like Ironic, will manage the port binding
|
||||
host_id out-of-band and the compute service should not override what
|
||||
is set by the backing hypervisor.
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
def load_compute_driver(virtapi, compute_driver=None):
|
||||
"""Load a compute driver module.
|
||||
|
|
|
@ -2176,3 +2176,8 @@ class IronicDriver(virt_driver.ComputeDriver):
|
|||
timer.start(interval=CONF.ironic.api_retry_interval).wait()
|
||||
LOG.info('Successfully unrescued Ironic node %(node)s',
|
||||
{'node': node_uuid}, instance=instance)
|
||||
|
||||
def manages_network_binding_host_id(self):
|
||||
"""IronicDriver manages port bindings for baremetal instances.
|
||||
"""
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue