From 9cead9457cf9c78bcae78ace62f2fcf0e20d448b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 22 Apr 2024 15:26:03 +0900 Subject: [PATCH] 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 --- ironic/conf/deploy.py | 9 ++++++--- ironic/conf/glance.py | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ironic/conf/deploy.py b/ironic/conf/deploy.py index ea4021c31b..3811ff6f56 100644 --- a/ironic/conf/deploy.py +++ b/ironic/conf/deploy.py @@ -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 " diff --git a/ironic/conf/glance.py b/ironic/conf/glance.py index 317f213bc1..54b5ada431 100644 --- a/ironic/conf/glance.py +++ b/ironic/conf/glance.py @@ -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". '