summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-10-02 19:16:54 +0000
committerGerrit Code Review <review@openstack.org>2017-10-02 19:16:54 +0000
commit8a39691c109dccd36462e1042fbdb535a891904c (patch)
tree6d92becb6ab9e34560481a8cf57405ef06f844f0
parent749105fee5b650f52211f1a991cc4eb9e1348cb8 (diff)
parent5daa38e5549e2cf4a1ef1d6c976c4922c9691eff (diff)
Merge "OSC: Add --labels to coe cluster create"
-rw-r--r--magnumclient/osc/v1/clusters.py12
-rw-r--r--magnumclient/tests/osc/unit/v1/fakes.py1
-rw-r--r--magnumclient/tests/osc/unit/v1/test_clusters.py1
3 files changed, 14 insertions, 0 deletions
diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py
index 274ed93..edae6cf 100644
--- a/magnumclient/osc/v1/clusters.py
+++ b/magnumclient/osc/v1/clusters.py
@@ -32,6 +32,7 @@ CLUSTER_ATTRIBUTES = [
32 'created_at', 32 'created_at',
33 'updated_at', 33 'updated_at',
34 'coe_version', 34 'coe_version',
35 'labels',
35 'faults', 36 'faults',
36 'keypair', 37 'keypair',
37 'api_address', 38 'api_address',
@@ -68,6 +69,13 @@ class CreateCluster(command.Command):
68 metavar='<docker-volume-size>', 69 metavar='<docker-volume-size>',
69 help=('The size in GB for the docker volume to ' 70 help=('The size in GB for the docker volume to '
70 'use.')) 71 'use.'))
72 parser.add_argument('--labels',
73 metavar='<KEY1=VALUE1,KEY2=VALUE2;KEY3=VALUE3...>',
74 action='append',
75 default=[],
76 help=_('Arbitrary labels in the form of key=value'
77 'pairs to associate with a cluster '
78 'template. May be used multiple times.'))
71 parser.add_argument('--keypair', 79 parser.add_argument('--keypair',
72 default=None, 80 default=None,
73 metavar='<keypair>', 81 metavar='<keypair>',
@@ -110,6 +118,10 @@ class CreateCluster(command.Command):
110 'name': parsed_args.name, 118 'name': parsed_args.name,
111 'node_count': parsed_args.node_count, 119 'node_count': parsed_args.node_count,
112 } 120 }
121
122 if parsed_args.labels is not None:
123 args['labels'] = magnum_utils.handle_labels(parsed_args.labels)
124
113 cluster = mag_client.clusters.create(**args) 125 cluster = mag_client.clusters.create(**args)
114 print("Request to create cluster %s accepted" 126 print("Request to create cluster %s accepted"
115 % cluster.uuid) 127 % cluster.uuid)
diff --git a/magnumclient/tests/osc/unit/v1/fakes.py b/magnumclient/tests/osc/unit/v1/fakes.py
index cf8220e..cabfb85 100644
--- a/magnumclient/tests/osc/unit/v1/fakes.py
+++ b/magnumclient/tests/osc/unit/v1/fakes.py
@@ -187,6 +187,7 @@ class FakeCluster(object):
187 'uuid': '3a369884-b6ba-484f-a206-919b4b718aff', 187 'uuid': '3a369884-b6ba-484f-a206-919b4b718aff',
188 'stack_id': 'c4554582-77bd-4734-8f1a-72c3c40e5fb4', 188 'stack_id': 'c4554582-77bd-4734-8f1a-72c3c40e5fb4',
189 'status_reason': None, 189 'status_reason': None,
190 'labels': {},
190 'created_at': '2017-03-16T18:40:39+00:00', 191 'created_at': '2017-03-16T18:40:39+00:00',
191 'updated_at': '2017-03-16T18:40:45+00:00', 192 'updated_at': '2017-03-16T18:40:45+00:00',
192 'coe_version': None, 193 'coe_version': None,
diff --git a/magnumclient/tests/osc/unit/v1/test_clusters.py b/magnumclient/tests/osc/unit/v1/test_clusters.py
index 7355bea..f64794c 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):
43 'create_timeout': 60, 43 'create_timeout': 60,
44 'discovery_url': None, 44 'discovery_url': None,
45 'docker_volume_size': None, 45 'docker_volume_size': None,
46 'labels': {},
46 'keypair': None, 47 'keypair': None,
47 'master_count': 1, 48 'master_count': 1,
48 'name': None, 49 'name': None,