From 4944d4eaa9aaeffdee358680550ac7d7f0c6e8d8 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 19 Feb 2018 13:14:58 -0500 Subject: Default --nic to 'auto' if creating a server with >= 2.37 Compute API version >= 2.37 requires a 'networks' value in the server create request. The novaclient CLI defaults this to 'auto' if not specified, but the novaclient ServerManager.create python API binding code does not, as it wants clients to be explicit. For the purposes of the OSC CLI, we should follow suit and if the user is requesting OS_COMPUTE_API_VERSION>=2.37 without specific nics, we should just default to 'auto'. Change-Id: Ib760c55e31209223338a4086ff1f4fee88dc6959 Closes-Bug: #1750395 (cherry picked from commit 1008544882fbdae16b045abca05cf3e2e8a14787) --- openstackclient/compute/v2/server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'openstackclient/compute/v2') diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index a6a59084..a1647421 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -809,9 +809,14 @@ class CreateServer(command.ShowOne): raise exceptions.CommandError(msg) nics = nics[0] else: - # Default to empty list if nothing was specified, let nova side to - # decide the default behavior. - nics = [] + # Compute API version >= 2.37 requires a value, so default to + # 'auto' to maintain legacy behavior if a nic wasn't specified. + if compute_client.api_version >= api_versions.APIVersion('2.37'): + nics = 'auto' + else: + # Default to empty list if nothing was specified, let nova + # side to decide the default behavior. + nics = [] # Check security group exist and convert ID to name security_group_names = [] -- cgit v1.2.1