summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-16 14:09:07 +0000
committerGerrit Code Review <review@openstack.org>2017-06-16 14:09:07 +0000
commita0e89b2848c54287e7051c4505cc8ed137b1eefb (patch)
tree3dbb40947fee8a502e09134dd029aae611bdc5da
parent0d0959aa1342eb9b8f3f582adc6431d2d22a3849 (diff)
parent0f03836628f28cc7c7d1452cfc55f8ff2e3e3331 (diff)
Merge "Add --docker-volume-size for cluster-create"
-rw-r--r--magnumclient/tests/v1/test_clusters.py11
-rw-r--r--magnumclient/tests/v1/test_clusters_shell.py25
-rw-r--r--magnumclient/tests/v1/test_clustertemplates.py20
-rw-r--r--magnumclient/v1/clusters.py1
-rw-r--r--magnumclient/v1/clusters_shell.py9
5 files changed, 56 insertions, 10 deletions
diff --git a/magnumclient/tests/v1/test_clusters.py b/magnumclient/tests/v1/test_clusters.py
index 5ab0329..c4426db 100644
--- a/magnumclient/tests/v1/test_clusters.py
+++ b/magnumclient/tests/v1/test_clusters.py
@@ -263,6 +263,17 @@ class ClusterManagerTest(testtools.TestCase):
263 self.assertEqual(expect, self.api.calls) 263 self.assertEqual(expect, self.api.calls)
264 self.assertTrue(cluster) 264 self.assertTrue(cluster)
265 265
266 def test_cluster_create_with_docker_volume_size(self):
267 cluster_with_volume_size = dict()
268 cluster_with_volume_size.update(CREATE_CLUSTER)
269 cluster_with_volume_size['docker_volume_size'] = 20
270 cluster = self.mgr.create(**cluster_with_volume_size)
271 expect = [
272 ('POST', '/v1/clusters', {}, cluster_with_volume_size),
273 ]
274 self.assertEqual(expect, self.api.calls)
275 self.assertTrue(cluster)
276
266 def test_cluster_create_with_discovery_url(self): 277 def test_cluster_create_with_discovery_url(self):
267 cluster_with_discovery = dict() 278 cluster_with_discovery = dict()
268 cluster_with_discovery.update(CREATE_CLUSTER) 279 cluster_with_discovery.update(CREATE_CLUSTER)
diff --git a/magnumclient/tests/v1/test_clusters_shell.py b/magnumclient/tests/v1/test_clusters_shell.py
index 862edab..3b56b38 100644
--- a/magnumclient/tests/v1/test_clusters_shell.py
+++ b/magnumclient/tests/v1/test_clusters_shell.py
@@ -26,6 +26,7 @@ class FakeCluster(Cluster):
26 Cluster.__init__(self, manager=manager, info=info) 26 Cluster.__init__(self, manager=manager, info=info)
27 self.uuid = kwargs.get('uuid', 'x') 27 self.uuid = kwargs.get('uuid', 'x')
28 self.keypair = kwargs.get('keypair', 'x') 28 self.keypair = kwargs.get('keypair', 'x')
29 self.docker_volume_size = kwargs.get('docker_volume_size', 3)
29 self.name = kwargs.get('name', 'x') 30 self.name = kwargs.get('name', 'x')
30 self.cluster_template_id = kwargs.get('cluster_template_id', 'x') 31 self.cluster_template_id = kwargs.get('cluster_template_id', 'x')
31 self.stack_id = kwargs.get('stack_id', 'x') 32 self.stack_id = kwargs.get('stack_id', 'x')
@@ -56,6 +57,7 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
56 def _get_expected_args_create(self, cluster_template_id, name=None, 57 def _get_expected_args_create(self, cluster_template_id, name=None,
57 master_count=1, node_count=1, 58 master_count=1, node_count=1,
58 create_timeout=60, keypair=None, 59 create_timeout=60, keypair=None,
60 docker_volume_size=None,
59 discovery_url=None): 61 discovery_url=None):
60 expected_args = {} 62 expected_args = {}
61 expected_args['name'] = name 63 expected_args['name'] = name
@@ -65,6 +67,7 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
65 expected_args['create_timeout'] = create_timeout 67 expected_args['create_timeout'] = create_timeout
66 expected_args['discovery_url'] = discovery_url 68 expected_args['discovery_url'] = discovery_url
67 expected_args['keypair'] = keypair 69 expected_args['keypair'] = keypair
70 expected_args['docker_volume_size'] = docker_volume_size
68 71
69 return expected_args 72 return expected_args
70 73
@@ -90,14 +93,8 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
90 mock_list.return_value = [FakeCluster()] 93 mock_list.return_value = [FakeCluster()]
91 self._test_arg_success( 94 self._test_arg_success(
92 'cluster-list --fields status,status,status,name', 95 'cluster-list --fields status,status,status,name',
93 keyword=('\n| uuid | name | keypair | node_count | ' 96 keyword=('\n| uuid | name | keypair | docker_volume_size | '
94 'master_count | status |\n')) 97 'node_count | master_count | status |\n'))
95 # Output should be
96 # +------+------+---------+--------------+--------------+--------+
97 # | uuid | name | keypair | node_count | master_count | status |
98 # +------+------+---------+--------------+--------------+--------+
99 # | x | x | x | x | x | x |
100 # +------+------+---------+--------------+--------------+--------+
101 expected_args = self._get_expected_args_list() 98 expected_args = self._get_expected_args_list()
102 mock_list.assert_called_once_with(**expected_args) 99 mock_list.assert_called_once_with(**expected_args)
103 100
@@ -152,6 +149,12 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
152 keypair='x') 149 keypair='x')
153 mock_create.assert_called_with(**expected_args) 150 mock_create.assert_called_with(**expected_args)
154 151
152 self._test_arg_success('cluster-create --cluster-template xxx '
153 '--docker-volume-size 20')
154 expected_args = self._get_expected_args_create('xxx',
155 docker_volume_size=20)
156 mock_create.assert_called_with(**expected_args)
157
155 self._test_arg_success('cluster-create test ' 158 self._test_arg_success('cluster-create test '
156 '--cluster-template xxx') 159 '--cluster-template xxx')
157 expected_args = self._get_expected_args_create('xxx', 160 expected_args = self._get_expected_args_create('xxx',
@@ -272,6 +275,12 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
272 mock_create.assert_not_called() 275 mock_create.assert_not_called()
273 276
274 @mock.patch('magnumclient.v1.clusters.ClusterManager.create') 277 @mock.patch('magnumclient.v1.clusters.ClusterManager.create')
278 def test_cluster_create_failure_only_docker_volume_size(self, mock_create):
279 self._test_arg_failure('cluster-create --docker_volume_size 20',
280 self._mandatory_arg_error)
281 mock_create.assert_not_called()
282
283 @mock.patch('magnumclient.v1.clusters.ClusterManager.create')
275 def test_cluster_create_failure_only_node_count(self, mock_create): 284 def test_cluster_create_failure_only_node_count(self, mock_create):
276 self._test_arg_failure('cluster-create --node-count 1', 285 self._test_arg_failure('cluster-create --node-count 1',
277 self._mandatory_arg_error) 286 self._mandatory_arg_error)
diff --git a/magnumclient/tests/v1/test_clustertemplates.py b/magnumclient/tests/v1/test_clustertemplates.py
index 548f6b5..0471b1a 100644
--- a/magnumclient/tests/v1/test_clustertemplates.py
+++ b/magnumclient/tests/v1/test_clustertemplates.py
@@ -61,7 +61,7 @@ CLUSTERTEMPLATE2 = {
61 'network_driver': 'flannel', 61 'network_driver': 'flannel',
62 'volume_driver': 'cinder', 62 'volume_driver': 'cinder',
63 'dns_nameserver': '8.8.1.2', 63 'dns_nameserver': '8.8.1.2',
64 'docker_volume_size': '50', 64 'docker_volume_size': '71',
65 'docker_storage_driver': 'overlay', 65 'docker_storage_driver': 'overlay',
66 'coe': 'kubernetes', 66 'coe': 'kubernetes',
67 'labels': 'key2=val2,key22=val22', 67 'labels': 'key2=val2,key22=val22',
@@ -385,6 +385,24 @@ class ClusterTemplateManagerTest(testtools.TestCase):
385 self.assertEqual(CLUSTERTEMPLATE1['docker_storage_driver'], 385 self.assertEqual(CLUSTERTEMPLATE1['docker_storage_driver'],
386 cluster_template.docker_storage_driver) 386 cluster_template.docker_storage_driver)
387 387
388 def test_clustertemplate_create_with_docker_volume_size(self):
389 cluster_template_with_docker_volume_size = dict()
390 cluster_template_with_docker_volume_size.update(CREATE_CLUSTERTEMPLATE)
391 cluster_template_with_docker_volume_size['docker_volume_size'] = 11
392
393 cluster_template = self.mgr.create(
394 **cluster_template_with_docker_volume_size)
395 expect = [
396 ('POST', '/v1/clustertemplates', {},
397 cluster_template_with_docker_volume_size),
398 ]
399 self.assertEqual(expect, self.api.calls)
400 self.assertTrue(cluster_template)
401 self.assertEqual(CLUSTERTEMPLATE1['docker_volume_size'],
402 cluster_template.docker_volume_size)
403 self.assertEqual(CLUSTERTEMPLATE1['docker_storage_driver'],
404 cluster_template.docker_storage_driver)
405
388 def test_clustertemplate_create_fail(self): 406 def test_clustertemplate_create_fail(self):
389 CREATE_CLUSTERTEMPLATE_FAIL = copy.deepcopy(CREATE_CLUSTERTEMPLATE) 407 CREATE_CLUSTERTEMPLATE_FAIL = copy.deepcopy(CREATE_CLUSTERTEMPLATE)
390 CREATE_CLUSTERTEMPLATE_FAIL["wrong_key"] = "wrong" 408 CREATE_CLUSTERTEMPLATE_FAIL["wrong_key"] = "wrong"
diff --git a/magnumclient/v1/clusters.py b/magnumclient/v1/clusters.py
index 5f41c1f..a88a826 100644
--- a/magnumclient/v1/clusters.py
+++ b/magnumclient/v1/clusters.py
@@ -19,6 +19,7 @@ CREATION_ATTRIBUTES = baseunit.CREATION_ATTRIBUTES
19CREATION_ATTRIBUTES.append('cluster_template_id') 19CREATION_ATTRIBUTES.append('cluster_template_id')
20CREATION_ATTRIBUTES.append('create_timeout') 20CREATION_ATTRIBUTES.append('create_timeout')
21CREATION_ATTRIBUTES.append('keypair') 21CREATION_ATTRIBUTES.append('keypair')
22CREATION_ATTRIBUTES.append('docker_volume_size')
22 23
23 24
24class Cluster(baseunit.BaseTemplate): 25class Cluster(baseunit.BaseTemplate):
diff --git a/magnumclient/v1/clusters_shell.py b/magnumclient/v1/clusters_shell.py
index d75e1ab..b89336a 100644
--- a/magnumclient/v1/clusters_shell.py
+++ b/magnumclient/v1/clusters_shell.py
@@ -70,7 +70,8 @@ def do_cluster_list(cs, args):
70 sort_key=args.sort_key, 70 sort_key=args.sort_key,
71 sort_dir=args.sort_dir) 71 sort_dir=args.sort_dir)
72 columns = [ 72 columns = [
73 'uuid', 'name', 'keypair', 'node_count', 'master_count', 'status' 73 'uuid', 'name', 'keypair', 'docker_volume_size', 'node_count',
74 'master_count', 'status'
74 ] 75 ]
75 columns += utils._get_list_table_columns_and_formatters( 76 columns += utils._get_list_table_columns_and_formatters(
76 args.fields, clusters, 77 args.fields, clusters,
@@ -108,6 +109,11 @@ def do_cluster_list(cs, args):
108 metavar='<keypair>', 109 metavar='<keypair>',
109 default=None, 110 default=None,
110 help=_('Name of the keypair to use for this cluster.')) 111 help=_('Name of the keypair to use for this cluster.'))
112@utils.arg('--docker-volume-size',
113 metavar='<docker-volume-size>',
114 type=int,
115 default=None,
116 help=_('The size in GB for the docker volume to use'))
111@utils.arg('--node-count', 117@utils.arg('--node-count',
112 metavar='<node-count>', 118 metavar='<node-count>',
113 type=int, 119 type=int,
@@ -138,6 +144,7 @@ def do_cluster_create(cs, args):
138 opts['name'] = args.positional_name or args.name 144 opts['name'] = args.positional_name or args.name
139 opts['cluster_template_id'] = cluster_template.uuid 145 opts['cluster_template_id'] = cluster_template.uuid
140 opts['keypair'] = args.keypair 146 opts['keypair'] = args.keypair
147 opts['docker_volume_size'] = args.docker_volume_size
141 opts['node_count'] = args.node_count 148 opts['node_count'] = args.node_count
142 opts['master_count'] = args.master_count 149 opts['master_count'] = args.master_count
143 opts['discovery_url'] = args.discovery_url 150 opts['discovery_url'] = args.discovery_url