Commit 1f1cf3e3 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

Merge "Validation for --physical-reservation argument"

parents 96b89041 48f6171e
......@@ -159,8 +159,29 @@ class CreateLease(command.CreateCommand):
parse_params(match.group(3))
parse_params(phys_res_str)
if not phys_res_info['min'] and not phys_res_info['max']:
if not (phys_res_info['min'] and phys_res_info['max']):
raise exception.IncorrectLease(err_msg)
try:
min_host = int(phys_res_info['min'])
max_host = int(phys_res_info['max'])
except Exception:
raise exception.IncorrectLease(err_msg)
if min_host > max_host:
err_msg = ("Invalid physical-reservation argument '%s'. "
"Reservation argument min value must be "
"less than max value"
% phys_res_str)
raise exception.IncorrectLease(err_msg)
if min_host == 0 or max_host == 0:
err_msg = ("Invalid physical-reservation argument '%s'. "
"Reservation arguments min and max values "
"must be greater than or equal to 1"
% phys_res_str)
raise exception.IncorrectLease(err_msg)
# NOTE(sbauza): The resource type should be conf-driven mapped with
# blazar.conf file but that's potentially on another
# host
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment