Merge "Use cfg.URIOpt for URLs with required schemes"

This commit is contained in:
Jenkins 2017-05-26 02:42:21 +00:00 committed by Gerrit Code Review
commit dbe6800a13
3 changed files with 7 additions and 13 deletions

View File

@ -974,7 +974,7 @@
# URL for connecting to cinder. If set, the value must start # URL for connecting to cinder. If set, the value must start
# with either http:// or https://. This option is part of # with either http:// or https://. This option is part of
# boot-from-volume work, which is not currently exposed to # boot-from-volume work, which is not currently exposed to
# users. (string value) # users. (uri value)
#url = <None> #url = <None>
# User's domain id (string value) # User's domain id (string value)
@ -1023,7 +1023,7 @@
# URL of Ironic API service. If not set ironic can get the # URL of Ironic API service. If not set ironic can get the
# current value from the keystone service catalog. If set, 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) # value)
#api_url = <None> #api_url = <None>

View File

@ -17,8 +17,8 @@ from ironic.common.i18n import _
from ironic.conf import auth from ironic.conf import auth
opts = [ opts = [
cfg.StrOpt('url', cfg.URIOpt('url',
regex='^http(s?):\/\/.+', schemes=('http', 'https'),
help=_('URL for connecting to cinder. If set, the value must ' help=_('URL for connecting to cinder. If set, the value must '
'start with either http:// or https://. This option is ' 'start with either http:// or https://. This option is '
'part of boot-from-volume work, which is not currently ' 'part of boot-from-volume work, which is not currently '
@ -47,10 +47,4 @@ def register_opts(conf):
def list_opts(): def list_opts():
# NOTE(jtaryma): Function add_auth_opts uses deepcopy on passed array. return auth.add_auth_opts(opts)
# 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

View File

@ -28,8 +28,8 @@ opts = [
cfg.IntOpt('heartbeat_interval', cfg.IntOpt('heartbeat_interval',
default=10, default=10,
help=_('Seconds between conductor heart beats.')), help=_('Seconds between conductor heart beats.')),
cfg.StrOpt('api_url', cfg.URIOpt('api_url',
regex='^http(s?):\/\/.+', schemes=('http', 'https'),
help=_('URL of Ironic API service. If not set ironic can ' help=_('URL of Ironic API service. If not set ironic can '
'get the current value from the keystone service ' 'get the current value from the keystone service '
'catalog. If set, the value must start with either ' 'catalog. If set, the value must start with either '