Merge "Improving node group templates validation"

This commit is contained in:
Jenkins 2015-09-21 19:44:22 +00:00 committed by Gerrit Code Review
commit fa6fad21e9
4 changed files with 35 additions and 12 deletions

View File

@ -150,6 +150,10 @@ def check_node_group_basic_fields(plugin_name, hadoop_version, ng,
if ng.get('volume_type'):
check_volume_type_exists(ng['volume_type'])
if not ng.get('volumes_size'):
raise ex.InvalidReferenceException(
_("You must specify a volumes_size parameter"))
if ng.get('floating_ip_pool'):
check_floatingip_pool_exists(ng['name'], ng['floating_ip_pool'])

View File

@ -57,23 +57,27 @@ def check_node_group_template_usage(node_group_template_id, **kwargs):
'clusters': cluster_users and ', '.join(cluster_users) or 'N/A'})
def check_node_group_template_update(data, **kwargs):
def check_node_group_template_update(node_group_template_id, data, **kwargs):
if data.get('plugin_name') and not data.get('hadoop_version'):
raise ex.InvalidReferenceException(
_("You must specify a hadoop_version value"
_("You must specify a hadoop_version value "
"for your plugin_name"))
if data.get('hadoop_version') and not data.get('plugin_name'):
raise ex.InvalidReferenceException(
_("You must specify a plugin_name"
"for your hadoop_version value"))
if data.get('plugin_name'):
b.check_plugin_name_exists(data['plugin_name'])
b.check_plugin_supports_version(data['plugin_name'],
data['hadoop_version'])
b.check_node_group_basic_fields(data['plugin_name'],
data['hadoop_version'], data)
plugin = data.get('plugin_name')
version = data.get('hadoop_version')
b.check_plugin_name_exists(plugin)
b.check_plugin_supports_version(plugin, version)
else:
ngt = api.get_node_group_template(node_group_template_id)
plugin = ngt.plugin_name
if data.get('hadoop_version'):
version = data.get('hadoop_version')
b.check_plugin_supports_version(plugin, version)
else:
version = ngt.hadoop_version
b.check_node_group_basic_fields(plugin, version, data)
if data.get('shares'):
shares.check_shares(data['shares'])

View File

@ -418,6 +418,7 @@ class TestClusterCreateValidation(u.ValidationTestCase):
'd9a3bebc-f788-4b81-9a93-aa048022c1ca',
'availability_zone': 'nova',
'volumes_per_node': 1,
'volumes_size': 1,
'volumes_availability_zone': 'nova'
}
]

View File

@ -336,3 +336,17 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase):
bad_req_i=(1, 'NOT_FOUND', "Floating IP pool network_bad "
"not found")
)
def test_volumes_per_node_without_volumes_size(self):
self._assert_create_object_validation(
data={
'name': 'a',
'flavor_id': '42',
'plugin_name': 'fake',
'hadoop_version': '0.1',
'node_processes': ['datanode', 'tasktracker'],
'volumes_per_node': 1
},
bad_req_i=(1, 'INVALID_REFERENCE', "You must specify a "
"volumes_size parameter")
)