From c6b795298280e1ee8f0dd358bb895d16aa2fa8d4 Mon Sep 17 00:00:00 2001 From: Feilong Wang Date: Thu, 2 Jul 2020 14:20:55 +1200 Subject: [PATCH] Support master_lb_enabled when creating cluster Task: 40263 Story: 2007634 Change-Id: I59ad158753f25a56219ecaa5a55dd3f0ae67965a --- magnumclient/osc/v1/clusters.py | 11 +++++++++++ magnumclient/tests/osc/unit/v1/fakes.py | 6 ++++-- magnumclient/v1/clusters.py | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py index 3ab06e96..edc506df 100644 --- a/magnumclient/osc/v1/clusters.py +++ b/magnumclient/osc/v1/clusters.py @@ -41,6 +41,7 @@ CLUSTER_ATTRIBUTES = [ 'keypair', 'api_address', 'master_addresses', + 'master_lb_enabled', 'create_timeout', 'node_count', 'discovery_url', @@ -151,6 +152,13 @@ class CreateCluster(command.Command): default=False, help=_('The labels provided will be merged with the labels ' 'configured in the specified cluster template.')) + parser.add_argument( + '--master-lb-enabled', + dest='master_lb_enabled', + action='store_true', + default=False, + help=_('Indicates whether created clusters should have ' + 'a loadbalancer for API.')) return parser @@ -200,6 +208,9 @@ class CreateCluster(command.Command): # way we avoid breaking older APIs. args["merge_labels"] = parsed_args.merge_labels + if parsed_args.master_lb_enabled: + args["master_lb_enabled"] = parsed_args.master_lb_enabled + 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 41810101..ad02bf14 100644 --- a/magnumclient/tests/osc/unit/v1/fakes.py +++ b/magnumclient/tests/osc/unit/v1/fakes.py @@ -256,7 +256,8 @@ class FakeCluster(object): 'master_flavor_id': None, 'flavor_id': 'm1.medium', 'project_id': None, - 'health_status_reason': {'api': 'ok'} + 'health_status_reason': {'api': 'ok'}, + 'master_lb_enabled': False, } # Overwrite default attributes. @@ -341,7 +342,8 @@ class FakeNodeGroup(object): 'is_default': False, 'stack_id': '3a369884-b6ba-484f-fake-stackb718aff', 'status': 'CREATE_COMPLETE', - 'status_reason': 'None' + 'status_reason': 'None', + 'master_lb_enabled': False, } # Overwrite default attributes. diff --git a/magnumclient/v1/clusters.py b/magnumclient/v1/clusters.py index 6aabc4b5..7a14e1a0 100644 --- a/magnumclient/v1/clusters.py +++ b/magnumclient/v1/clusters.py @@ -27,6 +27,7 @@ CREATION_ATTRIBUTES.append('fixed_network') CREATION_ATTRIBUTES.append('fixed_subnet') CREATION_ATTRIBUTES.append('floating_ip_enabled') CREATION_ATTRIBUTES.append('merge_labels') +CREATION_ATTRIBUTES.append('master_lb_enabled') class Cluster(baseunit.BaseTemplate):