Convert integer style parameters to integer values
python-blazarclient sends all request parameters in the request body as strings even though the blazar service only accepts integer values for some parameters. For instance, the instance reservation feature accepts an integer for the 'vcpus' parameter, but the blazar client sends a string value for the parameter with the --reservation vcpus=1 option. This patch enables the --reservation option to convert integer style parameters to integer values. Closes-Bug: #1707552 Change-Id: Ife1124e14adc0183fe5d4680031bc00ca3647ed5
This commit is contained in:
parent
2cdb0682ea
commit
b2fa6bf534
|
@ -18,6 +18,8 @@ import datetime
|
|||
import logging
|
||||
import re
|
||||
|
||||
from oslo_utils import strutils
|
||||
|
||||
from blazarclient import command
|
||||
from blazarclient import exception
|
||||
|
||||
|
@ -162,12 +164,13 @@ class CreateLease(command.CreateCommand):
|
|||
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:
|
||||
if not (strutils.is_int_like(phys_res_str['min']) and
|
||||
strutils.is_int_like(phys_res_str['max'])):
|
||||
raise exception.IncorrectLease(err_msg)
|
||||
|
||||
min_host = int(phys_res_info['min'])
|
||||
max_host = int(phys_res_info['max'])
|
||||
|
||||
if min_host > max_host:
|
||||
err_msg = ("Invalid physical-reservation argument '%s'. "
|
||||
"Reservation argument min value must be "
|
||||
|
@ -202,6 +205,8 @@ class CreateLease(command.CreateCommand):
|
|||
k, v = kv_str.split("=", 1)
|
||||
except ValueError:
|
||||
raise exception.IncorrectLease(err_msg)
|
||||
if strutils.is_int_like(v):
|
||||
v = int(v)
|
||||
res_info[k] = v
|
||||
reservations.append(res_info)
|
||||
if reservations:
|
||||
|
|
Loading…
Reference in New Issue