From 446a9bc7c73adc1864dfb38b0e5eb7693200a3bd Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Tue, 22 Oct 2013 15:37:53 +0400 Subject: [PATCH] Move Murano panel (named 'Environments') to a separate dashboard. Change-Id: I1c0c6bd250c8f4f6ab57ba611d5d56224ef9fbfb --- muranodashboard/dashboard.py | 32 +++++ .../{panel => environments}/__init__.py | 0 .../{panel => environments}/api.py | 2 +- .../{panel => environments}/consts.py | 0 .../{panel => environments}/forms.py | 2 +- .../{panel => environments}/panel.py | 8 +- .../services/__init__.py | 4 +- .../services/fields.py | 2 +- .../{panel => environments}/services/forms.py | 4 +- .../services/helpers.py | 0 .../environments/services/metadata.py | 122 ++++++++++++++++++ .../{panel => environments}/tables.py | 36 +++--- .../{panel => environments}/tabs.py | 8 +- .../{panel => environments}/urls.py | 2 +- .../{panel => environments}/views.py | 41 +++--- .../{panel => environments}/workflows.py | 6 +- muranodashboard/settings.py | 7 +- .../templates/deployments/_page_header.html | 2 +- .../deployments/_reports_page_header.html | 4 +- .../services/_detail_page_header.html | 4 +- .../templates/services/_page_header.html | 2 +- .../templates/services/_wizard_create.html | 2 +- .../{panel/overrides.py => views.py} | 8 +- 23 files changed, 227 insertions(+), 71 deletions(-) create mode 100644 muranodashboard/dashboard.py rename muranodashboard/{panel => environments}/__init__.py (100%) rename muranodashboard/{panel => environments}/api.py (99%) rename muranodashboard/{panel => environments}/consts.py (100%) rename muranodashboard/{panel => environments}/forms.py (97%) rename muranodashboard/{panel => environments}/panel.py (83%) rename muranodashboard/{panel => environments}/services/__init__.py (97%) rename muranodashboard/{panel => environments}/services/fields.py (99%) rename muranodashboard/{panel => environments}/services/forms.py (98%) rename muranodashboard/{panel => environments}/services/helpers.py (100%) create mode 100644 muranodashboard/environments/services/metadata.py rename muranodashboard/{panel => environments}/tables.py (91%) rename muranodashboard/{panel => environments}/tabs.py (94%) rename muranodashboard/{panel => environments}/urls.py (97%) rename muranodashboard/{panel => environments}/views.py (91%) rename muranodashboard/{panel => environments}/workflows.py (96%) rename muranodashboard/{panel/overrides.py => views.py} (77%) diff --git a/muranodashboard/dashboard.py b/muranodashboard/dashboard.py new file mode 100644 index 000000000..19c7f398a --- /dev/null +++ b/muranodashboard/dashboard.py @@ -0,0 +1,32 @@ +# Copyright (c) 2013 Mirantis, Inc. +# +# 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 horizon +from django.utils.translation import ugettext_lazy as _ + + +class DeployPanels(horizon.PanelGroup): + slug = "deployment_group" + name = _("Deployment") + panels = ('environments',) + + +class Murano(horizon.Dashboard): + name = _("Murano") + slug = "murano" + panels = (DeployPanels,) + default_panel = 'environments' + supports_tenants = True + + +horizon.register(Murano) diff --git a/muranodashboard/panel/__init__.py b/muranodashboard/environments/__init__.py similarity index 100% rename from muranodashboard/panel/__init__.py rename to muranodashboard/environments/__init__.py diff --git a/muranodashboard/panel/api.py b/muranodashboard/environments/api.py similarity index 99% rename from muranodashboard/panel/api.py rename to muranodashboard/environments/api.py index 4021f7d37..91d4291a9 100644 --- a/muranodashboard/panel/api.py +++ b/muranodashboard/environments/api.py @@ -20,7 +20,7 @@ from horizon.exceptions import ServiceCatalogException from muranoclient.common.exceptions import HTTPForbidden, HTTPNotFound from openstack_dashboard.api.base import url_for from muranoclient.v1.client import Client -from muranodashboard.panel.services import get_service_name +from muranodashboard.environments.services import get_service_name from consts import STATUS_ID_READY, STATUS_ID_NEW log = logging.getLogger(__name__) diff --git a/muranodashboard/panel/consts.py b/muranodashboard/environments/consts.py similarity index 100% rename from muranodashboard/panel/consts.py rename to muranodashboard/environments/consts.py diff --git a/muranodashboard/panel/forms.py b/muranodashboard/environments/forms.py similarity index 97% rename from muranodashboard/panel/forms.py rename to muranodashboard/environments/forms.py index 6eb6e5088..e85a1ff43 100644 --- a/muranodashboard/panel/forms.py +++ b/muranodashboard/environments/forms.py @@ -20,7 +20,7 @@ from horizon import messages, exceptions from openstack_dashboard.api import glance import json -from muranodashboard.panel.services import get_service_choices +from muranodashboard.environments.services import get_service_choices log = logging.getLogger(__name__) diff --git a/muranodashboard/panel/panel.py b/muranodashboard/environments/panel.py similarity index 83% rename from muranodashboard/panel/panel.py rename to muranodashboard/environments/panel.py index 71c96f62f..0300480e6 100644 --- a/muranodashboard/panel/panel.py +++ b/muranodashboard/environments/panel.py @@ -14,12 +14,12 @@ import horizon from django.utils.translation import ugettext_lazy as _ -from openstack_dashboard.dashboards.project import dashboard +from muranodashboard import dashboard -class Panel(horizon.Panel): +class Environments(horizon.Panel): name = _("Environments") - slug = 'murano' + slug = 'environments' -dashboard.Project.register(Panel) +dashboard.Murano.register(Environments) diff --git a/muranodashboard/panel/services/__init__.py b/muranodashboard/environments/services/__init__.py similarity index 97% rename from muranodashboard/panel/services/__init__.py rename to muranodashboard/environments/services/__init__.py index f31c07f38..fa0c8c215 100644 --- a/muranodashboard/panel/services/__init__.py +++ b/muranodashboard/environments/services/__init__.py @@ -33,7 +33,7 @@ _last_check_time = 0 class Service(object): def __init__(self, **kwargs): - import muranodashboard.panel.services.forms as services + import muranodashboard.environments.services.forms as services for key, value in kwargs.iteritems(): if key == 'forms': self.forms = [] @@ -64,7 +64,7 @@ class Service(object): def import_service(filename, service_file): - from muranodashboard.panel.services.helpers import decamelize + from muranodashboard.environments.services.helpers import decamelize try: with open(service_file) as stream: yaml_desc = yaml.load(stream) diff --git a/muranodashboard/panel/services/fields.py b/muranodashboard/environments/services/fields.py similarity index 99% rename from muranodashboard/panel/services/fields.py rename to muranodashboard/environments/services/fields.py index a2f899ff1..6dbca5eb9 100644 --- a/muranodashboard/panel/services/fields.py +++ b/muranodashboard/environments/services/fields.py @@ -19,7 +19,7 @@ from django.core.validators import RegexValidator, validate_ipv4_address from netaddr import all_matching_cidrs from django.utils.translation import ugettext_lazy as _ from django.utils.encoding import smart_text -from muranodashboard.panel import api +from muranodashboard.environments import api from horizon import exceptions, messages from openstack_dashboard.api import glance from openstack_dashboard.api.nova import novaclient diff --git a/muranodashboard/panel/services/forms.py b/muranodashboard/environments/services/forms.py similarity index 98% rename from muranodashboard/panel/services/forms.py rename to muranodashboard/environments/services/forms.py index 3cf8b8ef0..e4aeb53ed 100644 --- a/muranodashboard/panel/services/forms.py +++ b/muranodashboard/environments/services/forms.py @@ -17,8 +17,8 @@ import logging from django import forms from django.core.validators import RegexValidator from django.utils.translation import ugettext_lazy as _ -import muranodashboard.panel.services.fields as fields -import muranodashboard.panel.services.helpers as helpers +import muranodashboard.environments.services.fields as fields +import muranodashboard.environments.services.helpers as helpers import yaql import types diff --git a/muranodashboard/panel/services/helpers.py b/muranodashboard/environments/services/helpers.py similarity index 100% rename from muranodashboard/panel/services/helpers.py rename to muranodashboard/environments/services/helpers.py diff --git a/muranodashboard/environments/services/metadata.py b/muranodashboard/environments/services/metadata.py new file mode 100644 index 000000000..5641863e8 --- /dev/null +++ b/muranodashboard/environments/services/metadata.py @@ -0,0 +1,122 @@ +# Copyright (c) 2013 Mirantis, Inc. +# +# 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 tempfile +from django.conf import settings +import os.path +import os +import tarfile +import logging +import shutil +import hashlib + + +CHUNK_SIZE = 1 << 20 # 1MB +ARCHIVE_PKG_NAME = 'archive.tar.gz' +ARCHIVE_SUBDIR = 'service_forms' +CACHE_DIR = getattr(settings, 'UI_METADATA_CACHE_DIR', + os.path.join(os.path.dirname(os.path.abspath(__file__)), + '../../cache/')) +if not os.path.exists(CACHE_DIR): + os.mkdir(CACHE_DIR) + +ARCHIVE_PKG_PATH = os.path.join(CACHE_DIR, ARCHIVE_PKG_NAME) +ARCHIVE_SUBDIR_PATH = os.path.join(CACHE_DIR, ARCHIVE_SUBDIR) + +log = logging.getLogger(__name__) + + +from horizon.exceptions import ServiceCatalogException +from openstack_dashboard.api.base import url_for +from metadataclient.v1.client import Client + + +def get_endpoint(request): + # prefer location specified in settings for dev purposes + endpoint = getattr(settings, 'MURANO_METADATA_URL', None) + + if not endpoint: + try: + endpoint = url_for(request, 'murano-metadata') + except ServiceCatalogException: + endpoint = 'http://localhost:5000' + log.warning( + 'Murano Metadata API location could not be found in Service ' + 'Catalog, using default: {0}'.format(endpoint)) + return endpoint + + +def metadataclient(request): + endpoint = get_endpoint(request) + token_id = request.user.token.id + log.debug('Murano::Client '.format(endpoint, token_id)) + + return Client(endpoint=endpoint, token=token_id) + + +def get_hash(archive_path): + """Calculate SHA1-hash of archive file. + + SHA-1 take a bit more time than MD5 (see http://tinyurl.com/kpj5jy7), + but is more secure. + """ + if os.path.exists(archive_path): + sha1 = hashlib.sha1() + with open(archive_path) as f: + buf = f.read(CHUNK_SIZE) + while buf: + sha1.update(buf) + buf = f.read(CHUNK_SIZE) + hsum = sha1.hexdigest() + log.debug("Archive '{0}' has hash-sum {1}".format(archive_path, hsum)) + return hsum + else: + log.info("Archive '{0}' doesn't exist, no hash to calculate".format( + archive_path)) + return None + + +def unpack_ui_package(archive_path): + if not tarfile.is_tarfile(archive_path): + raise RuntimeError("{0} is not valid tarfile!".format(archive_path)) + dst_dir = os.path.dirname(os.path.abspath(archive_path)) + with tarfile.open(archive_path, 'r:gz') as tar: + tar.extractall(path=dst_dir) + return os.path.join(dst_dir, ARCHIVE_SUBDIR) + + +def get_ui_metadata(request): + """Returns directory with unpacked definitions provided by Metadata + Repository at `endpoint' URL or, if it was not found or some error has + occurred, returns None. + """ + log.debug("Retrieving metadata from Repository") + response, body_iter = metadataclient(request).metadata_client.get_ui_data( + get_hash(ARCHIVE_PKG_PATH)) + code = response.status + if code == 200: + with tempfile.NamedTemporaryFile(delete=False) as out: + for chunk in body_iter: + out.write(chunk) + if os.path.exists(ARCHIVE_PKG_PATH): + os.remove(ARCHIVE_PKG_PATH) + shutil.move(out.name, ARCHIVE_PKG_PATH) + log.info("Successfully downloaded new metadata package to {0}".format( + ARCHIVE_PKG_PATH)) + return unpack_ui_package(ARCHIVE_PKG_PATH), True + elif code == 304: + log.info("Metadata package hash-sum hasn't changed, doing nothing") + return ARCHIVE_SUBDIR_PATH, False + else: + raise RuntimeError('Unexpected response received: {0}'.format(code)) diff --git a/muranodashboard/panel/tables.py b/muranodashboard/environments/tables.py similarity index 91% rename from muranodashboard/panel/tables.py rename to muranodashboard/environments/tables.py index 4f07a6170..1dba63280 100644 --- a/muranodashboard/panel/tables.py +++ b/muranodashboard/environments/tables.py @@ -21,7 +21,7 @@ from horizon import tables from horizon import messages from openstack_dashboard.api import glance -from muranodashboard.panel import api +from muranodashboard.environments import api from muranodashboard.openstack.common import timeutils from consts import STATUS_ID_DEPLOYING from consts import STATUS_CHOICES @@ -33,7 +33,7 @@ from consts import DEPLOYMENT_STATUS_DISPLAY_CHOICES class CreateService(tables.LinkAction): name = 'CreateService' verbose_name = _('Create Service') - url = 'horizon:project:murano:create' + url = 'horizon:murano:environments:create' classes = ('btn-launch', 'ajax-modal') def allowed(self, request, environment): @@ -47,7 +47,7 @@ class CreateService(tables.LinkAction): class CreateEnvironment(tables.LinkAction): name = 'CreateEnvironment' verbose_name = _('Create Environment') - url = 'horizon:project:murano:create_environment' + url = 'horizon:murano:environments:create_environment' classes = ('btn-launch', 'ajax-modal') def allowed(self, request, datum): @@ -60,7 +60,7 @@ class CreateEnvironment(tables.LinkAction): class MuranoImages(tables.LinkAction): name = 'show_images' verbose_name = _('Murano Images') - url = 'horizon:project:murano:murano_images' + url = 'horizon:murano:environments:murano_images' def allowed(self, request, environment): return True @@ -88,7 +88,7 @@ class DeleteEnvironment(tables.DeleteAction): class EditEnvironment(tables.LinkAction): name = 'edit' verbose_name = _('Edit Environment') - url = 'horizon:project:murano:update_environment' + url = 'horizon:murano:environments:update_environment' classes = ('ajax-modal', 'btn-edit') def allowed(self, request, environment): @@ -119,7 +119,7 @@ class DeleteService(tables.DeleteAction): service_id) except: msg = _('Sorry, you can\'t delete service right now') - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") exceptions.handle(request, msg, redirect=redirect) @@ -144,7 +144,7 @@ class DeployEnvironment(tables.BatchAction): api.environment_deploy(request, environment_id) except Exception: msg = _('Unable to deploy. Try again later') - redirect = reverse('horizon:project:murano:index') + redirect = reverse('horizon:murano:environments:index') exceptions.handle(request, msg, redirect=redirect) @@ -172,16 +172,18 @@ class DeployThisEnvironment(tables.Action): messages.success(request, _('Deploy started')) except: msg = _('Unable to deploy. Try again later') - exceptions.handle(request, msg, - redirect=reverse('horizon:project:murano:index')) - return shortcuts.redirect(reverse('horizon:project:murano:services', - args=(environment_id,))) + exceptions.handle( + request, msg, + redirect=reverse('horizon:murano:environments:index')) + return shortcuts.redirect( + reverse('horizon:murano:environments:services', + args=(environment_id,))) class ShowEnvironmentServices(tables.LinkAction): name = 'show' verbose_name = _('Services') - url = 'horizon:project:murano:services' + url = 'horizon:murano:environments:services' def allowed(self, request, environment): return True @@ -205,7 +207,7 @@ class UpdateServiceRow(tables.Row): class ShowDeployments(tables.LinkAction): name = 'show_deployments' verbose_name = _('Show Deployments') - url = 'horizon:project:murano:deployments' + url = 'horizon:murano:environments:deployments' def allowed(self, request, environment): return environment.status != STATUS_ID_NEW @@ -213,7 +215,7 @@ class ShowDeployments(tables.LinkAction): class EnvironmentsTable(tables.DataTable): name = tables.Column('name', - link='horizon:project:murano:services', + link='horizon:murano:environments:services', verbose_name=_('Name')) status = tables.Column('status', @@ -233,7 +235,7 @@ class EnvironmentsTable(tables.DataTable): def get_service_details_link(service): - return reverse('horizon:project:murano:service_details', + return reverse('horizon:murano:environments:service_details', args=(service.environment_id, service.id)) @@ -276,7 +278,7 @@ class ShowDeploymentDetails(tables.LinkAction): def get_link_url(self, deployment=None): kwargs = {'environment_id': deployment.environment_id, 'deployment_id': deployment.id} - return reverse('horizon:project:murano:deployment_details', + return reverse('horizon:murano:environments:deployment_details', kwargs=kwargs) def allowed(self, request, environment): @@ -317,7 +319,7 @@ class EnvConfigTable(tables.DataTable): class AddMuranoImage(tables.LinkAction): name = "add_image" verbose_name = _("Add Image") - url = "horizon:project:murano:add_image" + url = "horizon:murano:environments:add_image" classes = ("ajax-modal", "btn-create") def allowed(self, request, image): diff --git a/muranodashboard/panel/tabs.py b/muranodashboard/environments/tabs.py similarity index 94% rename from muranodashboard/panel/tabs.py rename to muranodashboard/environments/tabs.py index b7982a7e7..b5e319840 100644 --- a/muranodashboard/panel/tabs.py +++ b/muranodashboard/environments/tabs.py @@ -17,11 +17,13 @@ import logging from django.utils.translation import ugettext_lazy as _ from django.utils.datastructures import SortedDict from horizon import tabs -from muranodashboard.panel.consts import LOG_LEVEL_TO_COLOR, LOG_LEVEL_TO_TEXT +from muranodashboard.environments.consts import LOG_LEVEL_TO_COLOR +from muranodashboard.environments.consts import LOG_LEVEL_TO_TEXT from openstack_dashboard.api import nova as nova_api -from muranodashboard.panel import api -from muranodashboard.panel.tables import STATUS_DISPLAY_CHOICES, EnvConfigTable +from muranodashboard.environments import api +from muranodashboard.environments.tables import STATUS_DISPLAY_CHOICES +from muranodashboard.environments.tables import EnvConfigTable LOG = logging.getLogger(__name__) diff --git a/muranodashboard/panel/urls.py b/muranodashboard/environments/urls.py similarity index 97% rename from muranodashboard/panel/urls.py rename to muranodashboard/environments/urls.py index 1a75e7f72..f0008dd13 100644 --- a/muranodashboard/panel/urls.py +++ b/muranodashboard/environments/urls.py @@ -26,7 +26,7 @@ from services import get_service_checkers from services import make_forms_getter from openstack_dashboard.dashboards.project.instances.views import DetailView -VIEW_MOD = 'openstack_dashboard.dashboards.project.murano.views' +VIEW_MOD = 'muranodashboard.environments.views' ENVIRONMENT_ID = r'^(?P[^/]+)' diff --git a/muranodashboard/panel/views.py b/muranodashboard/environments/views.py similarity index 91% rename from muranodashboard/panel/views.py rename to muranodashboard/environments/views.py index a2bf51ece..59c144d47 100644 --- a/muranodashboard/panel/views.py +++ b/muranodashboard/environments/views.py @@ -103,7 +103,7 @@ class Wizard(ModalFormMixin, LazyWizard): link = self.request.__dict__['META']['HTTP_REFERER'] environment_id = re.search('murano/(\w+)', link).group(0)[7:] - url = reverse('horizon:project:murano:services', + url = reverse('horizon:murano:environments:services', args=(environment_id,)) step0_data = form_list[0].cleaned_data @@ -118,10 +118,10 @@ class Wizard(ModalFormMixin, LazyWizard): except HTTPForbidden: msg = _('Sorry, you can\'t create service right now.' 'The environment is deploying.') - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, msg, redirect=redirect) except Exception: - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, _('Sorry, you can\'t create service right now.'), redirect=redirect) @@ -189,26 +189,25 @@ class Services(tables.DataTableView): except: msg = _('Sorry, this environment does\'t exist anymore') - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, msg, redirect=redirect) return context def get_data(self): services = [] self.environment_id = self.kwargs['environment_id'] + ns_url = "horizon:murano:environments:index" try: services = api.services_list(self.request, self.environment_id) except HTTPForbidden: msg = _('Unable to retrieve list of services. This environment ' 'is deploying or already deployed by other user.') - exceptions.handle(self.request, msg, - redirect=reverse("horizon:project:murano:index")) + exceptions.handle(self.request, msg, redirect=reverse(ns_url)) except HTTPInternalServerError: msg = _('Environment with id %s doesn\'t exist anymore' % self.environment_id) - exceptions.handle(self.request, msg, - redirect=reverse("horizon:project:murano:index")) + exceptions.handle(self.request, msg, redirect=reverse(ns_url)) except HTTPUnauthorized: exceptions.handle(self.request) return services @@ -237,7 +236,7 @@ class DetailServiceView(tabs.TabView): exceptions.handle(self.request) except HTTPForbidden: - redirect = reverse('horizon:project:murano:index') + redirect = reverse('horizon:murano:environments:index') exceptions.handle(self.request, _('Unable to retrieve details for ' 'service'), @@ -265,7 +264,7 @@ class CreateEnvironmentView(workflows.WorkflowView): class EditEnvironmentView(workflows.WorkflowView): workflow_class = UpdateEnvironment template_name = 'environments/update.html' - success_url = reverse_lazy("horizon:project:murano:index") + success_url = reverse_lazy("horizon:murano:environments:index") def get_context_data(self, **kwargs): context = super(EditEnvironmentView, self).get_context_data(**kwargs) @@ -279,7 +278,7 @@ class EditEnvironmentView(workflows.WorkflowView): self._object = \ api.environment_get(self.request, environment_id) except: - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") msg = _('Unable to retrieve environment details.') exceptions.handle(self.request, msg, redirect=redirect) return self._object @@ -306,27 +305,26 @@ class DeploymentsView(tables.DataTableView): context['environment_name'] = environment_name except: msg = _('Sorry, this environment does\'t exist anymore') - redirect = reverse("horizon:project:murano:index") + redirect = reverse("horizon:murano:environments:index") exceptions.handle(self.request, msg, redirect=redirect) return context def get_data(self): deployments = [] self.environment_id = self.kwargs['environment_id'] + ns_url = "horizon:murano:environments:index" try: deployments = api.deployments_list(self.request, self.environment_id) except HTTPForbidden: msg = _('Unable to retrieve list of deployments') - exceptions.handle(self.request, msg, - redirect=reverse("horizon:project:murano:index")) + exceptions.handle(self.request, msg, redirect=reverse(ns_url)) except HTTPInternalServerError: msg = _('Environment with id %s doesn\'t exist anymore' % self.environment_id) - exceptions.handle(self.request, msg, - redirect=reverse("horizon:project:murano:index")) + exceptions.handle(self.request, msg, redirect=reverse(ns_url)) return deployments @@ -355,7 +353,7 @@ class DeploymentDetailsView(tabs.TabbedTableView): except (HTTPInternalServerError, HTTPNotFound): msg = _('Deployment with id %s doesn\'t exist anymore' % self.deployment_id) - redirect = reverse("horizon:project:murano:deployments") + redirect = reverse("horizon:murano:environments:deployments") exceptions.handle(self.request, msg, redirect=redirect) return deployment @@ -368,7 +366,7 @@ class DeploymentDetailsView(tabs.TabbedTableView): except (HTTPInternalServerError, HTTPNotFound): msg = _('Deployment with id %s doesn\'t exist anymore' % self.deployment_id) - redirect = reverse("horizon:project:murano:deployments") + redirect = reverse("horizon:murano:environments:deployments") exceptions.handle(self.request, msg, redirect=redirect) return logs @@ -393,8 +391,9 @@ class MuranoImageView(tables.DataTableView): except HTTPForbidden: msg = _('Unable to retrieve list of images') - exceptions.handle(self.request, msg, - redirect=reverse("horizon:project:murano:index")) + exceptions.handle( + self.request, msg, + redirect=reverse("horizon:murano:environments:index")) murano_images = [] for image in images: murano_property = image.properties.get('murano_image_info') @@ -418,4 +417,4 @@ class AddMuranoImageView(ModalFormView): form_class = AddImageForm template_name = 'images/add.html' context_object_name = 'image' - success_url = reverse_lazy("horizon:project:murano:murano_images") + success_url = reverse_lazy("horizon:murano:environments:murano_images") diff --git a/muranodashboard/panel/workflows.py b/muranodashboard/environments/workflows.py similarity index 96% rename from muranodashboard/panel/workflows.py rename to muranodashboard/environments/workflows.py index 1b1db5636..372b7b8aa 100644 --- a/muranodashboard/panel/workflows.py +++ b/muranodashboard/environments/workflows.py @@ -20,7 +20,7 @@ from horizon import exceptions from horizon import forms from horizon import workflows -from muranodashboard.panel import api +from muranodashboard.environments import api log = logging.getLogger(__name__) @@ -76,7 +76,7 @@ class CreateEnvironment(workflows.Workflow): finalize_button_name = _("Create") success_message = _('Created environment "%s".') failure_message = _('Unable to create environment "%s".') - success_url = "horizon:project:murano:index" + success_url = "horizon:murano:environments:index" default_steps = (SelectProjectUser, ConfigureEnvironment) def format_status_message(self, message): @@ -133,7 +133,7 @@ class UpdateEnvironment(workflows.Workflow): finalize_button_name = _("Save") success_message = _('Modified environment "%s".') failure_message = _('Unable to modify environment "%s".') - success_url = "horizon:project:murano:index" + success_url = "horizon:murano:environments:index" default_steps = (UpdateEnvironmentInfo,) def format_status_message(self, message): diff --git a/muranodashboard/settings.py b/muranodashboard/settings.py index 2b808f44f..53cbc1f61 100644 --- a/muranodashboard/settings.py +++ b/muranodashboard/settings.py @@ -52,15 +52,14 @@ EXTENDED_UNAUTHORIZED_EXCEPTIONS = tuple( HORIZON_CONFIG = { - 'dashboards': ('project', 'admin', 'settings',), - 'default_dashboard': 'project', - 'user_home': 'openstack_dashboard.views.get_user_home', + 'dashboards': ('project', 'admin', 'settings', 'murano'), + 'default_dashboard': 'murano', + 'user_home': 'muranodashboard.views.get_user_home', 'ajax_queue_limit': 10, 'help_url': "http://docs.openstack.org", 'exceptions': {'recoverable': EXTENDED_RECOVERABLE_EXCEPTIONS, 'not_found': EXTENDED_NOT_FOUND_EXCEPTIONS, 'unauthorized': EXTENDED_UNAUTHORIZED_EXCEPTIONS}, - 'customization_module': 'panel.overrides' } diff --git a/muranodashboard/templates/deployments/_page_header.html b/muranodashboard/templates/deployments/_page_header.html index 11d02ea58..12647c095 100644 --- a/muranodashboard/templates/deployments/_page_header.html +++ b/muranodashboard/templates/deployments/_page_header.html @@ -7,7 +7,7 @@

