diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py index 3cf77d40c6e064369e1f01029beca039567b2396..3ab06e9673495abe8b276c8fbb4ad22ac9334906 100644 --- a/magnumclient/osc/v1/clusters.py +++ b/magnumclient/osc/v1/clusters.py @@ -34,6 +34,9 @@ CLUSTER_ATTRIBUTES = [ 'updated_at', 'coe_version', 'labels', + 'labels_overridden', + 'labels_skipped', + 'labels_added', 'faults', 'keypair', 'api_address', @@ -47,7 +50,7 @@ CLUSTER_ATTRIBUTES = [ 'master_flavor_id', 'flavor_id', 'health_status_reason', - 'project_id' + 'project_id', ] @@ -141,6 +144,13 @@ class CreateCluster(command.Command): action='append_const', const=False, help=_('Disables floating ip creation on the new Cluster')) + parser.add_argument( + '--merge-labels', + dest='merge_labels', + action='store_true', + default=False, + help=_('The labels provided will be merged with the labels ' + 'configured in the specified cluster template.')) return parser @@ -185,6 +195,11 @@ class CreateCluster(command.Command): if parsed_args.fixed_subnet is not None: args["fixed_subnet"] = parsed_args.fixed_subnet + if parsed_args.merge_labels: + # We are only sending this if it's True. This + # way we avoid breaking older APIs. + args["merge_labels"] = parsed_args.merge_labels + cluster = mag_client.clusters.create(**args) print("Request to create cluster %s accepted" % cluster.uuid) diff --git a/magnumclient/osc/v1/nodegroups.py b/magnumclient/osc/v1/nodegroups.py index 04967bf39bee0daebd99d6b6e931dace7c46bbae..afb58704dd44474fe1ff380733b776037152deba 100644 --- a/magnumclient/osc/v1/nodegroups.py +++ b/magnumclient/osc/v1/nodegroups.py @@ -27,6 +27,9 @@ NODEGROUP_ATTRIBUTES = [ 'project_id', 'docker_volume_size', 'labels', + 'labels_overridden', + 'labels_skipped', + 'labels_added', 'flavor_id', 'image_id', 'node_addresses', @@ -37,7 +40,7 @@ NODEGROUP_ATTRIBUTES = [ 'is_default', 'stack_id', 'status', - 'status_reason' + 'status_reason', ] @@ -100,6 +103,13 @@ class CreateNodeGroup(command.Command): metavar='<flavor>', help=_('The nova flavor name or UUID to use when launching the ' 'nodes in this NodeGroup.')) + parser.add_argument( + '--merge-labels', + dest='merge_labels', + action='store_true', + default=False, + help=_('The labels provided will be merged with the labels ' + 'configured in the specified cluster.')) return parser @@ -127,6 +137,11 @@ class CreateNodeGroup(command.Command): if parsed_args.image is not None: args['image_id'] = parsed_args.image + if parsed_args.merge_labels: + # We are only sending this if it's True. This + # way we avoid breaking older APIs. + args["merge_labels"] = parsed_args.merge_labels + cluster_id = parsed_args.cluster nodegroup = mag_client.nodegroups.create(cluster_id, **args) print("Request to create nodegroup %s accepted" diff --git a/magnumclient/tests/osc/unit/v1/fakes.py b/magnumclient/tests/osc/unit/v1/fakes.py index 2a25df5f4b87ae684ef8f6aa601c79c608c0c7fc..41810101afc63e58a89f4436ef4b2b4dcf5990bd 100644 --- a/magnumclient/tests/osc/unit/v1/fakes.py +++ b/magnumclient/tests/osc/unit/v1/fakes.py @@ -237,6 +237,9 @@ class FakeCluster(object): 'stack_id': 'c4554582-77bd-4734-8f1a-72c3c40e5fb4', 'status_reason': None, 'labels': {}, + 'labels_overridden': {}, + 'labels_added': {}, + 'labels_skipped': {}, 'created_at': '2017-03-16T18:40:39+00:00', 'updated_at': '2017-03-16T18:40:45+00:00', 'coe_version': None, @@ -324,6 +327,9 @@ class FakeNodeGroup(object): 'docker_volume_size': None, 'node_addresses': [], 'labels': {}, + 'labels_overridden': {}, + 'labels_added': {}, + 'labels_skipped': {}, 'node_count': 1, 'name': 'fake-nodegroup', 'flavor_id': 'm1.medium', diff --git a/magnumclient/v1/clusters.py b/magnumclient/v1/clusters.py index 989de85dc4b61ae59886c073753387ea06604395..6aabc4b571b137f91137114f10e4b8aeb782fa9c 100644 --- a/magnumclient/v1/clusters.py +++ b/magnumclient/v1/clusters.py @@ -26,6 +26,7 @@ CREATION_ATTRIBUTES.append('flavor_id') CREATION_ATTRIBUTES.append('fixed_network') CREATION_ATTRIBUTES.append('fixed_subnet') CREATION_ATTRIBUTES.append('floating_ip_enabled') +CREATION_ATTRIBUTES.append('merge_labels') class Cluster(baseunit.BaseTemplate): diff --git a/magnumclient/v1/nodegroups.py b/magnumclient/v1/nodegroups.py index cd7993493d747ec573e8b7695e7fb499eacd38a8..111d8fb52c4c7a1161bd8cb7f3ea08f1da0cf2d6 100644 --- a/magnumclient/v1/nodegroups.py +++ b/magnumclient/v1/nodegroups.py @@ -20,7 +20,7 @@ from magnumclient.v1 import baseunit CREATION_ATTRIBUTES = ['docker_volume_size', 'labels', 'flavor_id', 'image_id', 'project_id', 'node_count', 'name', 'role', - 'min_node_count', 'max_node_count'] + 'min_node_count', 'max_node_count', 'merge_labels'] class NodeGroup(baseunit.BaseTemplate):