Labels override
This adds a boolean flag called --merge-labels at the create CLIs for clusters and nodegroups. The show output for clusters and nodegroups is modified to contain also new fields called "labels_overridden", "labels_added", "labels_skipped". The new labels contain the differences of the object's labels with its parent's. story: 2007515 task: 39692 Depends-On: I1054c54da96005a49e874de6f4cf60b5db57fc02 Change-Id: Ie68bb85f4b8bbacc5b71b523d8639cf30e6e1992
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user