From 5daa38e5549e2cf4a1ef1d6c976c4922c9691eff Mon Sep 17 00:00:00 2001 From: Ricardo Rocha Date: Fri, 28 Jul 2017 14:33:22 +0000 Subject: [PATCH] OSC: Add --labels to coe cluster create Add a labels override parameter on osc cluster create to override the value present on the cluster template. Partial-Bug: #1697651 Depends-On: I8990c78433dcbbca5bc4aa121678b02636346802 Change-Id: I7c70f12012628aff5649cb238bde9186ce9552c8 --- magnumclient/osc/v1/clusters.py | 12 ++++++++++++ magnumclient/tests/osc/unit/v1/fakes.py | 1 + magnumclient/tests/osc/unit/v1/test_clusters.py | 1 + 3 files changed, 14 insertions(+) diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py index 274ed932..edae6cf1 100644 --- a/magnumclient/osc/v1/clusters.py +++ b/magnumclient/osc/v1/clusters.py @@ -32,6 +32,7 @@ CLUSTER_ATTRIBUTES = [ 'created_at', 'updated_at', 'coe_version', + 'labels', 'faults', 'keypair', 'api_address', @@ -68,6 +69,13 @@ class CreateCluster(command.Command): metavar='', help=('The size in GB for the docker volume to ' 'use.')) + parser.add_argument('--labels', + metavar='', + action='append', + default=[], + help=_('Arbitrary labels in the form of key=value' + 'pairs to associate with a cluster ' + 'template. May be used multiple times.')) parser.add_argument('--keypair', default=None, metavar='', @@ -110,6 +118,10 @@ class CreateCluster(command.Command): 'name': parsed_args.name, 'node_count': parsed_args.node_count, } + + if parsed_args.labels is not None: + args['labels'] = magnum_utils.handle_labels(parsed_args.labels) + cluster = mag_client.clusters.create(**args) print("Request to create cluster %s accepted" % cluster.uuid) diff --git a/magnumclient/tests/osc/unit/v1/fakes.py b/magnumclient/tests/osc/unit/v1/fakes.py index cf8220eb..cabfb85a 100644 --- a/magnumclient/tests/osc/unit/v1/fakes.py +++ b/magnumclient/tests/osc/unit/v1/fakes.py @@ -187,6 +187,7 @@ class FakeCluster(object): 'uuid': '3a369884-b6ba-484f-a206-919b4b718aff', 'stack_id': 'c4554582-77bd-4734-8f1a-72c3c40e5fb4', 'status_reason': None, + 'labels': {}, 'created_at': '2017-03-16T18:40:39+00:00', 'updated_at': '2017-03-16T18:40:45+00:00', 'coe_version': None, diff --git a/magnumclient/tests/osc/unit/v1/test_clusters.py b/magnumclient/tests/osc/unit/v1/test_clusters.py index 7355bea4..f64794c9 100644 --- a/magnumclient/tests/osc/unit/v1/test_clusters.py +++ b/magnumclient/tests/osc/unit/v1/test_clusters.py @@ -43,6 +43,7 @@ class TestClusterCreate(TestCluster): 'create_timeout': 60, 'discovery_url': None, 'docker_volume_size': None, + 'labels': {}, 'keypair': None, 'master_count': 1, 'name': None,