Use HostAddressOpt for opts that accept IP and hostnames

Some configuration options were accepting both IP addresses
and hostnames. Since there was no specific OSLO opt type to
support this, we were using ``StrOpt``. The change [1] that
added support for ``HostAddressOpt`` type was merged in Ocata
and became available for use with oslo version 3.22.

This patch changes the opt type of configuration options to use
this more relevant opt type - HostAddressOpt.

[1] I77bdb64b7e6e56ce761d76696bc4448a9bd325eb

TrivialFix

Change-Id: I44ba478ff14a6184434dd030efd9b7fa92458c7a
This commit is contained in:
luqitao 2017-03-16 04:54:15 -04:00
parent 80b54ad59d
commit 86a1bc189c
18 changed files with 66 additions and 63 deletions

View File

@ -58,10 +58,10 @@ CONF.register_cli_opts(core_opts)
CONF.register_cli_opts(debug_opts)
global_opts = [
cfg.StrOpt('my_ip',
default=netutils.get_my_ipv4(),
sample_default='<your_ip>',
help='IP address of this host.'),
cfg.HostAddressOpt('my_ip',
default=netutils.get_my_ipv4(),
sample_default='<your_ip>',
help='IP address of this host.'),
cfg.StrOpt('scheduler_topic',
default='manila-scheduler',
help='The topic scheduler nodes listen on.'),
@ -107,11 +107,12 @@ global_opts = [
cfg.StrOpt('data_manager',
default='manila.data.manager.DataManager',
help='Full class name for the data manager.'),
cfg.StrOpt('host',
default=socket.gethostname(),
sample_default='<your_hostname>',
help='Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address.'),
cfg.HostAddressOpt('host',
default=socket.gethostname(),
sample_default='<your_hostname>',
help='Name of this node. This can be an opaque '
'identifier. It is not necessarily a hostname, '
'FQDN, or IP address.'),
# NOTE(vish): default to nova for compatibility with nova installs
cfg.StrOpt('storage_availability_zone',
default='nova',

View File

@ -51,9 +51,10 @@ service_opts = [
help='Range of seconds to randomly delay when starting the '
'periodic task scheduler to reduce stampeding. '
'(Disable by setting to 0)'),
cfg.StrOpt('osapi_share_listen',
default="::",
help='IP address for OpenStack Share API to listen on.'),
cfg.HostAddressOpt('osapi_share_listen',
default="::",
help='IP address for OpenStack Share API to listen '
'on.'),
cfg.PortOpt('osapi_share_listen_port',
default=8786,
help='Port for OpenStack Share API to listen on.'),

View File

@ -30,8 +30,8 @@ EMC_NAS_OPTS = [
help='User name for the EMC server.'),
cfg.StrOpt('emc_nas_password',
help='Password for the EMC server.'),
cfg.StrOpt('emc_nas_server',
help='EMC server hostname or IP address.'),
cfg.HostAddressOpt('emc_nas_server',
help='EMC server hostname or IP address.'),
cfg.PortOpt('emc_nas_server_port',
default=8080,
help='Port number for the EMC server.'),

View File

@ -45,8 +45,8 @@ GlusterfsManilaShare_opts = [
default='Gluster',
help='Type of NFS server that mediate access to the Gluster '
'volumes (Gluster or Ganesha).'),
cfg.StrOpt('glusterfs_ganesha_server_ip',
help="Remote Ganesha server node's IP address."),
cfg.HostAddressOpt('glusterfs_ganesha_server_ip',
help="Remote Ganesha server node's IP address."),
cfg.StrOpt('glusterfs_ganesha_server_username',
default='root',
help="Remote Ganesha server node's username."),

View File

@ -44,8 +44,8 @@ from manila import utils
LOG = log.getLogger(__name__)
hdfs_native_share_opts = [
cfg.StrOpt('hdfs_namenode_ip',
help='The IP of the HDFS namenode.'),
cfg.HostAddressOpt('hdfs_namenode_ip',
help='The IP of the HDFS namenode.'),
cfg.PortOpt('hdfs_namenode_port',
default=9000,
help='The port of HDFS namenode service.'),

View File

@ -30,10 +30,10 @@ from manila.share import utils
LOG = log.getLogger(__name__)
hitachi_hnas_opts = [
cfg.StrOpt('hitachi_hnas_ip',
deprecated_name='hds_hnas_ip',
help="HNAS management interface IP for communication "
"between Manila controller and HNAS."),
cfg.HostAddressOpt('hitachi_hnas_ip',
deprecated_name='hds_hnas_ip',
help="HNAS management interface IP for communication "
"between Manila controller and HNAS."),
cfg.StrOpt('hitachi_hnas_user',
deprecated_name='hds_hnas_user',
help="HNAS username Base64 String in order to perform tasks "
@ -46,11 +46,12 @@ hitachi_hnas_opts = [
cfg.IntOpt('hitachi_hnas_evs_id',
deprecated_name='hds_hnas_evs_id',
help="Specify which EVS this backend is assigned to."),
cfg.StrOpt('hitachi_hnas_evs_ip',
deprecated_name='hds_hnas_evs_ip',
help="Specify IP for mounting shares."),
cfg.StrOpt('hitachi_hnas_admin_network_ip',
help="Specify IP for mounting shares in the Admin network."),
cfg.HostAddressOpt('hitachi_hnas_evs_ip',
deprecated_name='hds_hnas_evs_ip',
help="Specify IP for mounting shares."),
cfg.HostAddressOpt('hitachi_hnas_admin_network_ip',
help="Specify IP for mounting shares in the Admin "
"network."),
cfg.StrOpt('hitachi_hnas_file_system_name',
deprecated_name='hds_hnas_file_system_name',
help="Specify file-system name for creating shares."),
@ -59,10 +60,10 @@ hitachi_hnas_opts = [
secret=True,
help="RSA/DSA private key value used to connect into HNAS. "
"Required only if password is not provided."),
cfg.StrOpt('hitachi_hnas_cluster_admin_ip0',
deprecated_name='hds_hnas_cluster_admin_ip0',
help="The IP of the clusters admin node. Only set in HNAS "
"multinode clusters."),
cfg.HostAddressOpt('hitachi_hnas_cluster_admin_ip0',
deprecated_name='hds_hnas_cluster_admin_ip0',
help="The IP of the clusters admin node. Only set in "
"HNAS multinode clusters."),
cfg.IntOpt('hitachi_hnas_stalled_job_timeout',
deprecated_name='hds_hnas_stalled_job_timeout',
default=30,

View File

@ -27,10 +27,10 @@ from manila.share.drivers.hitachi.hsp import rest
LOG = log.getLogger(__name__)
hitachi_hsp_opts = [
cfg.StrOpt('hitachi_hsp_host',
required=True,
help="HSP management host for communication between Manila "
"controller and HSP."),
cfg.HostAddressOpt('hitachi_hsp_host',
required=True,
help="HSP management host for communication between "
"Manila controller and HSP."),
cfg.StrOpt('hitachi_hsp_username',
required=True,
help="HSP username to perform tasks such as create filesystems"

View File

@ -132,10 +132,9 @@ HPE3PAR_OPTS = [
help="3PAR password for the user specified in hpe3par_username",
secret=True,
deprecated_name='hp3par_password'),
cfg.StrOpt('hpe3par_san_ip',
default='',
help="IP address of SAN controller",
deprecated_name='hp3par_san_ip'),
cfg.HostAddressOpt('hpe3par_san_ip',
help="IP address of SAN controller",
deprecated_name='hp3par_san_ip'),
cfg.StrOpt('hpe3par_san_login',
default='',
help="Username for SAN controller",

View File

@ -60,8 +60,8 @@ AVPATTERN = re.compile(r'\s*(?P<attr>\w+)\s*=\s*(?P<val>'
ERR_FILE_NOT_FOUND = 2
gpfs_share_opts = [
cfg.StrOpt('gpfs_share_export_ip',
help='IP to be added to GPFS export string.'),
cfg.HostAddressOpt('gpfs_share_export_ip',
help='IP to be added to GPFS export string.'),
cfg.StrOpt('gpfs_mount_point_base',
default='$state_path/mnt',
help='Base folder where exported shares are located.'),

View File

@ -30,9 +30,10 @@ netapp_proxy_opts = [
'clustered Data ONTAP.')), ]
netapp_connection_opts = [
cfg.StrOpt('netapp_server_hostname',
deprecated_name='netapp_nas_server_hostname',
help='The hostname (or IP address) for the storage system.'),
cfg.HostAddressOpt('netapp_server_hostname',
deprecated_name='netapp_nas_server_hostname',
help='The hostname (or IP address) for the storage '
'system.'),
cfg.PortOpt('netapp_server_port',
help=('The TCP port to use for communication with the storage '
'system or proxy server. If not specified, Data ONTAP '

View File

@ -23,8 +23,8 @@
from oslo_config import cfg
nexenta_connection_opts = [
cfg.StrOpt('nexenta_host',
help='IP address of Nexenta storage appliance.'),
cfg.HostAddressOpt('nexenta_host',
help='IP address of Nexenta storage appliance.'),
cfg.IntOpt('nexenta_rest_port',
default=8457,
help='Port to connect to Nexenta REST API server.'),

View File

@ -37,9 +37,9 @@ qnap_manila_opts = [
cfg.StrOpt('qnap_management_url',
required=True,
help='The URL to manage QNAP Storage.'),
cfg.StrOpt('qnap_share_ip',
required=True,
help='NAS share IP for mounting shares.'),
cfg.HostAddressOpt('qnap_share_ip',
required=True,
help='NAS share IP for mounting shares.'),
cfg.StrOpt('qnap_nas_login',
required=True,
help='Username for QNAP storage.'),

View File

@ -125,13 +125,13 @@ no_share_servers_handling_mode_opts = [
"service_instance_name_or_id",
help="Name or ID of service instance in Nova to use for share "
"exports. Used only when share servers handling is disabled."),
cfg.StrOpt(
cfg.HostAddressOpt(
"service_net_name_or_ip",
help="Can be either name of network that is used by service "
"instance within Nova to get IP address or IP address itself "
"for managing shares there. "
"Used only when share servers handling is disabled."),
cfg.StrOpt(
cfg.HostAddressOpt(
"tenant_net_name_or_ip",
help="Can be either name of network that is used by service "
"instance within Nova to get IP address or IP address itself "

View File

@ -30,8 +30,8 @@ from manila.share import driver
from manila.share import utils as share_utils
tegile_opts = [
cfg.StrOpt('tegile_nas_server',
help='Tegile NAS server hostname or IP address.'),
cfg.HostAddressOpt('tegile_nas_server',
help='Tegile NAS server hostname or IP address.'),
cfg.StrOpt('tegile_nas_login',
help='User name for the Tegile NAS server.'),
cfg.StrOpt('tegile_nas_password',

View File

@ -41,11 +41,11 @@ from manila import utils
zfsonlinux_opts = [
cfg.StrOpt(
cfg.HostAddressOpt(
"zfs_share_export_ip",
required=True,
help="IP to be added to user-facing export location. Required."),
cfg.StrOpt(
cfg.HostAddressOpt(
"zfs_service_ip",
required=True,
help="IP to be added to admin-facing export location. Required."),

View File

@ -30,10 +30,10 @@ from manila.share.drivers.zfssa import zfssarest
ZFSSA_OPTS = [
cfg.StrOpt('zfssa_host',
help='ZFSSA management IP address.'),
cfg.StrOpt('zfssa_data_ip',
help='IP address for data.'),
cfg.HostAddressOpt('zfssa_host',
help='ZFSSA management IP address.'),
cfg.HostAddressOpt('zfssa_data_ip',
help='IP address for data.'),
cfg.StrOpt('zfssa_auth_user',
help='ZFSSA management authorized username.'),
cfg.StrOpt('zfssa_auth_password',

View File

@ -38,7 +38,7 @@ class ManilaCmdShareTestCase(test.TestCase):
self.mock_object(self.launcher, 'launch_service')
self.mock_object(self.launcher, 'wait')
self.server = manila_share.service.Service.create.return_value
fake_host = 'fake_host'
fake_host = 'fake.host'
CONF.set_override('enabled_share_backends', backends,
enforce_type=True)
CONF.set_override('host', fake_host, enforce_type=True)

View File

@ -60,7 +60,7 @@ class NetAppCDOTDataMotionTestCase(test.TestCase):
group=self.backend, enforce_type=True)
CONF.set_override("netapp_password", "fake_password",
group=self.backend, enforce_type=True)
CONF.set_override("netapp_server_hostname", "fake_hostname",
CONF.set_override("netapp_server_hostname", "fake.hostname",
group=self.backend, enforce_type=True)
CONF.set_override("netapp_server_port", 8866,
group=self.backend, enforce_type=True)
@ -72,7 +72,7 @@ class NetAppCDOTDataMotionTestCase(test.TestCase):
data_motion.get_client_for_backend(self.backend)
self.mock_cmode_client.assert_called_once_with(
hostname='fake_hostname', password='fake_password',
hostname='fake.hostname', password='fake_password',
username='fake_user', transport_type='https', port=8866,
trace=mock.ANY, vserver=None)
@ -86,7 +86,7 @@ class NetAppCDOTDataMotionTestCase(test.TestCase):
data_motion.get_client_for_backend(self.backend)
self.mock_cmode_client.assert_called_once_with(
hostname='fake_hostname', password='fake_password',
hostname='fake.hostname', password='fake_password',
username='fake_user', transport_type='https', port=8866,
trace=mock.ANY, vserver='fake_vserver')