- + {% blocktrans %}environments{% endblocktrans %} > {{ environment_name }} deployments

diff --git a/muranodashboard/templates/deployments/_reports_page_header.html b/muranodashboard/templates/deployments/_reports_page_header.html index e112ebc83..3626993f4 100644 --- a/muranodashboard/templates/deployments/_reports_page_header.html +++ b/muranodashboard/templates/deployments/_reports_page_header.html @@ -7,10 +7,10 @@

- + {% blocktrans %}environments{% endblocktrans %} > - + {% blocktrans %}{{ environment_name }} deployments{% endblocktrans %} > deployment at {{ deployment_start_time }} diff --git a/muranodashboard/templates/services/_detail_page_header.html b/muranodashboard/templates/services/_detail_page_header.html index 451655f15..e57c13cb6 100644 --- a/muranodashboard/templates/services/_detail_page_header.html +++ b/muranodashboard/templates/services/_detail_page_header.html @@ -6,10 +6,10 @@

{% blocktrans %}Service Detail: {{ service_name }} {% endblocktrans %}

- + {% blocktrans %}environments{% endblocktrans %} > - + {% blocktrans %}environment {{ environment_name }}{% endblocktrans %} {% blocktrans %} > service {{ service_name }}{% endblocktrans %} diff --git a/muranodashboard/templates/services/_page_header.html b/muranodashboard/templates/services/_page_header.html index 900ce15db..b1850bc6d 100644 --- a/muranodashboard/templates/services/_page_header.html +++ b/muranodashboard/templates/services/_page_header.html @@ -7,7 +7,7 @@

