diff --git a/tuskar_ui/api/heat.py b/tuskar_ui/api/heat.py index ae7fc718c..8203a66ba 100644 --- a/tuskar_ui/api/heat.py +++ b/tuskar_ui/api/heat.py @@ -98,7 +98,7 @@ class Stack(base.APIResourceWrapper): 'environment': environment, 'files': provider_resource_templates, } - password = getattr(settings, 'UNDERCLOUD_ADMIN_PASSWORD', None), + password = getattr(settings, 'UNDERCLOUD_ADMIN_PASSWORD', None) # TODO(lsmola) Bug #1394505. Until then we are calling the client # directly. When it's fixed, we should use heat_update from diff --git a/tuskar_ui/infrastructure/overview/forms.py b/tuskar_ui/infrastructure/overview/forms.py index 110d94945..7cd172b9b 100644 --- a/tuskar_ui/infrastructure/overview/forms.py +++ b/tuskar_ui/infrastructure/overview/forms.py @@ -161,6 +161,39 @@ class EditPlan(horizon.forms.SelfHandlingForm): return True +class ScaleOut(EditPlan): + def __init__(self, *args, **kwargs): + super(ScaleOut, self).__init__(*args, **kwargs) + for name, field in self.fields.items(): + if name.endswith('-count'): + field.widget.attrs['min'] = field.initial + + def handle(self, request, data): + if not super(ScaleOut, self).handle(request, data): + return False + plan = self.plan + try: + stack = api.heat.Stack.get_by_plan(self.request, plan) + stack.update(request, plan.name, plan.master_template, + plan.environment, plan.provider_resource_templates) + except Exception as e: + LOG.exception(e) + if hasattr(e, 'error'): + horizon.exceptions.handle( + request, + _( + "Unable to deploy overcloud. Reason: {0}" + ).format(e.error['error']['message']), + ) + return False + else: + raise + else: + msg = _('Deployment in progress.') + horizon.messages.success(request, msg) + return True + + class DeployOvercloud(horizon.forms.SelfHandlingForm): def handle(self, request, data): try: diff --git a/tuskar_ui/infrastructure/overview/urls.py b/tuskar_ui/infrastructure/overview/urls.py index 2c9242709..6e409a6b6 100644 --- a/tuskar_ui/infrastructure/overview/urls.py +++ b/tuskar_ui/infrastructure/overview/urls.py @@ -29,4 +29,7 @@ urlpatterns = urls.patterns( urls.url(r'^post-deploy-init$', views.PostDeployInitView.as_view(), name='post_deploy_init'), + urls.url(r'^scale-out$', + views.ScaleOutView.as_view(), + name='scale_out'), ) diff --git a/tuskar_ui/infrastructure/overview/views.py b/tuskar_ui/infrastructure/overview/views.py index 0eb41fadb..bc06fb686 100644 --- a/tuskar_ui/infrastructure/overview/views.py +++ b/tuskar_ui/infrastructure/overview/views.py @@ -313,3 +313,27 @@ class PostDeployInitView(horizon.forms.ModalFormView, StackMixin): initial = super(PostDeployInitView, self).get_initial(**kwargs) initial['stack_id'] = self.get_stack().id return initial + + +class ScaleOutView(horizon.forms.ModalFormView, StackMixin): + form_class = forms.ScaleOut + template_name = "infrastructure/overview/scale_out.html" + submit_label = _("Deploy Changes") + + def get_success_url(self): + return reverse(INDEX_URL) + + def get_form(self, form_class): + return form_class(self.request, **self.get_form_kwargs()) + + def get_context_data(self, *args, **kwargs): + context = super(ScaleOutView, self).get_context_data(*args, **kwargs) + plan = api.tuskar.Plan.get_the_plan(self.request) + form = context.get('form') + roles = [_get_role_data(plan, None, form, role) + for role in plan.role_list] + context.update({ + 'roles': roles, + 'plan': plan, + }) + return context diff --git a/tuskar_ui/infrastructure/static/infrastructure/scss/_numberpicker.scss b/tuskar_ui/infrastructure/static/infrastructure/scss/_numberpicker.scss index fa7d1a532..d443c41ee 100644 --- a/tuskar_ui/infrastructure/static/infrastructure/scss/_numberpicker.scss +++ b/tuskar_ui/infrastructure/static/infrastructure/scss/_numberpicker.scss @@ -15,6 +15,7 @@ div.number_picker { margin: 8px auto; padding: 0; text-align: center; + outline: 0; } a { display: block; diff --git a/tuskar_ui/infrastructure/templates/infrastructure/overview/_scale_out.html b/tuskar_ui/infrastructure/templates/infrastructure/overview/_scale_out.html new file mode 100644 index 000000000..550aa42dd --- /dev/null +++ b/tuskar_ui/infrastructure/templates/infrastructure/overview/_scale_out.html @@ -0,0 +1,41 @@ +{% extends "horizon/common/_modal_form.html" %} +{% load i18n %} +{% load url from future %} +{% load form_helpers %} + +{% block form_id %}scale_out_form{% endblock %} +{% block form_action %}{% url 'horizon:infrastructure:overview:scale_out' %}{% endblock %} + +{% block modal_id %}scale_out_modal{% endblock %} +{% block modal-header %}{% trans "Scale-out Deployment" %}{% endblock %} + +{% block modal-body %} +