Improving node group templates validation

* Enabling node group templates update validation
  if plugin_name is not updated
* Adding check for volumes_size parameter if
  volumes_per_node is specified
* Adding ability to change plugin version without
  changing a plugin

Closes-Bug: #1494730
Partially-bug: #1494728

Change-Id: If6db35611e5b1501ca6485d0f40bb6c3b65561b8
This commit is contained in:
Andrey Pavlov 2015-09-11 15:49:20 +03:00
parent 57ddf86431
commit 472e8627c6
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 "
"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")
)