summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/redfish
diff options
context:
space:
mode:
authorTakashi Kajinami <tkajinam@redhat.com>2021-08-21 01:35:45 +0900
committerTakashi Kajinami <tkajinam@redhat.com>2021-08-21 01:49:26 +0900
commit197e07d3de36895f506abb43b19001e9c63b8329 (patch)
treecac81a6181d674d6478c22df9a6d74b2c6294a40 /ironic/drivers/modules/redfish
parentb77a76dd638542ce65352943dfa6833c8537bef2 (diff)
downloadironic-197e07d3de36895f506abb43b19001e9c63b8329.tar.gz
rfc3986: Replace deprecated URIReference.is_valid
The URIReference.is_valid method has been deprecated since rfc3986 1.1.0[1] and triggers the following deprecation warning. DeprecationWarning: Please use rfc3986.validators.Validator instead. This method will be eventually removed. [1] https://github.com/python-hyper/rfc3986/commit/fd19bd90 Change-Id: I256e42b8aa736b278bab6b4aa145a859aca10e17
Diffstat (limited to 'ironic/drivers/modules/redfish')
-rw-r--r--ironic/drivers/modules/redfish/utils.py10
-rw-r--r--ironic/drivers/modules/redfish/vendor.py10
2 files changed, 16 insertions, 4 deletions
diff --git a/ironic/drivers/modules/redfish/utils.py b/ironic/drivers/modules/redfish/utils.py
index 9915dba11..607de4366 100644
--- a/ironic/drivers/modules/redfish/utils.py
+++ b/ironic/drivers/modules/redfish/utils.py
@@ -108,8 +108,14 @@ def parse_driver_info(node):
if not parsed.scheme or not parsed.authority:
address = 'https://%s' % address
parsed = rfc3986.uri_reference(address)
- # TODO(vdrok): Workaround this check, in py3 we need to use validator class
- if not parsed.is_valid(require_scheme=True, require_authority=True):
+ validator = rfc3986.validators.Validator().require_presence_of(
+ 'scheme', 'host',
+ ).check_validity_of(
+ 'scheme', 'userinfo', 'host', 'path', 'query', 'fragment',
+ )
+ try:
+ validator.validate(parsed)
+ except rfc3986.exceptions.RFC3986Exception:
raise exception.InvalidParameterValue(
_('Invalid Redfish address %(address)s set in '
'driver_info/redfish_address on node %(node)s') %
diff --git a/ironic/drivers/modules/redfish/vendor.py b/ironic/drivers/modules/redfish/vendor.py
index c802176ce..056dbe90a 100644
--- a/ironic/drivers/modules/redfish/vendor.py
+++ b/ironic/drivers/modules/redfish/vendor.py
@@ -137,8 +137,14 @@ class RedfishVendorPassthru(base.VendorInterface):
try:
parsed = rfc3986.uri_reference(destination)
- if not parsed.is_valid(require_scheme=True,
- require_authority=True):
+ validator = rfc3986.validators.Validator().require_presence_of(
+ 'scheme', 'host',
+ ).check_validity_of(
+ 'scheme', 'userinfo', 'host', 'path', 'query', 'fragment',
+ )
+ try:
+ validator.validate(parsed)
+ except rfc3986.exceptions.RFC3986Exception:
# NOTE(iurygregory): raise error because the parsed
# destination does not contain scheme or authority.
raise TypeError