Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion magnum/api/controllers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get(self):
return Root.convert()

@pecan.expose()
def _route(self, args):
def _route(self, args, request):
"""Overrides the default routing behavior.

It redirects the request to the default version of the magnum API
Expand Down
2 changes: 1 addition & 1 deletion magnum/api/controllers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _check_version(self, version, headers=None):
min_version=str(MIN_VER))

@pecan.expose()
def _route(self, args):
def _route(self, args, request):
version = ver.Version(
pecan.request.headers, MIN_VER_STR, MAX_VER_STR)

Expand Down
12 changes: 8 additions & 4 deletions magnum/api/controllers/v1/cluster_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,14 @@ def post(self, cluster_template):
# check root volume size
boot_volume_size = cluster_template_dict['labels'].get(
'boot_volume_size', CONF.cinder.default_boot_volume_size)
attr_validator.validate_flavor_root_volume_size(
cli, cluster_template_dict['flavor_id'], boot_volume_size)
attr_validator.validate_flavor_root_volume_size(
cli, cluster_template_dict['master_flavor_id'], boot_volume_size)
if 'flavor_id' in cluster_template_dict:
attr_validator.validate_flavor_root_volume_size(
cli, cluster_template_dict['flavor_id'], boot_volume_size)
if 'master_flavor_id' in cluster_template_dict:
attr_validator.validate_flavor_root_volume_size(
cli,
cluster_template_dict['master_flavor_id'],
boot_volume_size)

if (cluster_template.docker_storage_driver in ('devicemapper',
'overlay')):
Expand Down
13 changes: 13 additions & 0 deletions magnum/tests/unit/api/controllers/v1/test_cluster_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,19 @@ def test_create_cluster_template_with_flavor(self,
self.assertEqual(bdict['master_flavor_id'],
response.json['master_flavor_id'])

@mock.patch('magnum.api.attr_validator.validate_image')
def test_create_cluster_template_without_flavor(self,
mock_image_data):
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-coreos'}
bdict = apiutils.cluster_template_post_data()
del bdict['flavor_id']
del bdict['master_flavor_id']
response = self.post_json('/clustertemplates', bdict)
self.assertEqual(201, response.status_int)
self.assertIsNone(response.json['flavor_id'])
self.assertIsNone(response.json['master_flavor_id'])

@mock.patch('magnum.api.attr_validator.validate_image')
def test_create_cluster_template_with_no_exist_flavor(self,
mock_image_data):
Expand Down