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):
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)
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