Skip to content

Commit a950ce7

Browse files
committed
Cluster Create: template name now permitted again
This validation decorator used a driver convenience function to find the cluster template that required a uuid. With this change, we use the same code as others in the class and no longer have to modify get_driver_for_cluster to be more permissive. Change-Id: I9e7a462b3d78bb5f520c3edd70dc452f6812f924 Signed-off-by: Dale Smith <[email protected]>
1 parent eb56e29 commit a950ce7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

magnum/api/validation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ def enforce_cluster_master_size_supported():
9494
@decorator.decorator
9595
def wrapper(func, *args, **kwargs):
9696
cluster = args[1]
97-
cluster_driver = driver.Driver.get_driver_for_cluster(
98-
pecan.request.context, cluster)
97+
cluster_template = objects.ClusterTemplate.get(
98+
pecan.request.context, cluster.cluster_template_id)
99+
cluster_type = (cluster_template.server_type,
100+
cluster_template.cluster_distro,
101+
cluster_template.coe)
102+
cluster_driver = driver.Driver.get_driver(*cluster_type)
99103
# Call into the driver to validate initial master size
100104
cluster_driver.validate_master_size(cluster.master_count)
101105
return func(*args, **kwargs)

magnum/tests/unit/api/controllers/v1/test_cluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,10 @@ def test_create_cluster_with_non_existent_cluster_template_name(self):
714714
self.assertEqual(400, response.status_int)
715715
self.assertTrue(response.json['errors'])
716716

717-
def test_create_cluster_with_cluster_template_name(self):
717+
def test_create_cluster_with_cluster_template_name_as_id(self):
718718
modelname = self.cluster_template.name
719-
bdict = apiutils.cluster_post_data(name=modelname)
720-
response = self.post_json('/clusters', bdict, expect_errors=True)
719+
bdict = apiutils.cluster_post_data(cluster_template_id=modelname)
720+
response = self.post_json('/clusters', bdict)
721721
self.assertEqual('application/json', response.content_type)
722722
self.assertEqual(202, response.status_int)
723723

0 commit comments

Comments
 (0)