From: chenying Date: Tue, 10 Nov 2015 07:17:57 +0000 (+0800) Subject: Use oslo_config new type PortOpt for port options X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7ef20e1b910498e5a7952ec373286e69485a8533;p=openstack-build%2Fcinder-build.git Use oslo_config new type PortOpt for port options The oslo_config library provides new type PortOpt to validate the range of port now. ref: https://github.com/openstack/oslo.config/blob/2.6.0/oslo_config/cfg.py#L1114 DocImpact Change-Id: I9a3e4d13feef67b4a43936c6099b822e4f1f6a57 Closes-Bug: #1514702 --- diff --git a/cinder/service.py b/cinder/service.py index 36dc390ba..237bae211 100644 --- a/cinder/service.py +++ b/cinder/service.py @@ -62,10 +62,9 @@ service_opts = [ cfg.StrOpt('osapi_volume_listen', default="0.0.0.0", help='IP address on which OpenStack Volume API listens'), - cfg.IntOpt('osapi_volume_listen_port', - default=8776, - min=1, max=65535, - help='Port on which OpenStack Volume API listens'), + cfg.PortOpt('osapi_volume_listen_port', + default=8776, + help='Port on which OpenStack Volume API listens'), cfg.IntOpt('osapi_volume_workers', help='Number of workers for OpenStack Volume API service. ' 'The default is equal to the number of CPUs available.'), ] diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py index df208ee35..a42b7bb04 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py @@ -93,8 +93,8 @@ class TestBrcdFCSanLookupService(brcd_lookup.BrcdFCSanLookupService, fc_fabric_opts.append(cfg.StrOpt('fc_fabric_password', default='password', help='', secret=True)) - fc_fabric_opts.append(cfg.IntOpt('fc_fabric_port', - default=22, help='')) + fc_fabric_opts.append(cfg.PortOpt('fc_fabric_port', + default=22, help='')) fc_fabric_opts.append(cfg.StrOpt('principal_switch_wwn', default='100000051e55a100', help='')) config = conf.Configuration(fc_fabric_opts, 'BRCD_FAB_2') diff --git a/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py index ff353b6b8..6ca16d33f 100644 --- a/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_cisco_fc_san_lookup_service.py @@ -70,8 +70,8 @@ class TestCiscoFCSanLookupService(cisco_lookup.CiscoFCSanLookupService, fc_fabric_opts.append(cfg.StrOpt('cisco_fc_fabric_password', default='admin1234', help='', secret=True)) - fc_fabric_opts.append(cfg.IntOpt('cisco_fc_fabric_port', - default=22, help='')) + fc_fabric_opts.append(cfg.PortOpt('cisco_fc_fabric_port', + default=22, help='')) fc_fabric_opts.append(cfg.StrOpt('cisco_zoning_vsan', default='304', help='')) config = conf.Configuration(fc_fabric_opts, 'CISCO_FAB_2') diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index bb6d08e69..9feed1454 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -58,10 +58,9 @@ volume_opts = [ cfg.ListOpt('iscsi_secondary_ip_addresses', default=[], help='The list of secondary IP addresses of the iSCSI daemon'), - cfg.IntOpt('iscsi_port', - default=3260, - min=1, max=65535, - help='The port that the iSCSI daemon is listening on'), + cfg.PortOpt('iscsi_port', + default=3260, + help='The port that the iSCSI daemon is listening on'), cfg.IntOpt('num_volume_device_scan_tries', default=3, help='The maximum number of times to rescan targets' @@ -258,10 +257,9 @@ iser_opts = [ cfg.StrOpt('iser_ip_address', default='$my_ip', help='The IP address that the iSER daemon is listening on'), - cfg.IntOpt('iser_port', - default=3260, - min=1, max=65535, - help='The port that the iSER daemon is listening on'), + cfg.PortOpt('iser_port', + default=3260, + help='The port that the iSER daemon is listening on'), cfg.StrOpt('iser_helper', default='tgtadm', help='The name of the iSER target user-land tool to use'), diff --git a/cinder/volume/drivers/dell/dell_storagecenter_common.py b/cinder/volume/drivers/dell/dell_storagecenter_common.py index 46299d347..61b66dee4 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_common.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_common.py @@ -29,10 +29,9 @@ common_opts = [ cfg.IntOpt('dell_sc_ssn', default=64702, help='Storage Center System Serial Number'), - cfg.IntOpt('dell_sc_api_port', - default=3033, - min=1, max=65535, - help='Dell API port'), + cfg.PortOpt('dell_sc_api_port', + default=3033, + help='Dell API port'), cfg.StrOpt('dell_sc_server_folder', default='openstack', help='Name of the server folder to use on the Storage Center'), diff --git a/cinder/volume/drivers/prophetstor/options.py b/cinder/volume/drivers/prophetstor/options.py index ff9768f7f..ec7364dda 100644 --- a/cinder/volume/drivers/prophetstor/options.py +++ b/cinder/volume/drivers/prophetstor/options.py @@ -21,10 +21,9 @@ DPL_OPTS = [ cfg.StrOpt('dpl_pool', default='', help='DPL pool uuid in which DPL volumes are stored.'), - cfg.IntOpt('dpl_port', - default=8357, - min=1, max=65535, - help='DPL port number.'), + cfg.PortOpt('dpl_port', + default=8357, + help='DPL port number.'), ] CONF = cfg.CONF diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index 4bb5d65af..cc27c46df 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -49,10 +49,9 @@ nas_opts = [ default='', help='Password to connect to NAS system.', secret=True), - cfg.IntOpt('nas_ssh_port', - default=22, - min=1, max=65535, - help='SSH port to use to connect to NAS system.'), + cfg.PortOpt('nas_ssh_port', + default=22, + help='SSH port to use to connect to NAS system.'), cfg.StrOpt('nas_private_key', default='', help='Filename of private key to use for SSH authentication.'), diff --git a/cinder/volume/drivers/san/san.py b/cinder/volume/drivers/san/san.py index 6c6df1cc4..e6946fdd6 100644 --- a/cinder/volume/drivers/san/san.py +++ b/cinder/volume/drivers/san/san.py @@ -55,10 +55,9 @@ san_opts = [ cfg.StrOpt('san_clustername', default='', help='Cluster name to use for creating volumes'), - cfg.IntOpt('san_ssh_port', - default=22, - min=1, max=65535, - help='SSH port to use with SAN'), + cfg.PortOpt('san_ssh_port', + default=22, + help='SSH port to use with SAN'), cfg.BoolOpt('san_is_local', default=False, help='Execute commands locally instead of over SSH; ' diff --git a/cinder/volume/drivers/sheepdog.py b/cinder/volume/drivers/sheepdog.py index b41c1b26e..f29a61acb 100644 --- a/cinder/volume/drivers/sheepdog.py +++ b/cinder/volume/drivers/sheepdog.py @@ -43,10 +43,9 @@ sheepdog_opts = [ cfg.StrOpt('sheepdog_store_address', default='127.0.0.1', help=('IP address of sheep daemon.')), - cfg.IntOpt('sheepdog_store_port', - min=1, max=65535, - default=7000, - help=('Port of sheep daemon.')) + cfg.PortOpt('sheepdog_store_port', + default=7000, + help=('Port of sheep daemon.')) ] CONF = cfg.CONF diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index d18ec5c27..0bac423a9 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -84,12 +84,10 @@ sf_opts = [ 'memory, very large deployments may want to consider ' 'setting to False.'), - cfg.IntOpt('sf_api_port', - default=443, - min=1, max=65535, - help='SolidFire API port. Useful if the device api is behind ' - 'a proxy on a different port.')] - + cfg.PortOpt('sf_api_port', + default=443, + help='SolidFire API port. Useful if the device api is behind ' + 'a proxy on a different port.')] CONF = cfg.CONF CONF.register_opts(sf_opts) diff --git a/cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py b/cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py index ec311f87b..1328bb1ba 100644 --- a/cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py +++ b/cinder/zonemanager/drivers/brocade/brcd_fabric_opts.py @@ -31,10 +31,9 @@ brcd_zone_opts = [ default='', help='Password for user', secret=True), - cfg.IntOpt('fc_fabric_port', - default=22, - min=1, max=65535, - help='Connecting port'), + cfg.PortOpt('fc_fabric_port', + default=22, + help='Connecting port'), cfg.StrOpt('zoning_policy', default='initiator-target', help='overridden zoning policy'), diff --git a/cinder/zonemanager/drivers/cisco/cisco_fabric_opts.py b/cinder/zonemanager/drivers/cisco/cisco_fabric_opts.py index b29b408d5..524dcc1e9 100644 --- a/cinder/zonemanager/drivers/cisco/cisco_fabric_opts.py +++ b/cinder/zonemanager/drivers/cisco/cisco_fabric_opts.py @@ -28,10 +28,9 @@ cisco_zone_opts = [ default='', help='Password for user', secret=True), - cfg.IntOpt('cisco_fc_fabric_port', - default=22, - min=1, max=65535, - help='Connecting port'), + cfg.PortOpt('cisco_fc_fabric_port', + default=22, + help='Connecting port'), cfg.StrOpt('cisco_zoning_policy', default='initiator-target', help='overridden zoning policy'),