summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/redfish/utils.py
diff options
context:
space:
mode:
authorDmitry Tantsur <divius.inside@gmail.com>2017-04-28 14:04:33 +0200
committerDmitry Tantsur <divius.inside@gmail.com>2017-04-28 14:04:33 +0200
commit40a50e1ee9c045ec73eadca78337b3e9e404ac48 (patch)
tree4a3ae3a69641ace5d18c719761b5eeca0521c024 /ironic/drivers/modules/redfish/utils.py
parent8fa488ccfca200e5719de44c72730ac9efb5889c (diff)
downloadironic-40a50e1ee9c045ec73eadca78337b3e9e404ac48.tar.gz
Bring the redfish driver address parameter closer to one of other drivers
All of the drivers assume driver_address is a host name or IP, but for redfish it's scheme://authority. This change allows to provide only host name here too. Change-Id: Id392b79375b37b8ca8be63bec4818b8d9a3982d4
Diffstat (limited to 'ironic/drivers/modules/redfish/utils.py')
-rw-r--r--ironic/drivers/modules/redfish/utils.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/ironic/drivers/modules/redfish/utils.py b/ironic/drivers/modules/redfish/utils.py
index c70fbfeb8..276da6e43 100644
--- a/ironic/drivers/modules/redfish/utils.py
+++ b/ironic/drivers/modules/redfish/utils.py
@@ -32,9 +32,9 @@ LOG = log.getLogger(__name__)
REQUIRED_PROPERTIES = {
'redfish_address': _('The URL address to the Redfish controller. It '
- 'should include scheme and authority portion of '
- 'the URL. For example: https://mgmt.vendor.com. '
- 'Required'),
+ 'must include the authority portion of the URL. '
+ 'If the scheme is missing, https is assumed. '
+ 'For example: https://mgmt.vendor.com. Required'),
'redfish_system_id': _('The canonical path to the ComputerSystem '
'resource that the driver will interact with. '
'It should include the root service, version and '
@@ -85,8 +85,18 @@ def parse_driver_info(node):
# Validate the Redfish address
address = driver_info['redfish_address']
- if not rfc3986.is_valid_uri(address, require_scheme=True,
- require_authority=True):
+ try:
+ parsed = rfc3986.uri_reference(address)
+ except TypeError:
+ raise exception.InvalidParameterValue(
+ _('Invalid Redfish address %(address)s set in '
+ 'driver_info/redfish_address on node %(node)s') %
+ {'address': address, 'node': node.uuid})
+
+ if not parsed.scheme or not parsed.authority:
+ address = 'https://%s' % address
+ parsed = rfc3986.uri_reference(address)
+ if not parsed.is_valid(require_scheme=True, require_authority=True):
raise exception.InvalidParameterValue(
_('Invalid Redfish address %(address)s set in '
'driver_info/redfish_address on node %(node)s') %