From 3652bbea60a6657dfd5e9e6634fbd65426dcf00a Mon Sep 17 00:00:00 2001 From: "OTSUKA, Yuanying" Date: Fri, 5 Aug 2016 16:12:29 +0900 Subject: [PATCH] Add floating_ip_enabled attributes to baymodel floating_ip_enabled option is added by server, so we should add this option to client too. Change-Id: I971ef74f0cc79346a76c1faba55777b0a44465da Partial-Implements: blueprint bay-with-no-floating-ips Depends-On: I99677221250480b43a4b95ebf460c43bc77090ad --- magnumclient/tests/v1/test_baymodels.py | 8 +++++++- magnumclient/tests/v1/test_baymodels_shell.py | 3 ++- magnumclient/tests/v1/test_clustertemplates.py | 8 +++++++- magnumclient/tests/v1/test_clustertemplates_shell.py | 3 ++- magnumclient/v1/basemodels.py | 3 ++- magnumclient/v1/baymodels_shell.py | 5 +++++ magnumclient/v1/cluster_templates_shell.py | 5 +++++ 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/magnumclient/tests/v1/test_baymodels.py b/magnumclient/tests/v1/test_baymodels.py index 229bafe3..c8d41da9 100644 --- a/magnumclient/tests/v1/test_baymodels.py +++ b/magnumclient/tests/v1/test_baymodels.py @@ -44,7 +44,9 @@ BAYMODEL1 = {'id': 123, 'tls_disabled': False, 'public': False, 'registry_enabled': False, - 'master_lb_enabled': True} + 'master_lb_enabled': True, + 'floating_ip_enabled': True, + } BAYMODEL2 = {'id': 124, 'uuid': '66666666-7777-8888-9999-000000000002', @@ -278,6 +280,8 @@ class BayModelManagerTest(testtools.TestCase): baymodel.registry_enabled) self.assertEqual(BAYMODEL1['master_lb_enabled'], baymodel.master_lb_enabled) + self.assertEqual(BAYMODEL1['floating_ip_enabled'], + baymodel.floating_ip_enabled) def test_baymodel_show_by_name(self): baymodel = self.mgr.get(BAYMODEL1['name']) @@ -306,6 +310,8 @@ class BayModelManagerTest(testtools.TestCase): baymodel.registry_enabled) self.assertEqual(BAYMODEL1['master_lb_enabled'], baymodel.master_lb_enabled) + self.assertEqual(BAYMODEL1['floating_ip_enabled'], + baymodel.floating_ip_enabled) def test_baymodel_create(self): baymodel = self.mgr.create(**CREATE_BAYMODEL) diff --git a/magnumclient/tests/v1/test_baymodels_shell.py b/magnumclient/tests/v1/test_baymodels_shell.py index 2ed1ca31..ee800c3f 100644 --- a/magnumclient/tests/v1/test_baymodels_shell.py +++ b/magnumclient/tests/v1/test_baymodels_shell.py @@ -56,7 +56,8 @@ class ShellTest(shell_test_base.TestCommandLineArgument): '--docker-storage-driver devicemapper ' '--public ' '--server-type vm' - '--master-lb-enabled') + '--master-lb-enabled ' + '--floating-ip-enabled ') self.assertTrue(mock_create.called) self._test_arg_success('baymodel-create ' diff --git a/magnumclient/tests/v1/test_clustertemplates.py b/magnumclient/tests/v1/test_clustertemplates.py index 99980e08..366b28c9 100644 --- a/magnumclient/tests/v1/test_clustertemplates.py +++ b/magnumclient/tests/v1/test_clustertemplates.py @@ -46,7 +46,9 @@ CLUSTERTEMPLATE1 = { 'tls_disabled': False, 'public': False, 'registry_enabled': False, - 'master_lb_enabled': True} + 'master_lb_enabled': True, + 'floating_ip_enabled': True + } CLUSTERTEMPLATE2 = { 'id': 124, @@ -307,6 +309,8 @@ class ClusterTemplateManagerTest(testtools.TestCase): cluster_template.registry_enabled) self.assertEqual(CLUSTERTEMPLATE1['master_lb_enabled'], cluster_template.master_lb_enabled) + self.assertEqual(CLUSTERTEMPLATE1['floating_ip_enabled'], + cluster_template.floating_ip_enabled) def test_clustertemplate_show_by_name(self): cluster_template = self.mgr.get(CLUSTERTEMPLATE1['name']) @@ -351,6 +355,8 @@ class ClusterTemplateManagerTest(testtools.TestCase): cluster_template.registry_enabled) self.assertEqual(CLUSTERTEMPLATE1['master_lb_enabled'], cluster_template.master_lb_enabled) + self.assertEqual(CLUSTERTEMPLATE1['floating_ip_enabled'], + cluster_template.floating_ip_enabled) def test_clustertemplate_create(self): cluster_template = self.mgr.create(**CREATE_CLUSTERTEMPLATE) diff --git a/magnumclient/tests/v1/test_clustertemplates_shell.py b/magnumclient/tests/v1/test_clustertemplates_shell.py index c62b611d..af98d688 100644 --- a/magnumclient/tests/v1/test_clustertemplates_shell.py +++ b/magnumclient/tests/v1/test_clustertemplates_shell.py @@ -57,7 +57,8 @@ class ShellTest(shell_test_base.TestCommandLineArgument): '--docker-storage-driver devicemapper ' '--public ' '--server-type vm' - '--master-lb-enabled') + '--master-lb-enabled ' + '--floating-ip-enabled ') self.assertTrue(mock_create.called) self._test_arg_success('cluster-template-create ' diff --git a/magnumclient/v1/basemodels.py b/magnumclient/v1/basemodels.py index 98af1719..d2715c25 100644 --- a/magnumclient/v1/basemodels.py +++ b/magnumclient/v1/basemodels.py @@ -21,7 +21,8 @@ CREATION_ATTRIBUTES = ['name', 'image_id', 'flavor_id', 'master_flavor_id', 'labels', 'coe', 'http_proxy', 'https_proxy', 'no_proxy', 'network_driver', 'tls_disabled', 'public', 'registry_enabled', 'volume_driver', 'server_type', - 'docker_storage_driver', 'master_lb_enabled'] + 'docker_storage_driver', 'master_lb_enabled', + 'floating_ip_enabled'] class BaseModel(base.Resource): diff --git a/magnumclient/v1/baymodels_shell.py b/magnumclient/v1/baymodels_shell.py index 93b85eb0..aa9d8930 100644 --- a/magnumclient/v1/baymodels_shell.py +++ b/magnumclient/v1/baymodels_shell.py @@ -120,6 +120,10 @@ def _show_baymodel(baymodel): action='store_true', default=False, help='Indicates whether created bays should have a load balancer ' 'for master nodes or not.') +@utils.arg('--floating-ip-enabled', + action='store_true', default=True, + help='Indicates whether created bays should have a floating ip' + 'or not.') @utils.deprecated(DEPRECATION_MESSAGE) def do_baymodel_create(cs, args): """Create a baymodel.""" @@ -147,6 +151,7 @@ def do_baymodel_create(cs, args): opts['registry_enabled'] = args.registry_enabled opts['server_type'] = args.server_type opts['master_lb_enabled'] = args.master_lb_enabled + opts['floating_ip_enabled'] = args.floating_ip_enabled baymodel = cs.baymodels.create(**opts) _show_baymodel(baymodel) diff --git a/magnumclient/v1/cluster_templates_shell.py b/magnumclient/v1/cluster_templates_shell.py index 1057db6a..353fbe17 100644 --- a/magnumclient/v1/cluster_templates_shell.py +++ b/magnumclient/v1/cluster_templates_shell.py @@ -115,6 +115,10 @@ def _show_cluster_template(cluster_template): action='store_true', default=False, help='Indicates whether created bays should have a load balancer ' 'for master nodes or not.') +@utils.arg('--floating-ip-enabled', + action='store_true', default=True, + help='Indicates whether created bays should have a floating ip' + 'or not.') def do_cluster_template_create(cs, args): """Create a cluster template.""" opts = {} @@ -141,6 +145,7 @@ def do_cluster_template_create(cs, args): opts['registry_enabled'] = args.registry_enabled opts['server_type'] = args.server_type opts['master_lb_enabled'] = args.master_lb_enabled + opts['floating_ip_enabled'] = args.floating_ip_enabled cluster_template = cs.cluster_templates.create(**opts) _show_cluster_template(cluster_template)