From 1008544882fbdae16b045abca05cf3e2e8a14787 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 --- openstackclient/compute/v2/server.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'openstackclient/compute/v2/server.py') diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 85c20aee..3341fbfe 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -22,6 +22,7 @@ import logging import os import sys +from novaclient import api_versions from novaclient.v2 import servers from osc_lib.cli import parseractions from osc_lib.command import command @@ -754,9 +755,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