Commit 48f6171e authored by Govardhan Chintha's avatar Govardhan Chintha Committed by Hiroaki Kobayashi

Validation for --physical-reservation argument

There was no validation for min and max arguments, so the following
is added:

1. min and max values must be integers
2. min value must be less than max value
3. min and max values must be greater than 0
4. min and max values must be provided by user

Change-Id: Icef260826d84578875af1345c387395bc80cada6
Closes-Bug: #1404190
parent 55c6300f
...@@ -159,8 +159,29 @@ class CreateLease(command.CreateCommand): ...@@ -159,8 +159,29 @@ class CreateLease(command.CreateCommand):
parse_params(match.group(3)) parse_params(match.group(3))
parse_params(phys_res_str) 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) 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 # NOTE(sbauza): The resource type should be conf-driven mapped with
# blazar.conf file but that's potentially on another # blazar.conf file but that's potentially on another
# host # 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