Validate url options at config input layer

oslo.config provides the URIOpt class which enforces valid URI(URL)
format. Use this built-in feature to detect any malformed values for
better feedback.

Change-Id: I0d846f78f8132a2d63266b7b3331ec7118cea1b4
This commit is contained in:
Takashi Kajinami 2024-04-22 15:26:03 +09:00
parent d68aea2ebe
commit 9cead9457c
2 changed files with 8 additions and 4 deletions

View File

@ -21,7 +21,8 @@ from ironic.common.i18n import _
opts = [
cfg.StrOpt('http_url',
cfg.URIOpt('http_url',
schemes=['http', 'https'],
help=_("ironic-conductor node's HTTP server URL. "
"Example: http://192.1.2.3:8080")),
cfg.StrOpt('http_root',
@ -51,13 +52,15 @@ opts = [
help=_("Can be used by any authentication strategy that "
"requires password credential. Currently utilized by "
"the http_basic authentication strategy.")),
cfg.StrOpt('external_http_url',
cfg.URIOpt('external_http_url',
schemes=['http', 'https'],
help=_("URL of the ironic-conductor node's HTTP server for "
"boot methods such as virtual media, "
"where images could be served outside of the "
"provisioning network. Does not apply when Swift is "
"used. Defaults to http_url.")),
cfg.StrOpt('external_callback_url',
cfg.URIOpt('external_callback_url',
schemes=['http', 'https'],
help=_("Agent callback URL of the bare metal API for boot "
"methods such as virtual media, where images could be "
"served outside of the provisioning network. Defaults "

View File

@ -64,8 +64,9 @@ opts = [
'download starts. swift_temp_url_duration value must be '
'greater than or equal to this option\'s value. '
'Defaults to 0.')),
cfg.StrOpt(
cfg.URIOpt(
'swift_endpoint_url',
schemes=['http', 'https'],
help=_('The "endpoint" (scheme, hostname, optional port) for '
'the Swift URL of the form '
'"endpoint_url/api_version/account/container/object_id". '