Use oslo opt for storage_adapter_mappings
Use the oslo config opt object for the 'physical_storage_adapter_mappings' configuration option. This configuration option returns a list of tuples: [(adapter-id, port-id), (adapter-id, port-id)] In addition it validates if the adapter-id is of the right format. If provided in upper case, it will convert it to lower case (HMC web services API requires lower case). The config option does not check if an object with this ID exists on the HMC. Also the port value is verified. Valid values are '0', '1', '2', '3'. adapter-id and port can never be 'None'. The usage of parse_config_line will be replaced by this config option. Change-Id: Ica7928e1eded0350dcc708eed932e9b7a5401bfc Partial-Bug: #1663369
This commit is contained in:
parent
e80b98be20
commit
cacafd8819
|
@ -15,6 +15,7 @@
|
|||
from os_dpm.config import config as os_dpm_conf
|
||||
from oslo_config import cfg
|
||||
|
||||
from nova_dpm.conf.cfg import MultiStorageAdapterMappingOpt
|
||||
|
||||
os_dpm_conf.DPM_GROUP.help += """
|
||||
|
||||
|
@ -36,7 +37,7 @@ ALL_DPM_OPTS = [
|
|||
cfg.IntOpt('max_instances', help="""
|
||||
Maximum number of instances (partitions) that can be created for this
|
||||
OpenStack hypervisor host"""),
|
||||
cfg.MultiStrOpt('physical_storage_adapter_mappings', help="""
|
||||
MultiStorageAdapterMappingOpt('physical_storage_adapter_mappings', help="""
|
||||
Physical storage adapter with port details for hba creation"""),
|
||||
cfg.ListOpt('target_wwpn_ignore_list', default='', help="""
|
||||
list of target/remote wwpns can be used for example to exclude NAS/file
|
||||
|
|
|
@ -218,7 +218,6 @@ class DPMDriverInstanceTestCase(TestCase):
|
|||
cpc = self.client.cpcs.find(**{"object-id": "2"})
|
||||
self.dpmdriver._cpc = cpc
|
||||
self.flags(host="fake-mini")
|
||||
self.flags(group="dpm", physical_storage_adapter_mappings="mapping")
|
||||
|
||||
mock_instance = mock.Mock()
|
||||
mock_instance.uuid = "1"
|
||||
|
|
|
@ -221,11 +221,9 @@ class PartitionInstance(object):
|
|||
|
||||
def get_adapter_port_mappings(self):
|
||||
LOG.debug('Creating Adapter uris')
|
||||
interface_mappings = CONF.dpm.physical_storage_adapter_mappings
|
||||
mapping = PhysicalAdapterModel(self.cpc)
|
||||
for entry in interface_mappings:
|
||||
adapter_uuid, port = (
|
||||
PhysicalAdapterModel.parse_config_line(entry))
|
||||
for entry in CONF.dpm.physical_storage_adapter_mappings:
|
||||
adapter_uuid, port = entry
|
||||
adapter = mapping._get_adapter(adapter_uuid)
|
||||
mapping._validate_adapter_type(adapter)
|
||||
mapping._add_adapter_port(adapter_uuid, port)
|
||||
|
@ -251,15 +249,8 @@ class PartitionInstance(object):
|
|||
|
||||
def get_boot_hba_uri(self):
|
||||
hbas = self.get_hba_uris()
|
||||
|
||||
adapter_uuid, port = (
|
||||
PhysicalAdapterModel.parse_config_line(
|
||||
# As because we are using multiple
|
||||
# storage in configuration. So
|
||||
# we will use one i.e first adapter
|
||||
# in the list
|
||||
CONF.dpm.physical_storage_adapter_mappings[0]))
|
||||
|
||||
# Using the first adapter in the config option for boot
|
||||
adapter_uuid, port = CONF.dpm.physical_storage_adapter_mappings[0]
|
||||
hba_uri = None
|
||||
|
||||
for hba in hbas:
|
||||
|
@ -489,14 +480,3 @@ class PhysicalAdapterModel(object):
|
|||
:return: list of adapter_port dict
|
||||
"""
|
||||
return self._adapter_ports
|
||||
|
||||
@staticmethod
|
||||
def parse_config_line(line):
|
||||
result = line.split(":")
|
||||
adapter_id = result[0]
|
||||
# If no port-element-id was defined, default to 0
|
||||
# result[1] can also be '' - handled by 'and result[1]'
|
||||
port = int(result[1] if len(result) == 2 and result[1] else 0)
|
||||
LOG.debug('Adapter ID: %(adapterid)s and Port: %(port)s'
|
||||
% {"adapterid": str(adapter_id), "port": str(port)})
|
||||
return adapter_id, port
|
||||
|
|
Loading…
Reference in New Issue