Create nic string for os-specific-params in PartitionInst class
Till now the String was generated and set from the driver class. This patch moves both actions into the PartitionInstance class. This allows us overwriting this method once we support another partition type (e.g. ssc). Change-Id: If535cbdcdf878f5e9e2f91d0f0d1128021efcbbc
This commit is contained in:
parent
d4a3e6a58b
commit
2548d56f95
|
@ -260,9 +260,8 @@ class DPMDriverInstanceTestCase(TestCase):
|
|||
@mock.patch.object(vm.PartitionInstance, 'launch')
|
||||
@mock.patch.object(vm.PartitionInstance, 'attach_hbas')
|
||||
@mock.patch.object(vm.PartitionInstance, 'properties')
|
||||
@mock.patch.object(driver.DPMDriver, '_get_nic_string_for_guest_os')
|
||||
def test_spawn_attach_nic(self, mock_prop, mock_attachHba, mock_launch,
|
||||
mock_hba_uri, mock_get_bprops, mock_nic_string):
|
||||
mock_hba_uri, mock_get_bprops):
|
||||
|
||||
cpc = self.client.cpcs.find(**{"object-id": "2"})
|
||||
self.dpmdriver._cpc = cpc
|
||||
|
@ -289,6 +288,11 @@ class DPMDriverInstanceTestCase(TestCase):
|
|||
self.assertEqual(nics[0].name, "OpenStack_Port_foo-id")
|
||||
self.assertEqual(nics[1].name, "OpenStack_Port_foo-id2")
|
||||
|
||||
self.assertIn("8001,0,aabbccddeeff;",
|
||||
partition.get_property("boot-os-specific-parameters"))
|
||||
self.assertIn("8002,0,112233445566;",
|
||||
partition.get_property("boot-os-specific-parameters"))
|
||||
|
||||
def test_list_instances(self):
|
||||
self.flags(host="fakemini")
|
||||
cpc = self.client.cpcs.find(**{"object-id": "3"})
|
||||
|
|
|
@ -222,6 +222,20 @@ class VmPartitionInstanceTestCase(TestCase):
|
|||
self.part_name,
|
||||
self.partition_inst.get_partition().get_property('name'))
|
||||
|
||||
def test__set_nic_string_in_os_specific_parameters(self):
|
||||
nic = mock.Mock()
|
||||
nic.get_property = lambda prop: {'device-number': 'devno'}[prop]
|
||||
|
||||
vif_obj = mock.Mock()
|
||||
vif_obj.mac = 'mac'
|
||||
|
||||
self.partition_inst._set_nic_string_in_os_specific_parameters(nic,
|
||||
vif_obj)
|
||||
|
||||
boot_os_params = self.partition_inst.partition.get_property(
|
||||
'boot-os-specific-parameters')
|
||||
self.assertIn('devno,0,mac;', boot_os_params)
|
||||
|
||||
def test__get_nic_properties_dict(self):
|
||||
cfg.CONF.set_override("host", "subset")
|
||||
vif = mock.Mock()
|
||||
|
|
|
@ -281,42 +281,6 @@ class DPMDriver(driver.ComputeDriver):
|
|||
"""
|
||||
self.prep_for_spawn(context=None, instance=instance)
|
||||
|
||||
def _get_nic_string_for_guest_os(self, nic, vif_obj):
|
||||
"""Generate the NIC string that must be available from inside the OS
|
||||
|
||||
Passing the string into the operating system is achieved via appending
|
||||
it to the partitions boot-os-specific-parameters property.
|
||||
The value of this property will then be appended to the kernels cmdline
|
||||
and be accessible from within the instance under /proc/cmdline.
|
||||
It is ignored by the Linux Boot process but can be parsed by
|
||||
other userspace tools and scripts.
|
||||
|
||||
This allows the following operations to be done from within the
|
||||
Instance/Partitions Operating System:
|
||||
|
||||
* Replace the z Systems Firmware generated MAC address
|
||||
of the NIC with the one generated from Neutron. The MAC can be
|
||||
removed from this parameter once it is possible to set the correct
|
||||
MAC right on DPM NIC creation.
|
||||
|
||||
* Configure the physical network adapter port to be used.
|
||||
The port number can be removed once Linux is able to get this
|
||||
information via a different channel.
|
||||
"""
|
||||
# Format: <dev-no>,<port-no>,<mac>;
|
||||
# <devno>: The DPM device number
|
||||
# <port-no>: The network adapters port that should be usd
|
||||
# <mac>: MAC address without deliminator. This saves 5 additional
|
||||
# characters in the limited boot-os-specific-parameters property
|
||||
# Example: 0001,1,aabbccddeeff;
|
||||
# TODO(andreas_s): Update <port-no> once provided by Neutron. Till
|
||||
# then default to 0
|
||||
nic_boot_parms = "{devno},0,{mac};".format(
|
||||
devno=nic.get_property("device-number"),
|
||||
mac=vif_obj.mac.replace(":", "")
|
||||
)
|
||||
return nic_boot_parms
|
||||
|
||||
def prep_for_spawn(self, context, instance,
|
||||
flavor=None):
|
||||
|
||||
|
@ -357,9 +321,7 @@ class DPMDriver(driver.ComputeDriver):
|
|||
))
|
||||
for vif_dict in network_info:
|
||||
vif_obj = DPMVIF(vif_dict)
|
||||
nic = inst.attach_nic(vif_obj)
|
||||
inst.append_to_boot_os_specific_parameters(
|
||||
self._get_nic_string_for_guest_os(nic, vif_obj))
|
||||
inst.attach_nic(vif_obj)
|
||||
|
||||
inst.set_boot_properties(
|
||||
self._get_block_device_mapping(block_device_info))
|
||||
|
|
|
@ -174,6 +174,43 @@ class PartitionInstance(object):
|
|||
'boot-os-specific-parameters': new_data
|
||||
})
|
||||
|
||||
def _set_nic_string_in_os_specific_parameters(self, nic, vif_obj):
|
||||
"""Generate the NIC string that must be available from inside the OS
|
||||
|
||||
Passing the string into the operating system is achieved via appending
|
||||
it to the partitions boot-os-specific-parameters property.
|
||||
The value of this property will then be appended to the kernels cmdline
|
||||
and be accessible from within the instance under /proc/cmdline.
|
||||
It is ignored by the Linux Boot process but can be parsed by
|
||||
other userspace tools and scripts.
|
||||
|
||||
This allows the following operations to be done from within the
|
||||
Instance/Partitions Operating System:
|
||||
|
||||
* Replace the z Systems Firmware generated MAC address
|
||||
of the NIC with the one generated from Neutron. The MAC can be
|
||||
removed from this parameter once it is possible to set the correct
|
||||
MAC right on DPM NIC creation.
|
||||
|
||||
* Configure the physical network adapter port to be used.
|
||||
The port number can be removed once Linux is able to get this
|
||||
information via a different channel.
|
||||
"""
|
||||
# Format: <space><dev-no>,<port-no>,<mac>;
|
||||
# <space>: A space to ensure separation from other parameters
|
||||
# <devno>: The DPM device number
|
||||
# <port-no>: The network adapters port that should be usd
|
||||
# <mac>: MAC address without deliminator. This saves 5 additional
|
||||
# characters in the limited boot-os-specific-parameters property
|
||||
# Example: 0001,1,aabbccddeeff;
|
||||
# TODO(andreas_s): Update <port-no> once provided by Neutron. Till
|
||||
# then default to 0
|
||||
nic_boot_parms = "{devno},0,{mac};".format(
|
||||
devno=nic.get_property("device-number"),
|
||||
mac=vif_obj.mac.replace(":", "")
|
||||
)
|
||||
self.append_to_boot_os_specific_parameters(nic_boot_parms)
|
||||
|
||||
@staticmethod
|
||||
def _get_nic_properties_dict(vif_obj):
|
||||
return {
|
||||
|
@ -199,6 +236,7 @@ class PartitionInstance(object):
|
|||
LOG.debug("NIC created successfully %s with URI %s",
|
||||
nic_interface.properties['name'],
|
||||
nic_interface.properties['virtual-switch-uri'])
|
||||
self._set_nic_string_in_os_specific_parameters(nic_interface, vif_obj)
|
||||
return nic_interface
|
||||
|
||||
def attach_hbas(self):
|
||||
|
|
Loading…
Reference in New Issue