Remove obsolete baremetal override of MAC addresses.
Now that the hypervisor driver can specify what MAC addresses it needs, overriding the MAC address during bare metal instance provisioning is no longer appropriate. Change-Id: I2b0790753297104ddd40a410c8acb5fdac97ad15
This commit is contained in:
parent
05f445c1dc
commit
544bd10b76
|
@ -147,12 +147,6 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
|
|||
config = pxe.build_network_config(net)
|
||||
self.assertIn('eth0', config)
|
||||
self.assertNotIn('eth1', config)
|
||||
self.assertIn('hwaddress ether fake', config)
|
||||
self.assertNotIn('hwaddress ether aa:bb:cc:dd', config)
|
||||
|
||||
net[0][1]['mac'] = 'aa:bb:cc:dd'
|
||||
config = pxe.build_network_config(net)
|
||||
self.assertIn('hwaddress ether aa:bb:cc:dd', config)
|
||||
|
||||
net = utils.get_test_network_info(2)
|
||||
config = pxe.build_network_config(net)
|
||||
|
@ -306,15 +300,6 @@ class PXEPrivateMethodsTestCase(BareMetalPXETestCase):
|
|||
macs = self.driver._collect_mac_addresses(self.context, self.node)
|
||||
self.assertEqual(macs, address_list)
|
||||
|
||||
def test_generate_udev_rules(self):
|
||||
self._create_node()
|
||||
address_list = [nic['address'] for nic in self.nic_info]
|
||||
address_list.append(self.node_info['prov_mac_address'])
|
||||
|
||||
rules = self.driver._generate_udev_rules(self.context, self.node)
|
||||
for address in address_list:
|
||||
self.assertIn('ATTR{address}=="%s"' % address, rules)
|
||||
|
||||
def test_cache_tftp_images(self):
|
||||
self.instance['kernel_id'] = 'aaaa'
|
||||
self.instance['ramdisk_id'] = 'bbbb'
|
||||
|
@ -357,8 +342,6 @@ class PXEPrivateMethodsTestCase(BareMetalPXETestCase):
|
|||
# nova.virt.disk.api._inject_*_into_fs
|
||||
self._create_node()
|
||||
files = []
|
||||
files.append(('/etc/udev/rules.d/70-persistent-net.rules',
|
||||
self.driver._generate_udev_rules(self.context, self.node)))
|
||||
self.instance['hostname'] = 'fake hostname'
|
||||
files.append(('/etc/hostname', 'fake hostname'))
|
||||
self.instance['key_data'] = 'fake ssh key'
|
||||
|
|
|
@ -10,9 +10,6 @@ iface lo inet loopback
|
|||
#for $ifc in $interfaces
|
||||
auto ${ifc.name}
|
||||
iface ${ifc.name} inet dhcp
|
||||
#if $ifc.hwaddress
|
||||
hwaddress ether ${ifc.hwaddress}
|
||||
#end if
|
||||
|
||||
#if $use_ipv6
|
||||
iface ${ifc.name} inet6 dhcp
|
||||
|
|
|
@ -16,9 +16,6 @@ iface ${ifc.name} inet static
|
|||
#if $ifc.dns
|
||||
dns-nameservers ${ifc.dns}
|
||||
#end if
|
||||
#if $ifc.hwaddress
|
||||
hwaddress ether ${ifc.hwaddress}
|
||||
#end if
|
||||
|
||||
#if $use_ipv6
|
||||
iface ${ifc.name} inet6 static
|
||||
|
|
|
@ -121,7 +121,6 @@ def build_network_config(network_info):
|
|||
gateway_v6 = mapping['gateway_v6']
|
||||
interface = {
|
||||
'name': 'eth%d' % id,
|
||||
'hwaddress': mapping['mac'],
|
||||
'address': mapping['ips'][0]['ip'],
|
||||
'gateway': mapping['gateway'],
|
||||
'netmask': mapping['ips'][0]['netmask'],
|
||||
|
@ -238,27 +237,12 @@ class PXE(base.NodeDriver):
|
|||
super(PXE, self).__init__()
|
||||
|
||||
def _collect_mac_addresses(self, context, node):
|
||||
macs = []
|
||||
macs.append(db.bm_node_get(context, node['id'])['prov_mac_address'])
|
||||
macs = set()
|
||||
macs.add(db.bm_node_get(context, node['id'])['prov_mac_address'])
|
||||
for nic in db.bm_interface_get_all_by_bm_node_id(context, node['id']):
|
||||
if nic['address']:
|
||||
macs.append(nic['address'])
|
||||
macs.sort()
|
||||
return macs
|
||||
|
||||
def _generate_udev_rules(self, context, node):
|
||||
# TODO(deva): fix assumption that device names begin with "eth"
|
||||
# and fix assumption of ordering
|
||||
macs = self._collect_mac_addresses(context, node)
|
||||
rules = ''
|
||||
for (i, mac) in enumerate(macs):
|
||||
rules += 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ' \
|
||||
'ATTR{address}=="%(mac)s", ATTR{dev_id}=="0x0", ' \
|
||||
'ATTR{type}=="1", KERNEL=="eth*", NAME="%(name)s"\n' \
|
||||
% {'mac': mac.lower(),
|
||||
'name': 'eth%d' % i,
|
||||
}
|
||||
return rules
|
||||
macs.add(nic['address'])
|
||||
return sorted(macs)
|
||||
|
||||
def _cache_tftp_images(self, context, instance, image_info):
|
||||
"""Fetch the necessary kernels and ramdisks for the instance."""
|
||||
|
@ -330,9 +314,6 @@ class PXE(base.NodeDriver):
|
|||
injected_files = []
|
||||
|
||||
net_config = build_network_config(network_info)
|
||||
udev_rules = self._generate_udev_rules(context, node)
|
||||
injected_files.append(
|
||||
('/etc/udev/rules.d/70-persistent-net.rules', udev_rules))
|
||||
|
||||
if instance['hostname']:
|
||||
injected_files.append(('/etc/hostname', instance['hostname']))
|
||||
|
@ -385,7 +366,6 @@ class PXE(base.NodeDriver):
|
|||
config
|
||||
./pxelinux.cfg/
|
||||
{mac} -> ../{uuid}/config
|
||||
|
||||
"""
|
||||
image_info = get_tftp_image_info(instance)
|
||||
(root_mb, swap_mb) = get_partition_sizes(instance)
|
||||
|
|
Loading…
Reference in New Issue