From aa23f55ece898c5bc95272e6baf2a082b8227312 Mon Sep 17 00:00:00 2001 From: Tzu-Mainn Chen Date: Fri, 1 Aug 2014 22:32:24 +0200 Subject: [PATCH] Add Service Configuration panel and test Role parameter data Adds the service configuration panel, with a placeholder index view so that others can grow it into something truly beauteous. Also adds sample role parameter data. Change-Id: I77ddc3688d256d68b19ba69e12867cc9861bf82c --- tuskar_ui/api/tuskar.py | 6 ++- tuskar_ui/infrastructure/dashboard.py | 1 + .../infrastructure/parameters/__init__.py | 0 tuskar_ui/infrastructure/parameters/panel.py | 27 ++++++++++ .../templates/parameters/index.html | 23 ++++++++ tuskar_ui/infrastructure/parameters/tests.py | 31 +++++++++++ tuskar_ui/infrastructure/parameters/urls.py | 23 ++++++++ tuskar_ui/infrastructure/parameters/views.py | 27 ++++++++++ tuskar_ui/test/api_tests/tuskar_tests.py | 3 +- tuskar_ui/test/test_data/tuskar_data.py | 52 +++++++++++++++---- 10 files changed, 179 insertions(+), 14 deletions(-) create mode 100644 tuskar_ui/infrastructure/parameters/__init__.py create mode 100644 tuskar_ui/infrastructure/parameters/panel.py create mode 100644 tuskar_ui/infrastructure/parameters/templates/parameters/index.html create mode 100644 tuskar_ui/infrastructure/parameters/tests.py create mode 100644 tuskar_ui/infrastructure/parameters/urls.py create mode 100644 tuskar_ui/infrastructure/parameters/views.py diff --git a/tuskar_ui/api/tuskar.py b/tuskar_ui/api/tuskar.py index 776f7dae3..0e1e10122 100644 --- a/tuskar_ui/api/tuskar.py +++ b/tuskar_ui/api/tuskar.py @@ -148,7 +148,8 @@ class OvercloudPlan(base.APIDictWrapper): @cached_property def role_list(self): - return [OvercloudRole(role) for role in self.roles] + return [OvercloudRole.get(self._request, role['id']) + for role in self.roles] def parameter(self, param_name): for parameter in self.parameters: @@ -162,7 +163,8 @@ class OvercloudPlan(base.APIDictWrapper): class OvercloudRole(base.APIDictWrapper): - _attrs = ('id', 'name', 'version', 'description', 'created_at') + _attrs = ('id', 'name', 'version', 'description', 'created_at', + 'parameters') @classmethod @handle_errors(_("Unable to retrieve overcloud roles"), []) diff --git a/tuskar_ui/infrastructure/dashboard.py b/tuskar_ui/infrastructure/dashboard.py index b63e3f558..2d44e1f30 100644 --- a/tuskar_ui/infrastructure/dashboard.py +++ b/tuskar_ui/infrastructure/dashboard.py @@ -22,6 +22,7 @@ class BasePanels(horizon.PanelGroup): panels = ( 'overcloud', 'plans', + 'parameters', 'nodes', 'flavors', 'history', diff --git a/tuskar_ui/infrastructure/parameters/__init__.py b/tuskar_ui/infrastructure/parameters/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tuskar_ui/infrastructure/parameters/panel.py b/tuskar_ui/infrastructure/parameters/panel.py new file mode 100644 index 000000000..1e5d42e91 --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/panel.py @@ -0,0 +1,27 @@ +# -*- 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/index.html b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html new file mode 100644 index 000000000..f1d812669 --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/templates/parameters/index.html @@ -0,0 +1,23 @@ +{% extends 'infrastructure/base.html' %} +{% load i18n %} +{% load url from future %} +{% block title %}{% trans 'Service Configuration' %}{% endblock %} + +{% block page_header %} + {% include 'horizon/common/_page_header.html' with title=title %} +{% endblock page_header %} + +{% block main %} +
+
+ {% for role in roles %} + {{ role.name }} +
    + {% for p in role.parameters %} +
  • {{ p.name }}
  • + {% endfor %} +
+ {% endfor %} +
+
+{% endblock %} diff --git a/tuskar_ui/infrastructure/parameters/tests.py b/tuskar_ui/infrastructure/parameters/tests.py new file mode 100644 index 000000000..530b88980 --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/tests.py @@ -0,0 +1,31 @@ +# -*- 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 import urlresolvers + +from mock import patch, call # noqa + +from tuskar_ui.test import helpers as test + + +INDEX_URL = urlresolvers.reverse( + 'horizon:infrastructure:parameters:index') + + +class ParametersTest(test.BaseAdminViewTests): + + def test_index(self): + res = self.client.get(INDEX_URL) + + self.assertTemplateUsed(res, 'infrastructure/parameters/index.html') diff --git a/tuskar_ui/infrastructure/parameters/urls.py b/tuskar_ui/infrastructure/parameters/urls.py new file mode 100644 index 000000000..0f9052a52 --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/urls.py @@ -0,0 +1,23 @@ +# -*- 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'), +) diff --git a/tuskar_ui/infrastructure/parameters/views.py b/tuskar_ui/infrastructure/parameters/views.py new file mode 100644 index 000000000..250b056dc --- /dev/null +++ b/tuskar_ui/infrastructure/parameters/views.py @@ -0,0 +1,27 @@ +# -*- 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 horizon import views as horizon_views + +from tuskar_ui import api + + +class IndexView(horizon_views.APIView): + template_name = 'infrastructure/parameters/index.html' + + def get_data(self, request, context, *args, **kwargs): + plan = api.tuskar.OvercloudPlan.get_the_plan(self.request) + context['plan'] = plan + context['roles'] = plan.role_list + return context diff --git a/tuskar_ui/test/api_tests/tuskar_tests.py b/tuskar_ui/test/api_tests/tuskar_tests.py index 4f14e33cf..35f75077a 100644 --- a/tuskar_ui/test/api_tests/tuskar_tests.py +++ b/tuskar_ui/test/api_tests/tuskar_tests.py @@ -44,7 +44,6 @@ class TuskarAPITests(test.APITestCase): plan = api.tuskar.OvercloudPlan(self.tuskarclient_plans.first()) ret_val = plan.role_list - self.assertEqual(4, len(ret_val)) for r in ret_val: self.assertIsInstance(r, api.tuskar.OvercloudRole) @@ -54,7 +53,7 @@ class TuskarAPITests(test.APITestCase): for r in ret_val: self.assertIsInstance(r, api.tuskar.OvercloudRole) - self.assertEqual(5, len(ret_val)) + self.assertEqual(4, len(ret_val)) def test_role_get(self): role = self.tuskarclient_roles.first() diff --git a/tuskar_ui/test/test_data/tuskar_data.py b/tuskar_ui/test/test_data/tuskar_data.py index 5fee10136..23b0187ba 100644 --- a/tuskar_ui/test/test_data/tuskar_data.py +++ b/tuskar_ui/test/test_data/tuskar_data.py @@ -36,9 +36,9 @@ def data(TEST): 'name': 'Object Storage', 'version': 1, }, { - 'id': 'role-5', + 'id': 'role-4', 'name': 'Block Storage', - 'version': 2, + 'version': 1, }], 'parameters': [{ 'name': 'AdminPassword', @@ -58,6 +58,21 @@ def data(TEST): 'version': 1, 'description': 'controller role', 'created_at': '2014-05-27T21:11:09Z', + 'parameters': [{ + 'name': 'controller_NovaInterfaces', + 'parameter_group': 'Nova', + 'type': 'String', + 'description': '', + 'no_echo': 'false', + 'default': 'eth0', + }, { + 'name': 'controller_NeutronInterfaces', + 'parameter_group': 'Neutron', + 'type': 'String', + 'description': '', + 'no_echo': 'false', + 'default': 'eth0', + }] } r_2 = { 'id': 'role-2', @@ -65,6 +80,14 @@ def data(TEST): 'version': 1, 'description': 'compute role', 'created_at': '2014-05-27T21:11:09Z', + 'parameters': [{ + 'name': 'compute_KeystoneHost', + 'parameter_group': 'Keystone', + 'type': 'String', + 'description': '', + 'no_echo': 'false', + 'default': '', + }] } r_3 = { 'id': 'role-3', @@ -72,6 +95,14 @@ def data(TEST): 'version': 1, 'description': 'object storage role', 'created_at': '2014-05-27T21:11:09Z', + 'parameters': [{ + 'name': 'object_storage_SwiftHashSuffix', + 'parameter_group': 'Swift', + 'type': 'String', + 'description': '', + 'no_echo': 'true', + 'default': '', + }] } r_4 = { 'id': 'role-4', @@ -79,12 +110,13 @@ def data(TEST): 'version': 1, 'description': 'block storage role', 'created_at': '2014-05-27T21:11:09Z', + 'parameters': [{ + 'name': 'block_storage_NeutronNetworkType', + 'parameter_group': 'Neutron', + 'type': 'String', + 'description': '', + 'no_echo': 'false', + 'default': 'gre', + }] } - r_5 = { - 'id': 'role-5', - 'name': 'Block Storage', - 'version': 2, - 'description': 'block storage role', - 'created_at': '2014-05-28T21:11:09Z', - } - TEST.tuskarclient_roles.add(r_1, r_2, r_3, r_4, r_5) + TEST.tuskarclient_roles.add(r_1, r_2, r_3, r_4)