summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorHarald Jensas <hjensas@redhat.com>2018-01-20 01:39:16 +0100
committerHarald Jensas <hjensas@redhat.com>2018-01-31 16:58:18 +0100
commitcd7fd1feff9932b330bd2337d9e91e3e07995164 (patch)
tree48d8395fd122867fac6d4f189c7935aaad908531 /ironic
parent8db78cb36a6973057e52930d3944f5b66ae597f4 (diff)
downloadironic-cd7fd1feff9932b330bd2337d9e91e3e07995164.tar.gz
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
Diffstat (limited to 'ironic')
-rw-r--r--ironic/drivers/modules/network/flat.py8
-rw-r--r--ironic/tests/unit/drivers/modules/network/test_flat.py31
-rw-r--r--ironic/tests/unit/drivers/modules/test_agent.py5
3 files changed, 10 insertions, 34 deletions
diff --git a/ironic/drivers/modules/network/flat.py b/ironic/drivers/modules/network/flat.py
index e10e45dcb..a8b85cbbd 100644
--- a/ironic/drivers/modules/network/flat.py
+++ b/ironic/drivers/modules/network/flat.py
@@ -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:
diff --git a/ironic/tests/unit/drivers/modules/network/test_flat.py b/ironic/tests/unit/drivers/modules/network/test_flat.py
index 7d1833dce..15f4891a5 100644
--- a/ironic/tests/unit/drivers/modules/network/test_flat.py
+++ b/ironic/tests/unit/drivers/modules/network/test_flat.py
@@ -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,7 +204,8 @@ 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([
@@ -219,23 +213,6 @@ class TestFlatInterface(db_base.DbTestCase):
])
@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):
client_mock.return_value.update_port.side_effect = \
diff --git a/ironic/tests/unit/drivers/modules/test_agent.py b/ironic/tests/unit/drivers/modules/test_agent.py
index 24212b477..1d86c0487 100644
--- a/ironic/tests/unit/drivers/modules/test_agent.py
+++ b/ironic/tests/unit/drivers/modules/test_agent.py
@@ -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)