Support floating IP reservation parameters in lease-update

The lease-update command needs to know about all possible keys that can
be passed as reservation parameters. Also treat required_floatingips as
a list, like in commit 9183950833.

Change-Id: Iad95ebf662fb052000f05aa3d76f76308704fd1d
Related-Bug: #1843258
This commit is contained in:
Pierre Riteau 2019-09-11 17:50:43 +02:00
parent 9183950833
commit e98421c919
2 changed files with 16 additions and 4 deletions

View File

@ -412,14 +412,17 @@ class UpdateLease(command.UpdateCommand):
if parsed_args.start_date: if parsed_args.start_date:
params['start_date'] = parsed_args.start_date params['start_date'] = parsed_args.start_date
if parsed_args.reservation: if parsed_args.reservation:
keys = [ keys = set([
# General keys # General keys
'id', 'id',
# Keys for host reservation # Keys for host reservation
'min', 'max', 'hypervisor_properties', 'resource_properties', 'min', 'max', 'hypervisor_properties', 'resource_properties',
# Keys for instance reservation # Keys for instance reservation
'vcpus', 'memory_mb', 'disk_gb', 'amount', 'affinity' 'vcpus', 'memory_mb', 'disk_gb', 'amount', 'affinity',
] # Keys for floating IP reservation
'amount', 'network_id', 'required_floatingips',
])
list_keys = ['required_floatingips']
params['reservations'] = [] params['reservations'] = []
reservations = [] reservations = []
for res_str in parsed_args.reservation: for res_str in parsed_args.reservation:
@ -433,7 +436,9 @@ class UpdateLease(command.UpdateCommand):
match = prog.search(params) match = prog.search(params)
if match: if match:
k, v = match.group(2, 3) k, v = match.group(2, 3)
if strutils.is_int_like(v): if k in list_keys:
v = jsonutils.loads(v)
elif strutils.is_int_like(v):
v = int(v) v = int(v)
res_info[k] = v res_info[k] = v
if match.group(1) is not None: if match.group(1) is not None:

View File

@ -0,0 +1,7 @@
---
fixes:
- |
The command-line client now parses floating IP reservation values when
using the ``lease-update`` command. Note that while accepted by the client,
the Blazar service may prevent the update of some floating IP reservation
values.