- + {% blocktrans %}environments{% endblocktrans %} > environment {{ environment_name }}

diff --git a/muranodashboard/templates/services/_wizard_create.html b/muranodashboard/templates/services/_wizard_create.html index 6689637af..47432d119 100644 --- a/muranodashboard/templates/services/_wizard_create.html +++ b/muranodashboard/templates/services/_wizard_create.html @@ -1,7 +1,7 @@ {% extends "common/_modal_form.html" %} {% load i18n humanize %} -{% block form_action %}{% url horizon:project:murano:create %}{% endblock %} +{% block form_action %}{% url horizon:murano:environments:create %}{% endblock %} {% block form_id %}create_service_form{% endblock %} {% block modal_id %}create_service{% endblock %} {% block modal-header %}{% trans "Create Service" %}{% endblock %} diff --git a/muranodashboard/panel/overrides.py b/muranodashboard/views.py similarity index 77% rename from muranodashboard/panel/overrides.py rename to muranodashboard/views.py index 68263716d..a55495e00 100644 --- a/muranodashboard/panel/overrides.py +++ b/muranodashboard/views.py @@ -11,10 +11,10 @@ # 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 horizon -from muranodashboard.panel.panel import Panel -project = horizon.get_dashboard('project') -project.register(Panel) +def get_user_home(user): + #if user.is_superuser: + # return horizon.get_dashboard('admin').get_absolute_url() + return horizon.get_dashboard('murano').get_absolute_url()