Add separate restores panel in Karbor dashboard
As we discussed the dashboard features in the IRC Meeting, We will separate restores into a single panel. Change-Id: Iee7f926e7be37bade0b6cf0f1a00c8b55510401e
This commit is contained in:
@@ -41,12 +41,7 @@ Install Karbor Dashboard with all dependencies in your virtual environment::
|
|||||||
|
|
||||||
And enable it in Horizon::
|
And enable it in Horizon::
|
||||||
|
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6000_data_protection.py openstack_dashboard/local/enabled
|
cp ../karbor-dashboard/karbor_dashboard/enabled/* openstack_dashboard/local/enabled/
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6010_data_protection_protection_plans_panel.py openstack_dashboard/local/enabled
|
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6020_data_protection_protection_providers_panel.py openstack_dashboard/local/enabled
|
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6030_data_protection_checkpoints_panel.py openstack_dashboard/local/enabled
|
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6040_data_protection_operation_logs_panel.py openstack_dashboard/local/enabled
|
|
||||||
cp ../karbor-dashboard/karbor_dashboard/enabled/_6050_data_protection_triggers_panel.py openstack_dashboard/local/enabled
|
|
||||||
|
|
||||||
To run horizon with the newly enabled Karbor Dashboard plugin run::
|
To run horizon with the newly enabled Karbor Dashboard plugin run::
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) 2016 Huawei, 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.
|
||||||
|
|
||||||
|
|
||||||
|
PANEL = 'restores'
|
||||||
|
PANEL_GROUP = 'default'
|
||||||
|
PANEL_DASHBOARD = 'karbor'
|
||||||
|
|
||||||
|
ADD_PANEL = \
|
||||||
|
'karbor_dashboard.restores.panel.Restores'
|
||||||
0
karbor_dashboard/restores/__init__.py
Normal file
0
karbor_dashboard/restores/__init__.py
Normal file
25
karbor_dashboard/restores/panel.py
Normal file
25
karbor_dashboard/restores/panel.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright (c) 2016 Huawei, 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.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
import horizon
|
||||||
|
|
||||||
|
from karbor_dashboard import dashboard
|
||||||
|
|
||||||
|
|
||||||
|
class Restores(horizon.Panel):
|
||||||
|
name = _("Restores")
|
||||||
|
slug = 'restores'
|
||||||
|
|
||||||
|
dashboard.DataProtection.register(Restores)
|
||||||
42
karbor_dashboard/restores/tables.py
Normal file
42
karbor_dashboard/restores/tables.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Copyright (c) 2016 Huawei, 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.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from horizon import tables
|
||||||
|
|
||||||
|
|
||||||
|
class RestoresTable(tables.DataTable):
|
||||||
|
id = tables.Column(
|
||||||
|
'id',
|
||||||
|
verbose_name=_('ID'))
|
||||||
|
name = tables.Column(
|
||||||
|
'name',
|
||||||
|
verbose_name=_('Protection Plan'))
|
||||||
|
status = tables.Column(
|
||||||
|
'status',
|
||||||
|
verbose_name=_('Status'))
|
||||||
|
restore_from_checkpoint = tables.Column(
|
||||||
|
'checkpoint_id',
|
||||||
|
verbose_name=_('Restore From Checkpoint'))
|
||||||
|
restore_target = tables.Column(
|
||||||
|
'restore_target',
|
||||||
|
verbose_name=_('Restore Target'))
|
||||||
|
protection_provider = tables.Column(
|
||||||
|
'provider_name',
|
||||||
|
verbose_name=_('Protection Provider'))
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
name = 'restores'
|
||||||
|
verbose_name = _('Restores')
|
||||||
21
karbor_dashboard/restores/urls.py
Normal file
21
karbor_dashboard/restores/urls.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) 2016 Huawei, 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.
|
||||||
|
|
||||||
|
from django.conf.urls import url
|
||||||
|
from karbor_dashboard.restores import views
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||||
|
]
|
||||||
72
karbor_dashboard/restores/views.py
Normal file
72
karbor_dashboard/restores/views.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Copyright (c) 2016 Huawei, 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.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from horizon import exceptions
|
||||||
|
from horizon import tables as horizon_tables
|
||||||
|
|
||||||
|
from karbor_dashboard.api import karbor as karborclient
|
||||||
|
from karbor_dashboard.restores import tables
|
||||||
|
|
||||||
|
|
||||||
|
class IndexView(horizon_tables.DataTableView):
|
||||||
|
table_class = tables.RestoresTable
|
||||||
|
template_name = 'restores/index.html'
|
||||||
|
page_title = _("Restores")
|
||||||
|
|
||||||
|
def has_prev_data(self, table):
|
||||||
|
return self._prev
|
||||||
|
|
||||||
|
def has_more_data(self, table):
|
||||||
|
return self._more
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
request = self.request
|
||||||
|
prev_marker = request.GET.get(
|
||||||
|
tables.RestoresTable._meta.prev_pagination_param, None)
|
||||||
|
|
||||||
|
if prev_marker is not None:
|
||||||
|
marker = prev_marker
|
||||||
|
else:
|
||||||
|
marker = request.GET.get(
|
||||||
|
tables.RestoresTable._meta.pagination_param, None)
|
||||||
|
reversed_order = prev_marker is not None
|
||||||
|
restores = []
|
||||||
|
try:
|
||||||
|
restores, self._more, self._prev = \
|
||||||
|
karborclient.restore_list_paged(
|
||||||
|
self.request,
|
||||||
|
marker=marker,
|
||||||
|
paginate=True,
|
||||||
|
sort_dir='asc',
|
||||||
|
sort_key='id',
|
||||||
|
reversed_order=reversed_order)
|
||||||
|
|
||||||
|
for restore in restores:
|
||||||
|
checkpoint = karborclient.checkpoint_get(
|
||||||
|
self.request,
|
||||||
|
restore.provider_id,
|
||||||
|
restore.checkpoint_id)
|
||||||
|
provider = karborclient.provider_get(self.request,
|
||||||
|
restore.provider_id)
|
||||||
|
setattr(restore, "name", checkpoint.protection_plan["name"])
|
||||||
|
setattr(restore, "provider_name", provider.name)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
self._prev = False
|
||||||
|
self._more = False
|
||||||
|
exceptions.handle(self.request,
|
||||||
|
_('Unable to retrieve restore list.'))
|
||||||
|
return restores
|
||||||
10
karbor_dashboard/templates/restores/index.html
Normal file
10
karbor_dashboard/templates/restores/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans "Restores" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
{{ table.render }}
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user