Changed connector protocols to use constants

Originally the protocols in the connector factory method were checked
against strings. This change moves those strings out as constants and
now compares against the constants.

These constants will be used by nova and cinder so the protocol values
aren't hard-coded when being used with os-brick.

Change-Id: I0942c352a8d46fc29565e9555f97f8e9d86cda36
Closes-Bug: #1479355
This commit is contained in:
Ryan Rossiter 2015-07-29 15:14:14 +00:00
parent 9751e78c2a
commit e9d3912c06
1 changed files with 22 additions and 10 deletions

View File

@ -61,6 +61,18 @@ MULTIPATH_ERROR_REGEX = re.compile("\w{3} \d+ \d\d:\d\d:\d\d \|.*$")
MULTIPATH_DEV_CHECK_REGEX = re.compile("\s+dm-\d+\s+")
MULTIPATH_PATH_CHECK_REGEX = re.compile("\s+\d+:\d+:\d+:\d+\s+")
ISCSI = "ISCSI"
ISER = "ISER"
FIBRE_CHANNEL = "FIBRE_CHANNEL"
AOE = "AOE"
NFS = "NFS"
GLUSTERFS = "GLUSTERFS"
LOCAL = "LOCAL"
HUAWEISDSHYPERVISOR = "HUAWEISDSHYPERVISOR"
HGST = "HGST"
RBD = "RBD"
SCALEIO = "SCALEIO"
def _check_multipathd_running(root_helper, enforce_multipath):
try:
@ -146,21 +158,21 @@ class InitiatorConnector(executor.Executor):
LOG.debug("Factory for %(protocol)s on %(arch)s",
{'protocol': protocol, 'arch': arch})
protocol = protocol.upper()
if protocol == "ISCSI":
if protocol == ISCSI:
return ISCSIConnector(root_helper=root_helper,
driver=driver,
execute=execute,
use_multipath=use_multipath,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "ISER":
elif protocol == ISER:
return ISERConnector(root_helper=root_helper,
driver=driver,
execute=execute,
use_multipath=use_multipath,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "FIBRE_CHANNEL":
elif protocol == FIBRE_CHANNEL:
if arch in (S390, S390X):
return FibreChannelConnectorS390X(
root_helper=root_helper,
@ -177,45 +189,45 @@ class InitiatorConnector(executor.Executor):
use_multipath=use_multipath,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "AOE":
elif protocol == AOE:
return AoEConnector(root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "NFS" or protocol == "GLUSTERFS":
elif protocol == NFS or protocol == GLUSTERFS:
return RemoteFsConnector(mount_type=protocol.lower(),
root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "LOCAL":
elif protocol == LOCAL:
return LocalConnector(root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "HUAWEISDSHYPERVISOR":
elif protocol == HUAWEISDSHYPERVISOR:
return HuaweiStorHyperConnector(
root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "HGST":
elif protocol == HGST:
return HGSTConnector(root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "RBD":
elif protocol == RBD:
return RBDConnector(root_helper=root_helper,
driver=driver,
execute=execute,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
elif protocol == "SCALEIO":
elif protocol == SCALEIO:
return ScaleIOConnector(
root_helper=root_helper,
driver=driver,