Flat networks use node.uuid when binding ports.

The flat driver will use the ironic node uuid as
binding:host_id when ports are bound. Also the
binding:vnic_type will be baremetal so that the mechanism
driver in networking-baremetal can bind the port.

Related-Bug: 1658964
Depends-On: I952c7afbef5e80e3fd2a7f32f11bdc522e1ea397
Change-Id: I7841d59c3590106dd8ac7e625a9db7b47674fe29
This commit is contained in:
Harald Jensas 2018-01-20 01:39:16 +01:00
parent 8db78cb36a
commit cd7fd1feff
4 changed files with 43 additions and 34 deletions

View File

@ -60,11 +60,6 @@ class FlatNetwork(common.NeutronVIFPortIDMixin,
:raises: NetworkError when failed to set binding:host_id
"""
LOG.debug("Binding flat network ports")
node = task.node
host_id = node.instance_info.get('nova_host_id')
if not host_id:
return
client = neutron.get_client(context=task.context)
for port_like_obj in task.ports + task.portgroups:
vif_port_id = (
@ -75,7 +70,8 @@ class FlatNetwork(common.NeutronVIFPortIDMixin,
continue
body = {
'port': {
'binding:host_id': host_id
'binding:host_id': task.node.uuid,
'binding:vnic_type': neutron.VNIC_BAREMETAL
}
}
try:

View File

@ -182,15 +182,12 @@ class TestFlatInterface(db_base.DbTestCase):
self, client_mock):
upd_mock = mock.Mock()
client_mock.return_value.update_port = upd_mock
instance_info = self.node.instance_info
instance_info['nova_host_id'] = 'nova_host_id'
self.node.instance_info = instance_info
self.node.save()
extra = {'vif_port_id': 'foo'}
utils.create_test_port(self.context, node_id=self.node.id,
address='52:54:00:cf:2d:33', extra=extra,
uuid=uuidutils.generate_uuid())
exp_body = {'port': {'binding:host_id': 'nova_host_id'}}
exp_body = {'port': {'binding:host_id': self.node.uuid,
'binding:vnic_type': neutron.VNIC_BAREMETAL}}
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.add_provisioning_network(task)
upd_mock.assert_called_once_with('foo', exp_body)
@ -200,10 +197,6 @@ class TestFlatInterface(db_base.DbTestCase):
self, client_mock):
upd_mock = mock.Mock()
client_mock.return_value.update_port = upd_mock
instance_info = self.node.instance_info
instance_info['nova_host_id'] = 'nova_host_id'
self.node.instance_info = instance_info
self.node.save()
internal_info = {'tenant_vif_port_id': 'foo'}
utils.create_test_portgroup(
self.context, node_id=self.node.id, internal_info=internal_info,
@ -211,30 +204,14 @@ class TestFlatInterface(db_base.DbTestCase):
utils.create_test_port(
self.context, node_id=self.node.id, address='52:54:00:cf:2d:33',
extra={'vif_port_id': 'bar'}, uuid=uuidutils.generate_uuid())
exp_body = {'port': {'binding:host_id': 'nova_host_id'}}
exp_body = {'port': {'binding:host_id': self.node.uuid,
'binding:vnic_type': neutron.VNIC_BAREMETAL}}
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.add_provisioning_network(task)
upd_mock.assert_has_calls([
mock.call('bar', exp_body), mock.call('foo', exp_body)
])
@mock.patch.object(neutron, 'get_client')
def test_add_provisioning_network_no_binding_host_id(
self, client_mock):
upd_mock = mock.Mock()
client_mock.return_value.update_port = upd_mock
instance_info = self.node.instance_info
instance_info.pop('nova_host_id', None)
self.node.instance_info = instance_info
self.node.save()
extra = {'vif_port_id': 'foo'}
utils.create_test_port(self.context, node_id=self.node.id,
address='52:54:00:cf:2d:33', extra=extra,
uuid=uuidutils.generate_uuid())
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.add_provisioning_network(task)
self.assertFalse(upd_mock.called)
@mock.patch.object(neutron, 'get_client')
def test_add_provisioning_network_binding_host_id_raise(
self, client_mock):

View File

@ -370,12 +370,14 @@ class TestAgentDeploy(db_base.DbTestCase):
self.node.refresh()
self.assertEqual('bar', self.node.instance_info['foo'])
@mock.patch.object(flat_network.FlatNetwork, 'add_provisioning_network',
spec_set=True, autospec=True)
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk')
@mock.patch.object(deploy_utils, 'build_agent_options')
@mock.patch.object(deploy_utils, 'build_instance_info_for_deploy')
def test_prepare_manage_agent_boot_false(
self, build_instance_info_mock, build_options_mock,
pxe_prepare_ramdisk_mock):
pxe_prepare_ramdisk_mock, add_provisioning_net_mock):
self.config(group='agent', manage_agent_boot=False)
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
@ -385,6 +387,7 @@ class TestAgentDeploy(db_base.DbTestCase):
self.driver.prepare(task)
build_instance_info_mock.assert_called_once_with(task)
add_provisioning_net_mock.assert_called_once_with(mock.ANY, task)
self.assertFalse(build_options_mock.called)
self.assertFalse(pxe_prepare_ramdisk_mock.called)

View File

@ -0,0 +1,33 @@
---
features:
- Adds support for `routed networks
<https://docs.openstack.org/neutron/latest/admin/config-routed-networks>`_
when using ``flat`` network interfaces. This feature requires the
``baremetal`` ml2 mechanism driver and l2 agent in
`openstack/networking-baremetal
<https://docs.openstack.org/networking-baremetal>`_.
upgrade:
- |
The ``baremetal`` ml2 mechanism driver and l2 agent is now recommended for
use with the ``flat`` network interface. When installed, the ``baremetal``
mechanism driver and agent ensure that ports are properly bound in the
Networking service. Installation and configuration of the ml2 components
are documented `here <https://docs.openstack.org/networking-baremetal>`_.
In a configuration without the ml2 mechanism driver and l2 agent, the
Networking service's ports will not be correctly bound. In the Networking
service ports will have status: ``DOWN``, and binding_vif_type:
``binding_failed``. This was always the status for ironic ``flat`` network
interface ports prior to the introduction of the ``baremetal`` mechanism
driver. For a non-routed network, Bare Metal nodes can still be deployed
and are functional, despite this port binding state in the Networking
service.
fixes:
- For the ``flat`` networking interface, fixes an issue where the Networking
service would reject port bindings because no host would match the
*host-id* used in such configurations. The ``flat`` networking interface no
longer requires a networking agent (such as ``neutron-openvswitch-agent``)
to be run on the ``nova-compute`` proxy node which executes the ironic virt
driver. Instead, the interface uses the
`baremetal mechanism driver
<https://docs.openstack.org/networking-baremetal>`_.