summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2018-02-19 13:14:58 -0500
committerMatt Riedemann <mriedem.os@gmail.com>2018-10-25 16:25:28 -0400
commit4944d4eaa9aaeffdee358680550ac7d7f0c6e8d8 (patch)
treef32120b9675de096dc2303b6c96f0806547cee7c /openstackclient/compute
parenta12cee60c745b6eabb7c791eafd7c9adad0a916e (diff)
downloadpython-openstackclient-4944d4eaa9aaeffdee358680550ac7d7f0c6e8d8.tar.gz
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)
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py11
1 files changed, 8 insertions, 3 deletions
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 = []