summaryrefslogtreecommitdiff
path: root/ironic/common/args.py
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2020-11-18 21:18:48 +1300
committerSteve Baker <sbaker@redhat.com>2020-11-26 11:05:48 +1300
commite41893c9d085b4883366db65b9a74104f1949e1d (patch)
tree3a2b9362a8772e65ac40451cf8703dba62a56aa9 /ironic/common/args.py
parenta08da8551a66815bedef7c6444fde5f9082a6aea (diff)
downloadironic-e41893c9d085b4883366db65b9a74104f1949e1d.tar.gz
JSON conversion followup change
This change addresses nit-level review comments from this task. Story: 1651346 Task: 10551 Change-Id: I01608004ce90facadb73e252203900a1e62cbea1
Diffstat (limited to 'ironic/common/args.py')
-rwxr-xr-xironic/common/args.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/ironic/common/args.py b/ironic/common/args.py
index 014fbd318..94cfe8841 100755
--- a/ironic/common/args.py
+++ b/ironic/common/args.py
@@ -100,7 +100,7 @@ def uuid_or_name(name, value):
if value is None:
return
if (not utils.is_valid_logical_name(value)
- and not uuidutils.is_uuid_like(value)):
+ and not uuidutils.is_uuid_like(value)):
raise exception.InvalidParameterValue(
_('Expected UUID or name for %s: %s') % (name, value))
return value
@@ -271,7 +271,9 @@ def types(*types):
:param: types one or more types to use for the isinstance test
:returns: validator function which takes name and value arguments
"""
- return functools.partial(_validate_types, types=tuple(types))
+ # Replace None with the None type
+ types = tuple((type(None) if tp is None else tp) for tp in types)
+ return functools.partial(_validate_types, types=types)
def _apply_validator(name, value, val_functions):
@@ -352,7 +354,7 @@ def validate(*args, **kwargs):
elif param.default == inspect.Parameter.empty:
# no argument was provided, and there is no default
# in the parameter, so this is a mandatory argument
- raise exception.InvalidParameterValue(
+ raise exception.MissingParameterValue(
_('Missing mandatory parameter: %s') % param.name)
if param_positional:
@@ -388,7 +390,8 @@ patch = schema({
'op': {'type': 'string', 'enum': ['add', 'replace', 'remove']},
'value': {}
},
- 'additionalProperties': False
+ 'additionalProperties': False,
+ 'required': ['op', 'path']
}
})
"""Validate a patch API operation"""