From 43a5eedf8fe7fad2e6c0fa2039ab7db3347265ab Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Tue, 18 Apr 2017 20:01:21 +0800 Subject: [PATCH] Add bare metal servers content Change-Id: Ie1d2569ea0496207c946416752bafe28d4c2410b --- mogan_ui/content/__init__.py | 17 ++++++++ mogan_ui/content/baremetals/__init__.py | 0 mogan_ui/content/baremetals/panel.py | 42 +++++++++++++++++++ .../templates/baremetals/index.html | 11 +++++ mogan_ui/content/baremetals/urls.py | 23 ++++++++++ mogan_ui/content/baremetals/views.py | 20 +++++++++ 6 files changed, 113 insertions(+) create mode 100644 mogan_ui/content/__init__.py create mode 100644 mogan_ui/content/baremetals/__init__.py create mode 100644 mogan_ui/content/baremetals/panel.py create mode 100644 mogan_ui/content/baremetals/templates/baremetals/index.html create mode 100644 mogan_ui/content/baremetals/urls.py create mode 100644 mogan_ui/content/baremetals/views.py diff --git a/mogan_ui/content/__init__.py b/mogan_ui/content/__init__.py new file mode 100644 index 0000000..6a87c3c --- /dev/null +++ b/mogan_ui/content/__init__.py @@ -0,0 +1,17 @@ +# 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 pbr.version + + +__version__ = pbr.version.VersionInfo( + 'mogan-ui').version_string() diff --git a/mogan_ui/content/baremetals/__init__.py b/mogan_ui/content/baremetals/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mogan_ui/content/baremetals/panel.py b/mogan_ui/content/baremetals/panel.py new file mode 100644 index 0000000..b11473d --- /dev/null +++ b/mogan_ui/content/baremetals/panel.py @@ -0,0 +1,42 @@ +# Copyright 2017 Huawei Technologies Co.,LTD. +# All Rights Reserved. +# +# 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 openstack_dashboard.api import base +from openstack_dashboard.dashboards.project import dashboard + + +class Instances(horizon.Panel): + name = _("Instances") + slug = 'instances' + + def allowed(self, context): + request = context['request'] + if not base.is_service_enabled(request, 'baremetal_compute'): + return False + else: + return super(Instances, self).allowed(context) + + def nav(self, context): + request = context['request'] + if not base.is_service_enabled(request, 'baremetal_compute'): + return False + else: + return True + +dashboard.Project.register(Instances) diff --git a/mogan_ui/content/baremetals/templates/baremetals/index.html b/mogan_ui/content/baremetals/templates/baremetals/index.html new file mode 100644 index 0000000..b926735 --- /dev/null +++ b/mogan_ui/content/baremetals/templates/baremetals/index.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} +{% load i18n %} +{% block title %}{% trans "Bare Metal Servers" %}{% endblock %} + +{% block page_header %} + +{% endblock %} + +{% block main %} + +{% endblock %} diff --git a/mogan_ui/content/baremetals/urls.py b/mogan_ui/content/baremetals/urls.py new file mode 100644 index 0000000..f0d34a2 --- /dev/null +++ b/mogan_ui/content/baremetals/urls.py @@ -0,0 +1,23 @@ +# Copyright 2017 Huawei Technologies Co.,LTD. +# All Rights Reserved. +# +# 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.urls import url + +import mogan_ui.api.rest_api # noqa +from mogan_ui.content.baremetals import views + +urlpatterns = [ + url(r'^$', views.IndexView.as_view(), name='index'), +] diff --git a/mogan_ui/content/baremetals/views.py b/mogan_ui/content/baremetals/views.py new file mode 100644 index 0000000..b56ceee --- /dev/null +++ b/mogan_ui/content/baremetals/views.py @@ -0,0 +1,20 @@ +# Copyright 2017 Huawei Technologies Co.,LTD. +# All Rights Reserved. +# +# 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.views import generic + + +class IndexView(generic.TemplateView): + template_name = 'project/baremetals/index.html'