From 507daea012322b913128f5d201057966f8e3dfcf Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Tue, 15 Jan 2013 14:16:57 +1300 Subject: Export the MAC addresses of nodes for bare-metal. The bare-metal hypervisor needs to let the network layer know the MAC address of each node it has, or TFTP boot will fail, as the MAC addresses quantum / nova dynamically allocate will not match the actual MAC of the node as it boots. This change exports the MAC addresses to the manager, which passes them onto the network driver in use. With this change administrators should register all the MAC addresses of a given node with Nova bare-metal as interfaces, even though that may duplicate the MAC for PXE boot provisioning. Long term the dedicated provisioning MAC address will be removed. Change-Id: I55f6031294a2c5d31975462f868aa27441e11ad2 --- nova/tests/baremetal/test_driver.py | 13 +++++++++++++ nova/virt/baremetal/driver.py | 6 ++++++ 2 files changed, 19 insertions(+) (limited to 'nova') diff --git a/nova/tests/baremetal/test_driver.py b/nova/tests/baremetal/test_driver.py index d5384eff0..37ef71881 100644 --- a/nova/tests/baremetal/test_driver.py +++ b/nova/tests/baremetal/test_driver.py @@ -136,6 +136,19 @@ class BareMetalDriverWithDBTestCase(bm_db_base.BMDBTestCase): row = db.bm_node_get(self.context, self.node['id']) self.assertEqual(row['task_state'], baremetal_states.ACTIVE) + def test_macs_for_instance(self): + self._create_node() + expected = set(['01:23:45:67:89:01', '01:23:45:67:89:02']) + self.assertEqual( + expected, self.driver.macs_for_instance(self.test_instance)) + + def test_macs_for_instance_no_interfaces(self): + # Nodes cannot boot with no MACs, so we raise an error if that happens. + self.nic_info = [] + self._create_node() + self.assertRaises(exception.NovaException, + self.driver.macs_for_instance, self.test_instance) + def test_spawn_node_in_use(self): self._create_node() db.bm_node_update(self.context, self.node['id'], diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py index 62c0dff70..9904fdcd4 100644 --- a/nova/virt/baremetal/driver.py +++ b/nova/virt/baremetal/driver.py @@ -201,6 +201,12 @@ class BareMetalDriver(driver.ComputeDriver): % instance['uuid']) return node_id + def macs_for_instance(self, instance): + context = nova_context.get_admin_context() + node_id = self._require_node(instance) + return set(iface['address'] for iface in + db.bm_interface_get_all_by_bm_node_id(context, node_id)) + def spawn(self, context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None): node_id = self._require_node(instance) -- cgit