diff options
Diffstat (limited to 'tuskar_ui/infrastructure/parameters')
10 files changed, 0 insertions, 774 deletions
diff --git a/tuskar_ui/infrastructure/parameters/__init__.py b/tuskar_ui/infrastructure/parameters/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/tuskar_ui/infrastructure/parameters/__init__.py +++ /dev/null diff --git a/tuskar_ui/infrastructure/parameters/forms.py b/tuskar_ui/infrastructure/parameters/forms.py deleted file mode 100644 index a0e91e63..00000000 --- a/tuskar_ui/infrastructure/parameters/forms.py +++ /dev/null @@ -1,281 +0,0 @@ -# -*- coding: utf8 -*- -# -# 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. - -import json -import logging - -import django.forms -from django.utils.datastructures import SortedDict -from django.utils.translation import ugettext_lazy as _ -import horizon.exceptions -import horizon.forms -import horizon.messages - -from tuskar_ui import api -import tuskar_ui.forms -from tuskar_ui.utils import utils - - -LOG = logging.getLogger(__name__) - - -VIRT_TYPE_CHOICES = [ - ('qemu', _("Virtualized (qemu)")), - ('kvm', _("Baremetal (kvm)")), -] - -CINDER_ISCSI_HELPER_CHOICES = [ - ('tgtadm', _('tgtadm')), - ('lioadm', _('lioadm')), -] - - -class ParameterAwareMixin(object): - parameter = None - - -def parameter_fields(request, prefix=None, read_only=False): - fields = SortedDict() - plan = api.tuskar.Plan.get_the_plan(request) - parameters = plan.parameter_list(include_key_parameters=False) - - for p in parameters: - if prefix and not p.name.startswith(prefix): - continue - Field = django.forms.CharField - field_kwargs = {} - widget = None - if read_only: - if p.hidden: - widget = tuskar_ui.forms.StaticTextPasswordWidget - else: - widget = tuskar_ui.forms.StaticTextWidget - else: - if p.hidden: - widget = django.forms.PasswordInput(render_value=True) - elif p.parameter_type == 'number': - Field = django.forms.IntegerField - elif p.parameter_type == 'boolean': - Field = django.forms.BooleanField - elif (p.parameter_type == 'string' and - p.get_constraint_by_type('allowed_values')): - Field = django.forms.ChoiceField - field_kwargs['choices'] = [ - (choice, choice) for choice in - p.get_constraint_by_type('allowed_values')['definition']] - elif (p.parameter_type in ['json', 'comma_delimited_list'] or - 'Certificate' in p.name): - widget = django.forms.Textarea - - fields[p.name] = Field( - required=False, - label=_parameter_label(p), - initial=p.value, - widget=widget, - **field_kwargs - ) - fields[p.name].__class__ = type('ParameterAwareField', - (ParameterAwareMixin, Field), {}) - fields[p.name].parameter = p - return fields - - -def _parameter_label(parameter): - return tuskar_ui.forms.label_with_tooltip( - parameter.label or utils.de_camel_case(parameter.stripped_name), - parameter.description) - - -class ServiceConfig(horizon.forms.SelfHandlingForm): - def __init__(self, *args, **kwargs): - super(ServiceConfig, self).__init__(*args, **kwargs) - self.fields.update(parameter_fields(self.request, read_only=True)) - - def global_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='^(?!.*::)') - - def controller_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='Controller-1') - - def compute_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='Compute-1') - - def block_storage_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='Cinder-Storage-1') - - def object_storage_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='Swift-Storage-1') - - def ceph_storage_fieldset(self): - return tuskar_ui.forms.fieldset(self, prefix='Ceph-Storage-1') - - def handle(): - pass - - -class AdvancedEditServiceConfig(ServiceConfig): - def __init__(self, *args, **kwargs): - super(AdvancedEditServiceConfig, self).__init__(*args, **kwargs) - self.fields.update(parameter_fields(self.request)) - - def handle(self, request, data): - plan = api.tuskar.Plan.get_the_plan(self.request) - - # TODO(bcrochet): Commenting this out. - # For advanced config, we should have a whitelist of which params - # must be synced across roles. - # data = self._sync_common_params_across_roles(plan, data) - - try: - plan.patch(request, plan.uuid, data) - except Exception as e: - horizon.exceptions.handle( - request, - _("Unable to update the service configuration.")) - LOG.exception(e) - return False - else: - horizon.messages.success( - request, - _("Service configuration updated.")) - return True - - @staticmethod - def _sync_common_params_across_roles(plan, parameters_dict): - for (p_key, p_value) in parameters_dict.iteritems(): - for role in plan.role_list: - role_parameter_key = (role.parameter_prefix + - api.tuskar.strip_prefix(p_key)) - if role_parameter_key in parameters_dict: - parameters_dict[role_parameter_key] = p_value - return parameters_dict - - -class SimpleEditServiceConfig(horizon.forms.SelfHandlingForm): - virt_type = django.forms.ChoiceField( - label=_("Deployment Type"), - choices=VIRT_TYPE_CHOICES, - required=True, - help_text=_('If you are testing OpenStack in a virtual machine, ' - 'you must configure Compute to use qemu without KVM ' - 'and hardware virtualization.')) - neutron_public_interface = django.forms.CharField( - label=_("Public Interface"), - required=True, - initial='eth0', - help_text=_('What interface to bridge onto br-ex for network nodes. ' - 'If you are testing OpenStack in a virtual machine' - 'you must configure interface to eth0.')) - snmp_password = django.forms.CharField( - label=_("SNMP Password"), - required=True, - help_text=_('The user password for SNMPd with readonly ' - 'rights running on all Overcloud nodes'), - widget=django.forms.PasswordInput(render_value=True)) - cloud_name = django.forms.CharField( - label=_("Cloud name"), - required=True, - initial="overcloud", - help_text=_('The DNS name of this cloud. ' - 'E.g. ci-overcloud.tripleo.org')) - cinder_iscsi_helper = django.forms.ChoiceField( - label=_("Cinder ISCSI helper"), - choices=CINDER_ISCSI_HELPER_CHOICES, - required=True, - help_text=_('The iSCSI helper to use with cinder.')) - ntp_server = django.forms.CharField( - label=_("NTP server"), - required=False, - initial="", - help_text=_('Address of the NTP server. If blank, public NTP servers ' - 'will be used.')) - extra_config = django.forms.CharField( - label=_("Extra Config"), - required=False, - widget=django.forms.Textarea(attrs={'rows': 2}), - help_text=("Additional configuration to inject into the cluster." - "The data format of this field is JSON." - "See http://git.io/PuwLXQ for more information.")) - - def clean_extra_config(self): - data = self.cleaned_data['extra_config'] - try: - json.loads(data) - except Exception as json_error: - raise django.forms.ValidationError( - _("%(err_msg)s"), params={'err_msg': json_error.message}) - return data - - @staticmethod - def _load_additional_parameters(plan, data, form_key, param_name): - params = {} - param_value = data.get(form_key) - # Set the same parameter and value in all roles. - for role in plan.role_list: - key = role.parameter_prefix + param_name - if key in [parameter.name - for parameter in role.parameter_list(plan)]: - params[key] = param_value - - return params - - def handle(self, request, data): - plan = api.tuskar.Plan.get_the_plan(self.request) - compute_prefix = plan.get_role_by_name('Compute').parameter_prefix - controller_prefix = plan.get_role_by_name( - 'Controller').parameter_prefix - cinder_prefix = plan.get_role_by_name( - 'Cinder-Storage').parameter_prefix - - virt_type = data.get('virt_type') - neutron_public_interface = data.get('neutron_public_interface') - cloud_name = data.get('cloud_name') - cinder_iscsi_helper = data.get('cinder_iscsi_helper') - ntp_server = data.get('ntp_server') - - parameters = { - compute_prefix + 'NovaComputeLibvirtType': virt_type, - controller_prefix + 'CinderISCSIHelper': cinder_iscsi_helper, - cinder_prefix + 'CinderISCSIHelper': cinder_iscsi_helper, - controller_prefix + 'CloudName': cloud_name, - controller_prefix + 'NeutronPublicInterface': - neutron_public_interface, - compute_prefix + 'NeutronPublicInterface': - neutron_public_interface, - controller_prefix + 'NtpServer': - ntp_server, - compute_prefix + 'NtpServer': - ntp_server, - } - - parameters.update(self._load_additional_parameters( - plan, data, - 'snmp_password', 'SnmpdReadonlyUserPassword')) - parameters.update(self._load_additional_parameters( - plan, data, - 'extra_config', 'ExtraConfig')) - - try: - plan.patch(request, plan.uuid, parameters) - except Exception as e: - horizon.exceptions.handle( - request, - _("Unable to update the service configuration.")) - LOG.exception(e) - return False - else: - horizon.messages.success( - request, - _("Service configuration updated.")) - return True diff --git a/tuskar_ui/infrastructure/parameters/panel.py b/tuskar_ui/infrastructure/parameters/panel.py deleted file mode 100644 index 3c085ae0..00000000 --- a/tuskar_ui/infrastructure/parameters/panel.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf8 -*- -# -# 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 django.utils.translation import ugettext_lazy as _ -import horizon - -from tuskar_ui.infrastructure import dashboard - - -class Parameters(horizon.Panel): - name = _("Service Configuration") - slug = "parameters" - - -dashboard.Infrastructure.register(Parameters) diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/_simple_service_config.html b/tuskar_ui/infrastructure/parameters/templates/parameters/_simple_service_config.html deleted file mode 100644 index f8788d2f..00000000 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/_simple_service_config.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "horizon/common/_modal_form.html" %} -{% load i18n %} -{% load url from future %} - -{% block form_id %}configuration_form{% endblock %} -{% block form_action %}{% url 'horizon:infrastructure:parameters:simple_service_configuration' %}{% endblock %} - -{% block modal_id %}provision_modal{% endblock %} -{% block modal-header %}{% trans "Service Configuration" %}{% endblock %} - -{% block modal-body %} -<div class="left"> - <fieldset> - {% include "horizon/common/_form_fields.html" %} - </fieldset> -</div> -<div class="right"> - <h3>{% trans "Description:" %}</h3> - <p> - {% trans "Configure values that cannot be defaulted" %} - </p> - <p> - {% trans "These values cannot be defaulted. Please choose values for them and save them before you deploy your overcloud." %} - </p> -</div> -{% endblock %} diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/advanced_service_config.html b/tuskar_ui/infrastructure/parameters/templates/parameters/advanced_service_config.html deleted file mode 100644 index 9f9955be..00000000 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/advanced_service_config.html +++ /dev/null @@ -1,88 +0,0 @@ -{% extends "infrastructure/base.html" %} -{% load i18n %} -{% load url from future %} -{% block title %}{% trans "Advanced Service Configuration" %}{% endblock %} - -{% block page_header %} - {% include 'horizon/common/_items_count_domain_page_header.html' with title=_('Advanced Service Configuration') %} -{% endblock %} - -{% block main %} - <div class="row"> - <form id="{% block form_id %}{{ form_id }}{% endblock %}" - name="{% block form_name %}{% endblock %}" - autocomplete="{% block autocomplete %}{% if form.no_autocomplete %}off{% endif %}{% endblock %}" - class="{% block form_class %}{% endblock %} form-horizontal" - action="{% block form_action %}{{ submit_url }}{% endblock %}" - method="{% block form-method %}POST{% endblock %}" - {% block form_validation %}{% endblock %} - {% if add_to_field %}data-add-to-field="{{ add_to_field }}"{% endif %} {% block form_attrs %}{% endblock %}>{% csrf_token %} - <div class="col-sm-12 page_form_actions"> - <div class="pull-right"> - <a href="{% block cancel_url %}{{ cancel_url }}{% endblock %}" - class="btn btn-default cancel"> - {{ cancel_label }} - </a> - <input class="btn btn-primary" type="submit" value="{{ submit_label }}"> - </div> - </div> - {% include 'horizon/common/_form_errors.html' with form=form %} - <div class="col-md-2"> - <ul class="nav nav-pills nav-stacked nav-arrow" role="tablist"> - <li class="active"><a href="#global" role="tab" data-toggle="tab">{% trans "Global" %}</a></li> - <li><a href="#controller" role="tab" data-toggle="tab">{% trans "Controller" %}</a></li> - <li><a href="#compute" role="tab" data-toggle="tab">{% trans "Compute" %}</a></li> - <li><a href="#block-storage" role="tab" data-toggle="tab">{% trans "Block Storage" %}</a></li> - <li><a href="#object-storage" role="tab" data-toggle="tab">{% trans "Object Storage" %}</a></li> - <li><a href="#ceph-storage" role="tab" data-toggle="tab">{% trans "Ceph Storage" %}</a></li> - </ul> - </div> - <div class="col-md-10"> - <div class="tab-content panel panel-default configuration-panel"> - <div class="tab-pane active" id="global"> - {% for field in form.global_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="controller"> - {% for field in form.controller_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="compute"> - {% for field in form.compute_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="block-storage"> - {% for field in form.block_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="object-storage"> - {% for field in form.object_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="ceph-storage"> - {% for field in form.ceph_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - </div> - </div> - </form> - </div> - - <script type="text/javascript"> - (window.$ || window.addHorizonLoadEvent)(function () { - $(document).tooltip('hide'); // prevent horizon from adding tooltip - $('a.help-icon').click(function () { - return false; - }).popover({ - trigger: 'focus', - placement: 'right' - }); - }); - </script> -{% endblock %} diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html deleted file mode 100644 index 1671e707..00000000 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html +++ /dev/null @@ -1,76 +0,0 @@ -{% extends "infrastructure/base.html" %} -{% load i18n %} -{% load url from future %} -{% block title %}{% trans "Service Configuration" %}{% endblock %} - -{% block page_header %} - {% include 'horizon/common/_items_count_domain_page_header.html' with title=_('Service Configuration') %} -{% endblock %} - -{% block main %} - <div class="row"> - <form class="form-horizontal"> - {% include 'horizon/common/_form_errors.html' with form=form %} - <div class="col-md-2"> - <ul class="nav nav-pills nav-stacked nav-arrow" role="tablist"> - <li class="active"><a href="#global" role="tab" data-toggle="tab">{% trans "Global" %}</a></li> - <li><a href="#controller" role="tab" data-toggle="tab">{% trans "Controller" %}</a></li> - <li><a href="#compute" role="tab" data-toggle="tab">{% trans "Compute" %}</a></li> - <li><a href="#block-storage" role="tab" data-toggle="tab">{% trans "Block Storage" %}</a></li> - <li><a href="#object-storage" role="tab" data-toggle="tab">{% trans "Object Storage" %}</a></li> - <li><a href="#ceph-storage" role="tab" data-toggle="tab">{% trans "Ceph Storage" %}</a></li> - </ul> - </div> - <div class="col-md-10"> - <div class="tab-content panel panel-default configuration-panel"> - <div class="tab-pane active" id="global"> - {% for field in form.global_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="controller"> - {% for field in form.controller_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="compute"> - {% for field in form.compute_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="block-storage"> - {% for field in form.block_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="object-storage"> - {% for field in form.object_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - <div class="tab-pane" id="ceph-storage"> - {% for field in form.ceph_storage_fieldset %} - {% include 'horizon/common/_horizontal_field.html' with field=field %} - {% endfor %} - </div> - </div> - </div> - </form> - </div> - - <script type="text/javascript"> - (window.$ || window.addHorizonLoadEvent)(function () { - $(document).tooltip('hide'); // prevent horizon from adding tooltip - $('a.help-icon').click(function () { - return false; - }).popover({ - trigger: 'focus', - placement: 'right' - }); - $('a.password-button').popover({ - trigger: 'click', - placement: 'right' - }); - }); - </script> -{% endblock %} diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/simple_service_config.html b/tuskar_ui/infrastructure/parameters/templates/parameters/simple_service_config.html deleted file mode 100644 index 803fc3bb..00000000 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/simple_service_config.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% block title %}{% trans "Simple Service Configuration" %}{% endblock %} - -{% block page_header %} - {% include "horizon/common/_page_header.html" with title=_("Simple Service Configuration") %} -{% endblock %} - -{% block main %} - {% include "infrastructure/parameters/_simple_service_config.html" %} -{% endblock %} diff --git a/tuskar_ui/infrastructure/parameters/tests.py b/tuskar_ui/infrastructure/parameters/tests.py deleted file mode 100644 index 0d008884..00000000 --- a/tuskar_ui/infrastructure/parameters/tests.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf8 -*- -# -# 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. - -import contextlib - -from django.core import urlresolvers -from mock import patch, call, ANY # noqa -from openstack_dashboard.test.test_data import utils - -from tuskar_ui import api -from tuskar_ui.test import helpers as test -from tuskar_ui.test.test_data import tuskar_data - - -INDEX_URL = urlresolvers.reverse( - 'horizon:infrastructure:parameters:index') -SIMPLE_SERVICE_CONFIG_URL = urlresolvers.reverse( - 'horizon:infrastructure:parameters:simple_service_configuration') -ADVANCED_SERVICE_CONFIG_URL = urlresolvers.reverse( - 'horizon:infrastructure:parameters:advanced_service_configuration') - -TEST_DATA = utils.TestDataContainer() -tuskar_data.data(TEST_DATA) - - -class ParametersTest(test.BaseAdminViewTests): - - def test_index(self): - plans = [api.tuskar.Plan(plan) - for plan in self.tuskarclient_plans.list()] - roles = [api.tuskar.Role(role) - for role in self.tuskarclient_roles.list()] - - with contextlib.nested( - patch('tuskar_ui.api.tuskar.Plan.list', - return_value=plans), - patch('tuskar_ui.api.tuskar.Role.list', - return_value=roles), - ): - res = self.client.get(INDEX_URL) - - self.assertTemplateUsed(res, 'infrastructure/parameters/index.html') - - def test_simple_service_config_get(self): - plan = api.tuskar.Plan(self.tuskarclient_plans.first()) - role = api.tuskar.Role(self.tuskarclient_roles.first()) - with contextlib.nested( - patch('tuskar_ui.api.tuskar.Plan.get_the_plan', - return_value=plan), - patch('tuskar_ui.api.tuskar.Plan.get_role_by_name', - return_value=role), - ): - res = self.client.get(SIMPLE_SERVICE_CONFIG_URL) - self.assertTemplateUsed( - res, 'infrastructure/parameters/simple_service_config.html') - - def test_advanced_service_config_post(self): - plan = api.tuskar.Plan(self.tuskarclient_plans.first()) - roles = [api.tuskar.Role(role) - for role in self.tuskarclient_roles.list()] - parameters = [api.tuskar.Parameter(p, plan=self) - for p in plan.parameters] - - data = {p.name: unicode(p.value) for p in parameters} - - with contextlib.nested( - patch('tuskar_ui.api.tuskar.Plan.get_the_plan', - return_value=plan), - patch('tuskar_ui.api.tuskar.Plan.role_list', - return_value=roles), - patch('tuskar_ui.api.tuskar.Plan.parameter_list', - return_value=parameters), - patch('tuskar_ui.api.tuskar.Plan.patch', - return_value=plan), - ) as (get_the_plan, role_list, parameter_list, plan_patch): - res = self.client.post(ADVANCED_SERVICE_CONFIG_URL, data) - - self.assertRedirectsNoFollow(res, INDEX_URL) - - plan_patch.assert_called_once_with(ANY, plan.uuid, data) - - def test_simple_service_config_post(self): - plan = api.tuskar.Plan(self.tuskarclient_plans.first()) - roles = [api.tuskar.Role(role) for role in - self.tuskarclient_roles.list()] - plan.role_list = roles - - data = { - 'virt_type': 'qemu', - 'snmp_password': 'password', - 'cinder_iscsi_helper': 'lioadm', - 'cloud_name': 'cloud_name', - 'neutron_public_interface': 'eth0', - 'extra_config': '{}' - } - with contextlib.nested( - patch('tuskar_ui.api.tuskar.Plan.get_the_plan', - return_value=plan), - patch('tuskar_ui.api.tuskar.Plan.patch', - return_value=plan), - patch('tuskar_ui.api.tuskar.Plan.get_role_by_name', - return_value=roles[0]), - ) as (get_the_plan, plan_patch, get_role_by_name): - res = self.client.post(SIMPLE_SERVICE_CONFIG_URL, data) - - self.assertRedirectsNoFollow(res, INDEX_URL) - - plan_patch.assert_called_once_with(ANY, plan.uuid, { - 'Controller-1::CloudName': u'cloud_name', - 'Controller-1::SnmpdReadonlyUserPassword': u'password', - 'Controller-1::NeutronPublicInterface': u'eth0', - 'Controller-1::CinderISCSIHelper': u'lioadm', - 'Controller-1::NovaComputeLibvirtType': u'qemu', - 'Compute-1::SnmpdReadonlyUserPassword': u'password', - 'Controller-1::NtpServer': u'', - 'Controller-1::ExtraConfig': u'{}', - 'Compute-1::ExtraConfig': u'{}', - 'Block Storage-1::ExtraConfig': u'{}', - 'Object Storage-1::ExtraConfig': u'{}'}) diff --git a/tuskar_ui/infrastructure/parameters/urls.py b/tuskar_ui/infrastructure/parameters/urls.py deleted file mode 100644 index efadf7ea..00000000 --- a/tuskar_ui/infrastructure/parameters/urls.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf8 -*- -# -# 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 django.conf import urls - -from tuskar_ui.infrastructure.parameters import views - - -urlpatterns = urls.patterns( - '', - urls.url(r'^$', views.IndexView.as_view(), name='index'), - urls.url(r'^simple-service-config$', - views.SimpleServiceConfigView.as_view(), - name='simple_service_configuration'), - urls.url(r'^advanced-service-config$', - views.AdvancedServiceConfigView.as_view(), - name='advanced_service_configuration'), -) diff --git a/tuskar_ui/infrastructure/parameters/views.py b/tuskar_ui/infrastructure/parameters/views.py deleted file mode 100644 index b7748299..00000000 --- a/tuskar_ui/infrastructure/parameters/views.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf8 -*- -# -# 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 django.core.urlresolvers import reverse -from django.core.urlresolvers import reverse_lazy -from django.utils.translation import ugettext_lazy as _ -import horizon.forms -import horizon.tables - -from tuskar_ui import api -from tuskar_ui.infrastructure.parameters import forms - - -class SimpleServiceConfigView(horizon.forms.ModalFormView): - form_class = forms.SimpleEditServiceConfig - success_url = reverse_lazy('horizon:infrastructure:parameters:index') - submit_label = _("Save Configuration") - template_name = "infrastructure/parameters/simple_service_config.html" - - def get_initial(self): - plan = api.tuskar.Plan.get_the_plan(self.request) - compute_prefix = plan.get_role_by_name('Compute').parameter_prefix - controller_prefix = plan.get_role_by_name( - 'Controller').parameter_prefix - - cinder_iscsi_helper = plan.parameter_value( - controller_prefix + 'CinderISCSIHelper') - cloud_name = plan.parameter_value( - controller_prefix + 'CloudName') - extra_config = plan.parameter_value( - controller_prefix + 'ExtraConfig') - neutron_public_interface = plan.parameter_value( - controller_prefix + 'NeutronPublicInterface') - ntp_server = plan.parameter_value( - controller_prefix + 'NtpServer') - snmp_password = plan.parameter_value( - controller_prefix + 'SnmpdReadonlyUserPassword') - virt_type = plan.parameter_value( - compute_prefix + 'NovaComputeLibvirtType') - return { - 'cinder_iscsi_helper': cinder_iscsi_helper, - 'cloud_name': cloud_name, - 'neutron_public_interface': neutron_public_interface, - 'ntp_server': ntp_server, - 'extra_config': extra_config, - 'neutron_public_interface': neutron_public_interface, - 'snmp_password': snmp_password, - 'virt_type': virt_type} - - -class IndexView(horizon.forms.ModalFormView): - form_class = forms.ServiceConfig - form_id = "service_config" - template_name = "infrastructure/parameters/index.html" - - def get_initial(self): - self.plan = api.tuskar.Plan.get_the_plan(self.request) - self.parameters = self.plan.parameter_list( - include_key_parameters=False) - return {p.name: p.value for p in self.parameters} - - def get_context_data(self, **kwargs): - context = super(IndexView, self).get_context_data(**kwargs) - advanced_edit_action = { - 'name': _('Advanced Configuration'), - 'url': reverse('horizon:infrastructure:parameters:' - 'advanced_service_configuration'), - 'icon': 'fa-pencil', - 'ajax_modal': False, - } - simplified_edit_action = { - 'name': _('Simplified Configuration'), - 'url': reverse('horizon:infrastructure:parameters:' - 'simple_service_configuration'), - 'icon': 'fa-pencil-square-o', - 'ajax_modal': True, - } - context['header_actions'] = [advanced_edit_action, - simplified_edit_action] - return context - - -class AdvancedServiceConfigView(IndexView): - form_class = forms.AdvancedEditServiceConfig - form_id = "advanced_service_config" - success_url = reverse_lazy('horizon:infrastructure:parameters:index') - submit_label = _("Save Configuration") - submit_url = reverse_lazy('horizon:infrastructure:parameters:' - 'advanced_service_configuration') - template_name = "infrastructure/parameters/advanced_service_config.html" - - def get_context_data(self, **kwargs): - context = super(AdvancedServiceConfigView, - self) .get_context_data(**kwargs) - context['header_actions'] = [] - return context |