summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-01-19 16:55:14 +0000
committerStephen Finucane <sfinucan@redhat.com>2021-01-21 11:01:15 +0000
commit9ed34aac0a172ece4cd856319486208fcdba095d (patch)
tree2543ecbba2a920b997961f083e36effdb357c39b /openstackclient/compute/v2
parentc7d582379ad6b22c6dd8b7334b34a51ec59b69d4 (diff)
downloadpython-openstackclient-9ed34aac0a172ece4cd856319486208fcdba095d.tar.gz
compute: Add support for 'server boot --nic ...,tag=<tag>'
This has been around for a long time but was not exposed via OSC. Close this gap. Change-Id: I71aabf10f791f68ee7405ffb5e8317cc96cb3b38 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/compute/v2')
-rw-r--r--openstackclient/compute/v2/server.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 1277c341..92942883 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -646,6 +646,8 @@ class NICAction(argparse.Action):
values = '='.join([self.key, values])
+ # We don't include 'tag' here by default since that requires a
+ # particular microversion
info = {
'net-id': '',
'port-id': '',
@@ -656,11 +658,11 @@ class NICAction(argparse.Action):
for kv_str in values.split(','):
k, sep, v = kv_str.partition("=")
- if k not in info or not v:
+ if k not in list(info) + ['tag'] or not v:
msg = _(
"Invalid argument %s; argument must be of form "
- "'net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
- "port-id=port-uuid'"
+ "'net-id=net-uuid,port-id=port-uuid,v4-fixed-ip=ip-addr,"
+ "v6-fixed-ip=ip-addr,tag=tag'"
)
raise argparse.ArgumentTypeError(msg % values)
@@ -801,7 +803,7 @@ class CreateServer(command.ShowOne):
parser.add_argument(
'--nic',
metavar="<net-id=net-uuid,port-id=port-uuid,v4-fixed-ip=ip-addr,"
- "v6-fixed-ip=ip-addr,auto,none>",
+ "v6-fixed-ip=ip-addr,tag=tag,auto,none>",
action=NICAction,
dest='nics',
default=[],
@@ -814,6 +816,8 @@ class CreateServer(command.ShowOne):
"\n"
"v6-fixed-ip=<ip-addr>: IPv6 fixed address for NIC (optional),"
"\n"
+ "tag: interface metadata tag (optional) "
+ "(supported by --os-compute-api-version 2.43 or above),\n"
"none: (v2.37+) no network is attached,\n"
"auto: (v2.37+) the compute service will automatically "
"allocate a network.\n"
@@ -1191,6 +1195,17 @@ class CreateServer(command.ShowOne):
nics = nics[0]
else:
for nic in nics:
+ if 'tag' in nic:
+ if (
+ compute_client.api_version <
+ api_versions.APIVersion('2.43')
+ ):
+ msg = _(
+ '--os-compute-api-version 2.43 or greater is '
+ 'required to support the --nic tag field'
+ )
+ raise exceptions.CommandError(msg)
+
if self.app.client_manager.is_network_endpoint_enabled():
network_client = self.app.client_manager.network