summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2017-05-24 11:05:08 +0000
committerPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2017-05-24 11:08:52 +0000
commit13d91bd7b43e0e1a931fe6b5f7338a64b627ff50 (patch)
tree05fbdd699d6d3bfe74eb086c8c1a7433276ea49a
parent3ea37717767c54203a088177e4fee3df16663cf2 (diff)
downloadironic-13d91bd7b43e0e1a931fe6b5f7338a64b627ff50.tar.gz
Use cfg.URIOpt for URLs with required schemes
instead of specifying URL config options as StrOpt + regex enforcing the string starting with 'http://' or 'https://'. URIOpt is already available in minimal version of oslo.config that is required by ironic. Change-Id: I47089e215f730b3990004a66e0f35262a5f9d9bd
-rw-r--r--etc/ironic/ironic.conf.sample4
-rw-r--r--ironic/conf/cinder.py12
-rw-r--r--ironic/conf/conductor.py4
3 files changed, 7 insertions, 13 deletions
diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample
index c8e7bcd71..1e3c1aaff 100644
--- a/etc/ironic/ironic.conf.sample
+++ b/etc/ironic/ironic.conf.sample
@@ -974,7 +974,7 @@
# URL for connecting to cinder. If set, the value must start
# with either http:// or https://. This option is part of
# boot-from-volume work, which is not currently exposed to
-# users. (string value)
+# users. (uri value)
#url = <None>
# User's domain id (string value)
@@ -1023,7 +1023,7 @@
# URL of Ironic API service. If not set ironic can get the
# current value from the keystone service catalog. If set, the
-# value must start with either http:// or https://. (string
+# value must start with either http:// or https://. (uri
# value)
#api_url = <None>
diff --git a/ironic/conf/cinder.py b/ironic/conf/cinder.py
index 67460674a..b9f912174 100644
--- a/ironic/conf/cinder.py
+++ b/ironic/conf/cinder.py
@@ -17,8 +17,8 @@ from ironic.common.i18n import _
from ironic.conf import auth
opts = [
- cfg.StrOpt('url',
- regex='^http(s?):\/\/.+',
+ cfg.URIOpt('url',
+ schemes=('http', 'https'),
help=_('URL for connecting to cinder. If set, the value must '
'start with either http:// or https://. This option is '
'part of boot-from-volume work, which is not currently '
@@ -47,10 +47,4 @@ def register_opts(conf):
def list_opts():
- # NOTE(jtaryma): Function add_auth_opts uses deepcopy on passed array.
- # Since deepcopy does not support regex, to enable regex
- # protocol restriction for 'url' option, empty array is
- # passed. The result is appended to opts array and resorted.
- cinder_opts = opts + auth.add_auth_opts([])
- cinder_opts.sort(key=lambda x: x.name)
- return cinder_opts
+ return auth.add_auth_opts(opts)
diff --git a/ironic/conf/conductor.py b/ironic/conf/conductor.py
index a9846b088..b62cbd7f7 100644
--- a/ironic/conf/conductor.py
+++ b/ironic/conf/conductor.py
@@ -28,8 +28,8 @@ opts = [
cfg.IntOpt('heartbeat_interval',
default=10,
help=_('Seconds between conductor heart beats.')),
- cfg.StrOpt('api_url',
- regex='^http(s?):\/\/.+',
+ cfg.URIOpt('api_url',
+ schemes=('http', 'https'),
help=_('URL of Ironic API service. If not set ironic can '
'get the current value from the keystone service '
'catalog. If set, the value must start with either '