From 91839508335cd5cee3ab1231715914129662db82 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Mon, 9 Sep 2019 14:00:21 +0200 Subject: [PATCH] Parse required_floatingips parameter as a JSON array An API request to create a floating IP reservation is expected to pass the required_floatingips parameter as a list, not as a string. Modify the CLI to parse required_floatingips as a JSON array so it can be passed to the API in the right format. Change-Id: Ia84ceb881f0889266c8f0349a1ffb047597bac2d Closes-Bug: #1843258 --- blazarclient/v1/shell_commands/leases.py | 3 +++ .../parse-required-floatingips-f79f79d652e371ae.yaml | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 releasenotes/notes/parse-required-floatingips-f79f79d652e371ae.yaml diff --git a/blazarclient/v1/shell_commands/leases.py b/blazarclient/v1/shell_commands/leases.py index 41fbfcb..55ee258 100644 --- a/blazarclient/v1/shell_commands/leases.py +++ b/blazarclient/v1/shell_commands/leases.py @@ -18,6 +18,7 @@ import datetime import logging import re +from oslo_serialization import jsonutils from oslo_utils import strutils from blazarclient import command @@ -172,6 +173,8 @@ class CreateLease(command.CreateCommand): else: if strutils.is_int_like(v): request_params[k] = int(v) + elif isinstance(defaults[k], list): + request_params[k] = jsonutils.loads(v) else: request_params[k] = v diff --git a/releasenotes/notes/parse-required-floatingips-f79f79d652e371ae.yaml b/releasenotes/notes/parse-required-floatingips-f79f79d652e371ae.yaml new file mode 100644 index 0000000..355ad78 --- /dev/null +++ b/releasenotes/notes/parse-required-floatingips-f79f79d652e371ae.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + Parse the ``required_floatingips`` command-line parameter as a list instead + of a string, to pass it to the API in the expected format. For example, + this parameter can be used in the following fashion: + + ``blazar lease-create --reservation 'resource_type=virtual:floatingip,network_id=81fabec7-00ae-497a-b485-72f4bf187d3e,amount=2,required_floatingips=["172.24.4.2","172.24.4.3"]' fip-lease`` + + For more details, see `bug 1843258 `_.