diff --git a/tuskar_ui/infrastructure/parameters/tables.py b/tuskar_ui/infrastructure/parameters/tables.py new file mode 100644 index 000000000..bb31ca62e --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/tables.py @@ -0,0 +1,32 @@ +# -*- 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 _ + +from horizon import tables + + +class ParametersTable(tables.DataTable): + label = tables.Column('label', + verbose_name=_("Parameter Name")) + value = tables.Column('value', + verbose_name=_("Default Value")) + description = tables.Column('description', + verbose_name=("Detailed Description")) + + class Meta: + name = "parameters" + verbose_name = _("Service Configuration") + table_actions = () + row_actions = () diff --git a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html index b50ba6e9a..fd3f10fdd 100644 --- a/tuskar_ui/infrastructure/parameters/templates/parameters/index.html +++ b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html @@ -1,6 +1,5 @@ {% extends 'infrastructure/base.html' %} {% load i18n %} -{% load url from future %} {% block title %}{% trans 'Service Configuration' %}{% endblock %} {% block page_header %} @@ -8,9 +7,12 @@ {% endblock page_header %} {% block main %} -
-
-

To Be Done

+
+
+
+ {{ table.render }} +
-{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/tuskar_ui/infrastructure/parameters/tests.py b/tuskar_ui/infrastructure/parameters/tests.py index 8ec1b3bec..78962db50 100644 --- a/tuskar_ui/infrastructure/parameters/tests.py +++ b/tuskar_ui/infrastructure/parameters/tests.py @@ -29,6 +29,8 @@ INDEX_URL = urlresolvers.reverse( TEST_DATA = utils.TestDataContainer() tuskar_data.data(TEST_DATA) +from tuskar_ui.infrastructure.parameters import views + class ParametersTest(test.BaseAdminViewTests): @@ -47,3 +49,13 @@ class ParametersTest(test.BaseAdminViewTests): res = self.client.get(INDEX_URL) self.assertTemplateUsed(res, 'infrastructure/parameters/index.html') + + def test_param_object(self): + param_dict = {'parameter_group': 'Neutron', + 'default': '1.2.3.4', + 'name': 'Ip Address', + 'description': 'This is an IP Address'} + + p = views.ServiceParameter(param_dict, 5) + self.assertEqual(p.id, 5) + self.assertEqual(p.value, '1.2.3.4') diff --git a/tuskar_ui/infrastructure/parameters/views.py b/tuskar_ui/infrastructure/parameters/views.py index 4893c8260..ff2eb6a4c 100644 --- a/tuskar_ui/infrastructure/parameters/views.py +++ b/tuskar_ui/infrastructure/parameters/views.py @@ -12,17 +12,29 @@ # License for the specific language governing permissions and limitations # under the License. -from horizon import views as horizon_views +from horizon import tables as horizon_tables from tuskar_ui import api +from tuskar_ui.infrastructure.parameters import tables -class IndexView(horizon_views.APIView): - template_name = 'infrastructure/parameters/index.html' +class ServiceParameter: + def __init__(self, params_dict, id): + self.id = id + self.label = params_dict.get('name') + self.value = params_dict.get('default') + self.category = params_dict.get('parameter_group') + self.description = params_dict.get('description') - def get_data(self, request, context, *args, **kwargs): + +class IndexView(horizon_tables.DataTableView): + table_class = tables.ParametersTable + template_name = "infrastructure/parameters/index.html" + + def get_data(self): plan = api.tuskar.OvercloudPlan.get_the_plan(self.request) - context['plan'] = plan - context['plan_parameters'] = plan.parameter_list( + base_parameters = plan.parameter_list( include_key_parameters=False) - return context + params = [ServiceParameter(param, ind) + for ind, param in enumerate(base_parameters)] + return params diff --git a/tuskar_ui/test/test_data/tuskar_data.py b/tuskar_ui/test/test_data/tuskar_data.py index 4b9997421..40f05986e 100644 --- a/tuskar_ui/test/test_data/tuskar_data.py +++ b/tuskar_ui/test/test_data/tuskar_data.py @@ -29,6 +29,7 @@ def data(TEST): 'template': '', 'created_at': '2014-05-27T21:11:09Z', 'modified_at': '2014-05-30T21:11:09Z', + 'uuid': '1234567890', 'roles': [ { 'uuid': 'role-1', @@ -122,13 +123,17 @@ def data(TEST): 'description': '', 'no_echo': 'false', 'default': '', + 'label': 'Keystone Host', + 'value': '' }, { 'name': 'object_storage_SwiftHashSuffix', 'parameter_group': 'Swift', + 'label': 'Swift Object Storage Hash Suffix', 'type': 'String', 'description': '', 'no_echo': 'true', 'default': '', + 'value': '' }, { 'name': 'block_storage_NeutronNetworkType', 'parameter_group': 'Neutron',