Merge "Allow multiple clusters creation"

This commit is contained in:
Jenkins 2015-09-11 12:07:32 +00:00 committed by Gerrit Code Review
commit dd812faa69
3 changed files with 58 additions and 2 deletions

View File

@ -264,8 +264,8 @@ def cluster_template_update(request, ct_id, name, plugin_name,
def cluster_create(request, name, plugin_name, hadoop_version,
cluster_template_id=None, default_image_id=None,
is_transient=None, description=None, cluster_configs=None,
node_groups=None, user_keypair_id=None,
anti_affinity=None, net_id=None, use_autoconfig=None):
node_groups=None, user_keypair_id=None, anti_affinity=None,
net_id=None, count=None, use_autoconfig=None):
return client(request).clusters.create(
name=name,
plugin_name=plugin_name,
@ -279,6 +279,7 @@ def cluster_create(request, name, plugin_name, hadoop_version,
user_keypair_id=user_keypair_id,
anti_affinity=anti_affinity,
net_id=net_id,
count=count,
use_autoconfig=use_autoconfig)

View File

@ -80,6 +80,12 @@ class GeneralConfigAction(workflows.Action):
add_item_link=
TEMPLATE_UPLOAD_URL)
cluster_count = forms.IntegerField(min_value=1,
label=_("Cluster Count"),
initial=1,
help_text=(
_("Number of clusters to launch.")))
image = forms.DynamicChoiceField(label=_("Base Image"),
add_item_link=BASE_IMAGE_URL)
@ -241,6 +247,7 @@ class ConfigureCluster(whelpers.StatusFormatMixin, workflows.Workflow):
description=context["general_description"],
node_groups=node_groups,
user_keypair_id=user_keypair,
cluster_count=context['cluster_count'],
net_id=context.get("general_neutron_management_network", None))
return True
except api_base.APIException as e:

View File

@ -0,0 +1,48 @@
# Copyright 2015, Telles Nobrega
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from openstack_dashboard.contrib.sahara import api
from openstack_dashboard.contrib.sahara.test import helpers as test
class SaharaApiTest(test.SaharaAPITestCase):
#
# Cluster
#
def test_cluster_create_count(self):
saharaclient = self.stub_saharaclient()
saharaclient.clusters = self.mox.CreateMockAnything()
saharaclient.clusters.create(anti_affinity=None,
cluster_configs=None,
cluster_template_id=None,
count=2,
use_autoconfig=None,
default_image_id=None,
description=None,
hadoop_version='1.0.0',
is_transient=None,
name='name',
net_id=None,
node_groups=None,
plugin_name='fake_plugin',
user_keypair_id=None) \
.AndReturn({"Clusters": ['cluster1', 'cluster2']})
self.mox.ReplayAll()
ret_val = api.sahara.cluster_create(self.request,
'name',
'fake_plugin',
'1.0.0',
count=2)
self.assertEqual(2, len(ret_val['Clusters']))