diff options
| author | Matt Riedemann <mriedem.os@gmail.com> | 2018-02-19 13:14:58 -0500 |
|---|---|---|
| committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-03-21 01:44:29 +0000 |
| commit | 1008544882fbdae16b045abca05cf3e2e8a14787 (patch) | |
| tree | 0cc1d88b56f070e7d0701ee5bb451969148f597f /openstackclient/compute | |
| parent | 6361e5e121d6ea058aa1c5c20ec897929b7a9c05 (diff) | |
| download | python-openstackclient-1008544882fbdae16b045abca05cf3e2e8a14787.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
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/server.py | 12 |
1 files changed, 9 insertions, 3 deletions
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 = [] |
