From 86a1bc189cda217404439ef6962858bf80c9fabd Mon Sep 17 00:00:00 2001 From: luqitao Date: Thu, 16 Mar 2017 04:54:15 -0400 Subject: [PATCH] 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 --- manila/common/config.py | 19 ++++++------- manila/service.py | 7 ++--- manila/share/drivers/dell_emc/driver.py | 4 +-- manila/share/drivers/glusterfs/__init__.py | 4 +-- manila/share/drivers/hdfs/hdfs_native.py | 4 +-- manila/share/drivers/hitachi/hnas/driver.py | 27 ++++++++++--------- manila/share/drivers/hitachi/hsp/driver.py | 8 +++--- manila/share/drivers/hpe/hpe_3par_driver.py | 7 +++-- manila/share/drivers/ibm/gpfs.py | 4 +-- manila/share/drivers/netapp/options.py | 7 ++--- manila/share/drivers/nexenta/options.py | 4 +-- manila/share/drivers/qnap/qnap.py | 6 ++--- manila/share/drivers/service_instance.py | 4 +-- manila/share/drivers/tegile/tegile.py | 4 +-- manila/share/drivers/zfsonlinux/driver.py | 4 +-- manila/share/drivers/zfssa/zfssashare.py | 8 +++--- manila/tests/cmd/test_share.py | 2 +- .../cluster_mode/test_data_motion.py | 6 ++--- 18 files changed, 66 insertions(+), 63 deletions(-) diff --git a/manila/common/config.py b/manila/common/config.py index f9abe9148e..bc4feb73e6 100644 --- a/manila/common/config.py +++ b/manila/common/config.py @@ -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='', - help='IP address of this host.'), + cfg.HostAddressOpt('my_ip', + default=netutils.get_my_ipv4(), + sample_default='', + 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='', - 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='', + 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', diff --git a/manila/service.py b/manila/service.py index a61f3e54c5..8382333e31 100644 --- a/manila/service.py +++ b/manila/service.py @@ -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.'), diff --git a/manila/share/drivers/dell_emc/driver.py b/manila/share/drivers/dell_emc/driver.py index f1c722944b..b5f9783372 100644 --- a/manila/share/drivers/dell_emc/driver.py +++ b/manila/share/drivers/dell_emc/driver.py @@ -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.'), diff --git a/manila/share/drivers/glusterfs/__init__.py b/manila/share/drivers/glusterfs/__init__.py index e26f531ec9..5f7140bd8f 100644 --- a/manila/share/drivers/glusterfs/__init__.py +++ b/manila/share/drivers/glusterfs/__init__.py @@ -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."), diff --git a/manila/share/drivers/hdfs/hdfs_native.py b/manila/share/drivers/hdfs/hdfs_native.py index 7ea4c61aaa..e183acb037 100644 --- a/manila/share/drivers/hdfs/hdfs_native.py +++ b/manila/share/drivers/hdfs/hdfs_native.py @@ -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.'), diff --git a/manila/share/drivers/hitachi/hnas/driver.py b/manila/share/drivers/hitachi/hnas/driver.py index 9be11c3a88..7f107b3991 100644 --- a/manila/share/drivers/hitachi/hnas/driver.py +++ b/manila/share/drivers/hitachi/hnas/driver.py @@ -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, diff --git a/manila/share/drivers/hitachi/hsp/driver.py b/manila/share/drivers/hitachi/hsp/driver.py index 6fc9e9e506..8af130ce9d 100644 --- a/manila/share/drivers/hitachi/hsp/driver.py +++ b/manila/share/drivers/hitachi/hsp/driver.py @@ -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" diff --git a/manila/share/drivers/hpe/hpe_3par_driver.py b/manila/share/drivers/hpe/hpe_3par_driver.py index 8aa40a279a..0d83952ce9 100644 --- a/manila/share/drivers/hpe/hpe_3par_driver.py +++ b/manila/share/drivers/hpe/hpe_3par_driver.py @@ -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", diff --git a/manila/share/drivers/ibm/gpfs.py b/manila/share/drivers/ibm/gpfs.py index 4d599a1471..cc8f4ec600 100644 --- a/manila/share/drivers/ibm/gpfs.py +++ b/manila/share/drivers/ibm/gpfs.py @@ -60,8 +60,8 @@ AVPATTERN = re.compile(r'\s*(?P\w+)\s*=\s*(?P' 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.'), diff --git a/manila/share/drivers/netapp/options.py b/manila/share/drivers/netapp/options.py index c1ad21644e..df483e8dec 100644 --- a/manila/share/drivers/netapp/options.py +++ b/manila/share/drivers/netapp/options.py @@ -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 ' diff --git a/manila/share/drivers/nexenta/options.py b/manila/share/drivers/nexenta/options.py index b82b6a6c7e..a5ac758983 100644 --- a/manila/share/drivers/nexenta/options.py +++ b/manila/share/drivers/nexenta/options.py @@ -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.'), diff --git a/manila/share/drivers/qnap/qnap.py b/manila/share/drivers/qnap/qnap.py index d85bf9c8c0..86227546f9 100644 --- a/manila/share/drivers/qnap/qnap.py +++ b/manila/share/drivers/qnap/qnap.py @@ -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.'), diff --git a/manila/share/drivers/service_instance.py b/manila/share/drivers/service_instance.py index 27b671d66c..d94aceb095 100644 --- a/manila/share/drivers/service_instance.py +++ b/manila/share/drivers/service_instance.py @@ -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 " diff --git a/manila/share/drivers/tegile/tegile.py b/manila/share/drivers/tegile/tegile.py index f75b18fb1d..95b965bad5 100644 --- a/manila/share/drivers/tegile/tegile.py +++ b/manila/share/drivers/tegile/tegile.py @@ -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', diff --git a/manila/share/drivers/zfsonlinux/driver.py b/manila/share/drivers/zfsonlinux/driver.py index 7f5d09d0f6..f870c8b103 100644 --- a/manila/share/drivers/zfsonlinux/driver.py +++ b/manila/share/drivers/zfsonlinux/driver.py @@ -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."), diff --git a/manila/share/drivers/zfssa/zfssashare.py b/manila/share/drivers/zfssa/zfssashare.py index 1b2d28746b..be8f120cba 100644 --- a/manila/share/drivers/zfssa/zfssashare.py +++ b/manila/share/drivers/zfssa/zfssashare.py @@ -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', diff --git a/manila/tests/cmd/test_share.py b/manila/tests/cmd/test_share.py index 81c5fa984e..ddca6915a3 100644 --- a/manila/tests/cmd/test_share.py +++ b/manila/tests/cmd/test_share.py @@ -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) diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py index 433efb15c6..57107b6fcd 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py @@ -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')