Refactor project dashboard
Separating tabs of single panel to separate panels. It will reduce amount of redundant calls, because it is very unlikely that someone will need all tabs at once. Also, it is current approach that is used by core projects. Similar refactor for admin dashboard is located at [1] [1] I874253e0e9a35ede8239bc1bdf0a330a44ade413 Change-Id: Ia8a432e136a9c06f3db887b9289d90853dd027e6 Partially-Implements BluePrint create-share-panel-group
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Shares" %}{% endblock %}
|
||||
{% block title %}{% trans "Security Services" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
|
@@ -26,7 +26,7 @@ from manila_ui.api import manila
|
||||
import manila_ui.dashboards.admin.security_services.tables as ss_tables
|
||||
import manila_ui.dashboards.admin.security_services.tabs as ss_tabs
|
||||
from manila_ui.dashboards.admin import utils
|
||||
import manila_ui.dashboards.project.shares.security_services.views as ss_views
|
||||
import manila_ui.dashboards.project.security_services.views as ss_views
|
||||
|
||||
|
||||
class SecurityServicesView(tables.MultiTableView):
|
||||
|
@@ -14,7 +14,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import tables
|
||||
import six
|
||||
|
||||
import manila_ui.dashboards.project.shares.share_networks.tables as sn_tables
|
||||
import manila_ui.dashboards.project.share_networks.tables as sn_tables
|
||||
|
||||
|
||||
class ShareNetworksTable(tables.DataTable):
|
||||
|
@@ -28,7 +28,7 @@ from manila_ui.api import manila
|
||||
from manila_ui.dashboards.admin.share_networks import tables as sn_tables
|
||||
from manila_ui.dashboards.admin.share_networks import tabs as sn_tabs
|
||||
from manila_ui.dashboards.admin import utils
|
||||
import manila_ui.dashboards.project.shares.share_networks.views as p_views
|
||||
from manila_ui.dashboards.project.share_networks import views as p_views
|
||||
|
||||
|
||||
class ShareNetworksView(tables.MultiTableView):
|
||||
|
@@ -20,8 +20,8 @@ from horizon import exceptions
|
||||
from horizon import tables
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.shares import tables as shares_tables
|
||||
import manila_ui.dashboards.project.shares.snapshots.tables as ss_tables
|
||||
import manila_ui.dashboards.project.share_snapshots.tables as ss_tables
|
||||
from manila_ui.dashboards.project.shares import tables as shares_tables
|
||||
|
||||
|
||||
def get_size(share):
|
||||
@@ -118,7 +118,7 @@ class ShareSnapshotsTable(tables.DataTable):
|
||||
name = "share_snapshots"
|
||||
verbose_name = _("Share Snapshots")
|
||||
status_columns = ["status"]
|
||||
row_class = ss_tables.UpdateRow
|
||||
row_class = ss_tables.UpdateShareSnapshotRow
|
||||
table_actions = (
|
||||
tables.NameFilterAction,
|
||||
DeleteShareSnapshot,
|
||||
|
@@ -26,7 +26,7 @@ from manila_ui.api import manila
|
||||
from manila_ui.dashboards.admin.share_snapshots import tables as ss_tables
|
||||
from manila_ui.dashboards.admin.share_snapshots import tabs as ss_tabs
|
||||
from manila_ui.dashboards.admin import utils
|
||||
import manila_ui.dashboards.project.shares.snapshots.views as snapshot_views
|
||||
import manila_ui.dashboards.project.share_snapshots.views as snapshot_views
|
||||
|
||||
|
||||
class ShareSnapshotsView(tables.MultiTableView):
|
||||
@@ -57,7 +57,7 @@ class ShareSnapshotsView(tables.MultiTableView):
|
||||
return snapshots
|
||||
|
||||
|
||||
class ShareSnapshotDetailView(snapshot_views.SnapshotDetailView):
|
||||
class ShareSnapshotDetailView(snapshot_views.ShareSnapshotDetailView):
|
||||
tab_group_class = ss_tabs.SnapshotDetailTabs
|
||||
template_name = "admin/share_snapshots/detail.html"
|
||||
redirect_url = reverse_lazy("horizon:admin:share_snapshots:index")
|
||||
|
@@ -15,7 +15,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import tables
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.shares import tables as shares_tables
|
||||
from manila_ui.dashboards.project.shares import tables as shares_tables
|
||||
|
||||
|
||||
class MigrationStartAction(tables.LinkAction):
|
||||
|
@@ -29,7 +29,7 @@ from manila_ui.dashboards.admin.shares import forms as project_forms
|
||||
from manila_ui.dashboards.admin.shares import tables as s_tables
|
||||
from manila_ui.dashboards.admin.shares import tabs as s_tabs
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.dashboards.project.shares.shares import views as share_views
|
||||
from manila_ui.dashboards.project.shares import views as share_views
|
||||
|
||||
|
||||
class SharesView(tables.MultiTableView, share_views.ShareTableMixIn):
|
||||
|
@@ -18,7 +18,6 @@ from django.forms import ValidationError # noqa
|
||||
from django.template.defaultfilters import filesizeformat # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.debug import sensitive_variables # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
@@ -88,7 +87,7 @@ class Update(forms.SelfHandlingForm):
|
||||
messages.success(request, message)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:shares:index")
|
||||
redirect = reverse("horizon:project:security_services:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to update security service.'),
|
||||
redirect=redirect)
|
28
manila_ui/dashboards/project/security_services/panel.py
Normal file
28
manila_ui/dashboards/project/security_services/panel.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.project import dashboard
|
||||
|
||||
|
||||
class SecurityServices(horizon.Panel):
|
||||
name = _("Security Services")
|
||||
slug = 'security_services'
|
||||
permissions = (
|
||||
'openstack.services.share',
|
||||
)
|
||||
|
||||
|
||||
dashboard.Project.register(SecurityServices)
|
@@ -22,7 +22,7 @@ from manila_ui.api import manila
|
||||
class Create(tables.LinkAction):
|
||||
name = "create_security_service"
|
||||
verbose_name = _("Create Security Service")
|
||||
url = "horizon:project:shares:create_security_service"
|
||||
url = "horizon:project:security_services:security_service_create"
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
icon = "plus"
|
||||
policy_rules = (("share", "security_service:create"),)
|
||||
@@ -54,15 +54,15 @@ class Delete(tables.DeleteAction):
|
||||
class Edit(tables.LinkAction):
|
||||
name = "edit"
|
||||
verbose_name = _("Edit Security Service")
|
||||
url = "horizon:project:shares:update_security_service"
|
||||
url = "horizon:project:security_services:security_service_update"
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
policy_rules = (("share", "security_service:update"),)
|
||||
|
||||
|
||||
class SecurityServiceTable(tables.DataTable):
|
||||
class SecurityServicesTable(tables.DataTable):
|
||||
name = tables.WrappingColumn(
|
||||
"name", verbose_name=_("Name"),
|
||||
link="horizon:project:shares:security_service_detail")
|
||||
link="horizon:project:security_services:security_service_detail")
|
||||
dns_ip = tables.Column("dns_ip", verbose_name=_("DNS IP"))
|
||||
server = tables.Column("server", verbose_name=_("Server"))
|
||||
domain = tables.Column("domain", verbose_name=_("Domain"))
|
@@ -12,37 +12,13 @@
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tabs
|
||||
|
||||
from manila_ui.api import manila
|
||||
|
||||
from manila_ui.dashboards.project.shares.security_services \
|
||||
import tables as security_services_tables
|
||||
|
||||
|
||||
class SecurityServiceTab(tabs.TableTab):
|
||||
table_classes = (security_services_tables.SecurityServiceTable,)
|
||||
name = _("Security Services")
|
||||
slug = "security_services_tab"
|
||||
template_name = "horizon/common/_detail_table.html"
|
||||
|
||||
def get_security_services_data(self):
|
||||
try:
|
||||
security_services = manila.security_service_list(self.request)
|
||||
except Exception:
|
||||
security_services = []
|
||||
exceptions.handle(self.request,
|
||||
_("Unable to retrieve security services"))
|
||||
|
||||
return security_services
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = ("project/shares/security_services/_detail_overview.html")
|
||||
template_name = ("project/security_services/_detail.html")
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"sec_service": self.tab_group.kwargs['sec_service']}
|
||||
@@ -50,4 +26,6 @@ class OverviewTab(tabs.Tab):
|
||||
|
||||
class SecurityServiceDetailTabs(tabs.TabGroup):
|
||||
slug = "security_service_details"
|
||||
tabs = (OverviewTab,)
|
||||
tabs = (
|
||||
OverviewTab,
|
||||
)
|
@@ -2,7 +2,7 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block form_id %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:project:shares:add_security_service' share_network.id %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:project:security_service:add_security_service' share_network.id %}{% endblock %}
|
||||
|
||||
{% block modal_id %}add_security_service_modal{% endblock %}
|
||||
{% block modal-header %}{% trans "Add Security Service" %}{% endblock %}
|
||||
@@ -56,5 +56,5 @@
|
||||
|
||||
{% block modal-footer %}
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Security Service" %}" />
|
||||
<a href="{% url 'horizon:project:shares:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
|
||||
<a href="{% url 'horizon:project:security_services:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Create Security Service" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/security_services/_add_security_service.html' %}
|
||||
{% include 'project/security_services/_add.html' %}
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Create Security Service" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/security_services/_create_security_service.html' %}
|
||||
{% include 'project/security_services/_create.html' %}
|
||||
{% endblock %}
|
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Security Services" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ security_services_table.render }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Edit Security Service" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/security_services/_update.html' %}
|
||||
{% include 'project/security_services/_update.html' %}
|
||||
{% endblock %}
|
37
manila_ui/dashboards/project/security_services/urls.py
Normal file
37
manila_ui/dashboards/project/security_services/urls.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2012 Nebula, 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 import urls
|
||||
|
||||
from manila_ui.dashboards.project.security_services import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
urls.url(
|
||||
r'^$',
|
||||
views.SecurityServicesView.as_view(),
|
||||
name='index'),
|
||||
urls.url(
|
||||
r'^create_security_service$',
|
||||
views.CreateView.as_view(),
|
||||
name='security_service_create'),
|
||||
urls.url(
|
||||
r'^(?P<sec_service_id>[^/]+)/update/$',
|
||||
views.UpdateView.as_view(),
|
||||
name='security_service_update'),
|
||||
urls.url(
|
||||
r'^(?P<sec_service_id>[^/]+)$',
|
||||
views.Detail.as_view(),
|
||||
name='security_service_detail'),
|
||||
]
|
@@ -15,31 +15,48 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.security_services import\
|
||||
forms as sec_services_forms
|
||||
from manila_ui.dashboards.project.shares.security_services \
|
||||
import tabs as security_services_tabs
|
||||
from manila_ui.dashboards.project.shares.share_networks import forms\
|
||||
as share_net_forms
|
||||
from manila_ui.dashboards.project.security_services import forms as ss_forms
|
||||
from manila_ui.dashboards.project.security_services import tables as ss_tables
|
||||
from manila_ui.dashboards.project.security_services import tabs as ss_tabs
|
||||
from manila_ui.dashboards.project.share_networks import forms as sn_forms
|
||||
from manila_ui.dashboards import utils
|
||||
|
||||
|
||||
class SecurityServicesView(tables.MultiTableView):
|
||||
table_classes = (
|
||||
ss_tables.SecurityServicesTable,
|
||||
)
|
||||
template_name = "project/security_services/index.html"
|
||||
page_title = _("Security Services")
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_security_services_data(self):
|
||||
try:
|
||||
security_services = manila.security_service_list(self.request)
|
||||
except Exception:
|
||||
security_services = []
|
||||
exceptions.handle(
|
||||
self.request, _("Unable to retrieve security services"))
|
||||
|
||||
return security_services
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
template_name = "project/shares/security_services/update.html"
|
||||
form_class = sec_services_forms.Update
|
||||
template_name = "project/security_services/update.html"
|
||||
form_class = ss_forms.Update
|
||||
form_id = "update_security_service"
|
||||
modal_header = _("Edit Security Service")
|
||||
modal_id = "update_security_service_modal"
|
||||
submit_label = _("Edit")
|
||||
submit_url = "horizon:project:shares:update_security_service"
|
||||
success_url = 'horizon:project:shares:index'
|
||||
submit_url = "horizon:project:security_services:security_service_update"
|
||||
success_url = 'horizon:project:security_services:index'
|
||||
page_title = _('Edit Security Service')
|
||||
|
||||
def get_success_url(self):
|
||||
@@ -53,7 +70,7 @@ class UpdateView(forms.ModalFormView):
|
||||
self.request, sec_service_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve security_service.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
url = reverse('horizon:project:security_services:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
@@ -70,15 +87,15 @@ class UpdateView(forms.ModalFormView):
|
||||
|
||||
|
||||
class CreateView(forms.ModalFormView):
|
||||
form_class = sec_services_forms.Create
|
||||
form_class = ss_forms.Create
|
||||
form_id = "create_security_service"
|
||||
template_name = ('project/shares/security_services'
|
||||
'/create_security_service.html')
|
||||
template_name = 'project/security_services/create.html'
|
||||
modal_header = _("Create Security Service")
|
||||
modal_id = "create_security_service_modal"
|
||||
submit_label = _("Create")
|
||||
submit_url = reverse_lazy("horizon:project:shares:create_security_service")
|
||||
success_url = 'horizon:project:shares:index'
|
||||
submit_url = reverse_lazy(
|
||||
"horizon:project:security_services:security_service_create")
|
||||
success_url = 'horizon:project:security_services:index'
|
||||
page_title = _('Create Security Service')
|
||||
|
||||
def get_success_url(self):
|
||||
@@ -86,10 +103,9 @@ class CreateView(forms.ModalFormView):
|
||||
|
||||
|
||||
class AddSecurityServiceView(forms.ModalFormView):
|
||||
form_class = share_net_forms.AddSecurityServiceForm
|
||||
template_name = ('project/shares/security_services'
|
||||
'/add_security_service.html')
|
||||
success_url = 'horizon:project:shares:index'
|
||||
form_class = sn_forms.AddSecurityServiceForm
|
||||
template_name = 'project/security_services/add.html'
|
||||
success_url = 'horizon:project:security_services:index'
|
||||
page_title = _('Add Security Service')
|
||||
|
||||
def get_object(self):
|
||||
@@ -99,7 +115,7 @@ class AddSecurityServiceView(forms.ModalFormView):
|
||||
self._object = manila.share_network_get(self.request, share_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share network.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
url = reverse('horizon:project:security_services:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
@@ -117,9 +133,9 @@ class AddSecurityServiceView(forms.ModalFormView):
|
||||
|
||||
|
||||
class Detail(tabs.TabView):
|
||||
tab_group_class = security_services_tabs.SecurityServiceDetailTabs
|
||||
template_name = 'project/shares/security_services/detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:shares:index')
|
||||
tab_group_class = ss_tabs.SecurityServiceDetailTabs
|
||||
template_name = 'project/security_services/detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:security_services:index')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Detail, self).get_context_data(**kwargs)
|
@@ -17,18 +17,16 @@ from django.core.urlresolvers import reverse
|
||||
from django.forms import ValidationError # noqa
|
||||
from django.template.defaultfilters import filesizeformat # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
from horizon.utils.memoized import memoized # noqa
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.api import network
|
||||
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
|
||||
class Create(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Name"))
|
28
manila_ui/dashboards/project/share_networks/panel.py
Normal file
28
manila_ui/dashboards/project/share_networks/panel.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.project import dashboard
|
||||
|
||||
|
||||
class ShareNetworks(horizon.Panel):
|
||||
name = _("Share Networks")
|
||||
slug = 'share_networks'
|
||||
permissions = (
|
||||
'openstack.services.share',
|
||||
)
|
||||
|
||||
|
||||
dashboard.Project.register(ShareNetworks)
|
@@ -18,15 +18,13 @@ from django.utils.translation import pgettext_lazy
|
||||
from django.utils.translation import string_concat # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import tables
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.api import network
|
||||
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
|
||||
DELETABLE_STATES = ("INACTIVE", "ERROR")
|
||||
EDITABLE_STATES = ("INACTIVE", )
|
||||
@@ -35,7 +33,7 @@ EDITABLE_STATES = ("INACTIVE", )
|
||||
class Create(tables.LinkAction):
|
||||
name = "create_share_network"
|
||||
verbose_name = _("Create Share Network")
|
||||
url = "horizon:project:shares:create_share_network"
|
||||
url = "horizon:project:share_networks:share_network_create"
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
icon = "plus"
|
||||
policy_rules = (("share", "share_network:create"),)
|
||||
@@ -74,7 +72,7 @@ class Delete(tables.DeleteAction):
|
||||
class EditShareNetwork(tables.LinkAction):
|
||||
name = "edit"
|
||||
verbose_name = _("Edit Share Network")
|
||||
url = "horizon:project:shares:update_share_network"
|
||||
url = "horizon:project:share_networks:share_network_update"
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
policy_rules = (("share", "share_network:update"),)
|
||||
|
||||
@@ -102,36 +100,6 @@ class UpdateRow(tables.Row):
|
||||
return share_net
|
||||
|
||||
|
||||
class NovaShareNetworkTable(tables.DataTable):
|
||||
name = tables.WrappingColumn(
|
||||
"name", verbose_name=_("Name"),
|
||||
link="horizon:project:shares:share_network_detail")
|
||||
nova_net = tables.Column("nova_net", verbose_name=_("Nova Net"))
|
||||
ip_version = tables.Column("ip_version", verbose_name=_("IP Version"))
|
||||
network_type = tables.Column("network_type",
|
||||
verbose_name=_("Network Type"))
|
||||
segmentation_id = tables.Column("segmentation_id",
|
||||
verbose_name=_("Segmentation Id"))
|
||||
|
||||
def get_object_display(self, share_network):
|
||||
return share_network.name or str(share_network.id)
|
||||
|
||||
def get_object_id(self, share_network):
|
||||
return str(share_network.id)
|
||||
|
||||
class Meta(object):
|
||||
name = "share_networks"
|
||||
verbose_name = _("Share Networks")
|
||||
table_actions = (
|
||||
tables.NameFilterAction,
|
||||
Create,
|
||||
Delete)
|
||||
row_class = UpdateRow
|
||||
row_actions = (
|
||||
EditShareNetwork,
|
||||
Delete)
|
||||
|
||||
|
||||
class ShareNetworksTable(tables.DataTable):
|
||||
STATUS_CHOICES = (
|
||||
("ACTIVE", True),
|
||||
@@ -147,20 +115,15 @@ class ShareNetworksTable(tables.DataTable):
|
||||
)
|
||||
name = tables.WrappingColumn(
|
||||
"name", verbose_name=_("Name"),
|
||||
link="horizon:project:shares:share_network_detail")
|
||||
link="horizon:project:share_networks:share_network_detail")
|
||||
neutron_net = tables.Column("neutron_net", verbose_name=_("Neutron Net"))
|
||||
neutron_subnet = tables.Column(
|
||||
"neutron_subnet", verbose_name=_("Neutron Subnet"))
|
||||
ip_version = tables.Column("ip_version", verbose_name=_("IP Version"))
|
||||
network_type = tables.Column("network_type",
|
||||
verbose_name=_("Network Type"))
|
||||
segmentation_id = tables.Column("segmentation_id",
|
||||
verbose_name=_("Segmentation Id"))
|
||||
# NOTE: disable status column until it become used
|
||||
# status = tables.Column("status", verbose_name=_("Status"),
|
||||
# status=True,
|
||||
# status_choices=STATUS_CHOICES)
|
||||
# display_choices=STATUS_DISPLAY_CHOICES)
|
||||
network_type = tables.Column(
|
||||
"network_type", verbose_name=_("Network Type"))
|
||||
segmentation_id = tables.Column(
|
||||
"segmentation_id", verbose_name=_("Segmentation Id"))
|
||||
|
||||
def get_object_display(self, share_network):
|
||||
return share_network.name or str(share_network.id)
|
||||
@@ -174,9 +137,10 @@ class ShareNetworksTable(tables.DataTable):
|
||||
table_actions = (
|
||||
tables.NameFilterAction,
|
||||
Create,
|
||||
Delete)
|
||||
# status_columns = ["status"]
|
||||
Delete,
|
||||
)
|
||||
row_class = UpdateRow
|
||||
row_actions = (
|
||||
EditShareNetwork,
|
||||
Delete)
|
||||
Delete,
|
||||
)
|
31
manila_ui/dashboards/project/share_networks/tabs.py
Normal file
31
manila_ui/dashboards/project/share_networks/tabs.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# 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 tabs
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = "project/share_networks/_detail.html"
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"share_network": self.tab_group.kwargs['share_network']}
|
||||
|
||||
|
||||
class ShareNetworkDetailTabs(tabs.TabGroup):
|
||||
slug = "share_network_details"
|
||||
tabs = (
|
||||
OverviewTab,
|
||||
)
|
@@ -12,13 +12,6 @@
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ share_network.description }}</dd>
|
||||
{% endif %}
|
||||
{% if share_network.share_servers %}
|
||||
<dt>{% trans "Share Servers" %}</dt>
|
||||
{% for server in share_network.share_servers %}
|
||||
{% url 'horizon:admin:shares:share_server_detail' server.id as server_url %}
|
||||
<dd><a href="{{ server_url }}">{{ server.id }}</a></dd>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +35,7 @@
|
||||
<h4>{% trans "Security Services" %}</h4>
|
||||
<hr class="header_rule">
|
||||
{% for sec_service in share_network.sec_services %}
|
||||
{% url 'horizon:project:shares:security_service_detail' sec_service.id as sec_service_url%}
|
||||
{% url 'horizon:project:security_services:security_service_detail' sec_service.id as sec_service_url%}
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Id" %}</dt>
|
||||
<dd><a href="{{ sec_service_url }}">{{ sec_service.id }}</a></dd>
|
@@ -2,7 +2,7 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block form_id %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:project:shares:update_share_network' share_network.id %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:project:share_networks:share_network_update' share_network.id %}{% endblock %}
|
||||
|
||||
{% block modal_id %}update_share_network_modal{% endblock %}
|
||||
{% block modal-header %}{% trans "Edit Share network" %}{% endblock %}
|
||||
@@ -21,5 +21,5 @@
|
||||
|
||||
{% block modal-footer %}
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Edit Share Network" %}" />
|
||||
<a href="{% url 'horizon:project:shares:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
|
||||
<a href="{% url 'horizon:project:share_networks:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Create Share Network" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/share_networks/_create_share_network.html' %}
|
||||
{% include 'project/share_networks/_create.html' %}
|
||||
{% endblock %}
|
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Share Details" %}{% endblock %}
|
||||
{% block title %}{% trans "Share Network Details" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Share Networks" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ share_networks_table.render }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
37
manila_ui/dashboards/project/share_networks/urls.py
Normal file
37
manila_ui/dashboards/project/share_networks/urls.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from django.conf import urls
|
||||
|
||||
from manila_ui.dashboards.project.share_networks import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
urls.url(
|
||||
r'^$',
|
||||
views.ShareNetworksView.as_view(),
|
||||
name='index'),
|
||||
urls.url(
|
||||
r'^create_share_network$',
|
||||
views.Create.as_view(),
|
||||
name='share_network_create'),
|
||||
urls.url(
|
||||
r'^(?P<share_network_id>[^/]+)/update$',
|
||||
views.Update.as_view(),
|
||||
name='share_network_update'),
|
||||
urls.url(
|
||||
r'^(?P<share_network_id>[^/]+)$',
|
||||
views.Detail.as_view(),
|
||||
name='share_network_detail'),
|
||||
]
|
@@ -17,28 +17,55 @@ from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
from horizon import workflows
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.api import network
|
||||
from manila_ui.dashboards.project.shares.share_networks import forms \
|
||||
as share_net_forms
|
||||
from manila_ui.dashboards.project.shares.share_networks import tabs \
|
||||
as share_net_tabs
|
||||
from manila_ui.dashboards.project.shares.share_networks \
|
||||
import workflows as share_net_workflows
|
||||
from manila_ui.dashboards import utils
|
||||
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.api import network
|
||||
from manila_ui.dashboards.project.share_networks import forms as sn_forms
|
||||
from manila_ui.dashboards.project.share_networks import tables as sn_tables
|
||||
from manila_ui.dashboards.project.share_networks import tabs as sn_tabs
|
||||
import manila_ui.dashboards.project.share_networks.workflows as sn_workflows
|
||||
from manila_ui.dashboards import utils
|
||||
|
||||
|
||||
class ShareNetworksView(tables.MultiTableView):
|
||||
table_classes = (
|
||||
sn_tables.ShareNetworksTable,
|
||||
)
|
||||
template_name = "admin/share_networks/index.html"
|
||||
page_title = _("Share Networks")
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_share_networks_data(self):
|
||||
try:
|
||||
share_networks = manila.share_network_list(
|
||||
self.request, detailed=True)
|
||||
if base.is_service_enabled(self.request, 'network'):
|
||||
neutron_net_names = dict((net.id, net.name) for net in
|
||||
neutron.network_list(self.request))
|
||||
neutron_subnet_names = dict((net.id, net.name) for net in
|
||||
neutron.subnet_list(self.request))
|
||||
for sn in share_networks:
|
||||
sn.neutron_net = neutron_net_names.get(
|
||||
sn.neutron_net_id) or sn.neutron_net_id or "-"
|
||||
sn.neutron_subnet = neutron_subnet_names.get(
|
||||
sn.neutron_subnet_id) or sn.neutron_subnet_id or "-"
|
||||
except Exception:
|
||||
share_networks = []
|
||||
exceptions.handle(
|
||||
self.request, _("Unable to retrieve share networks"))
|
||||
return share_networks
|
||||
|
||||
|
||||
class Update(workflows.WorkflowView):
|
||||
workflow_class = share_net_workflows.UpdateShareNetworkWorkflow
|
||||
template_name = "project/shares/share_networks/share_network_update.html"
|
||||
success_url = 'horizon:project:shares:index'
|
||||
workflow_class = sn_workflows.UpdateShareNetworkWorkflow
|
||||
template_name = "project/share_networks/update.html"
|
||||
success_url = 'horizon:project:share_networks:index'
|
||||
page_title = _('Update Share Network')
|
||||
|
||||
def get_initial(self):
|
||||
@@ -51,13 +78,14 @@ class Update(workflows.WorkflowView):
|
||||
|
||||
|
||||
class Create(forms.ModalFormView):
|
||||
form_class = share_net_forms.Create
|
||||
form_class = sn_forms.Create
|
||||
form_id = "create_share_network"
|
||||
template_name = 'project/shares/share_networks/create_share_network.html'
|
||||
template_name = 'project/share_networks/create.html'
|
||||
modal_header = _("Create Share Network")
|
||||
submit_label = _("Create")
|
||||
submit_url = reverse_lazy("horizon:project:shares:create_share_network")
|
||||
success_url = 'horizon:project:shares:index'
|
||||
submit_url = reverse_lazy(
|
||||
"horizon:project:share_networks:share_network_create")
|
||||
success_url = 'horizon:project:share_networks:index'
|
||||
page_title = _('Create Share Network')
|
||||
|
||||
def get_success_url(self):
|
||||
@@ -65,9 +93,9 @@ class Create(forms.ModalFormView):
|
||||
|
||||
|
||||
class Detail(tabs.TabView):
|
||||
tab_group_class = share_net_tabs.ShareNetworkDetailTabs
|
||||
template_name = 'project/shares/share_networks/detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:shares:index')
|
||||
tab_group_class = sn_tabs.ShareNetworkDetailTabs
|
||||
template_name = 'project/share_networks/detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:share_networks:index')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Detail, self).get_context_data(**kwargs)
|
@@ -112,7 +112,7 @@ class UpdateShareNetworkWorkflow(workflows.Workflow):
|
||||
finalize_button_name = _("Update Share Network")
|
||||
success_message = _('Updated share network "%s".')
|
||||
failure_message = _('Unable to update share network "%s".')
|
||||
success_url = 'horizon:project:shares:index'
|
||||
success_url = 'horizon:project:share_networks:index'
|
||||
default_steps = (UpdateShareNetworkInfoStep, AddSecurityServiceStep)
|
||||
|
||||
def format_status_message(self, message):
|
@@ -14,7 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Views for managing snapshots.
|
||||
Views for managing share snapshots.
|
||||
"""
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
@@ -22,7 +22,6 @@ from django.forms import ValidationError # noqa
|
||||
from django.template.defaultfilters import filesizeformat # noqa
|
||||
from django.utils.http import urlencode # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import messages
|
||||
@@ -30,19 +29,18 @@ from horizon import messages
|
||||
from manila_ui.api import manila
|
||||
|
||||
|
||||
class CreateSnapshotForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Snapshot Name"))
|
||||
class CreateShareSnapshotForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Share Snapshot Name"))
|
||||
description = forms.CharField(
|
||||
widget=forms.Textarea,
|
||||
label=_("Description"), required=False)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(CreateSnapshotForm, self).__init__(request, *args, **kwargs)
|
||||
|
||||
super(self.__class__, self).__init__(request, *args, **kwargs)
|
||||
# populate share_id
|
||||
share_id = kwargs.get('initial', {}).get('share_id', [])
|
||||
self.fields['share_id'] = forms.CharField(widget=forms.HiddenInput(),
|
||||
initial=share_id)
|
||||
self.fields['share_id'] = forms.CharField(
|
||||
widget=forms.HiddenInput(), initial=share_id)
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
@@ -52,30 +50,30 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
|
||||
messages.success(request, message)
|
||||
return snapshot
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:shares:index")
|
||||
redirect = reverse("horizon:project:share_snapshots:index")
|
||||
exceptions.handle(request,
|
||||
_('Unable to create share snapshot.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
class UpdateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Snapshot Name"))
|
||||
description = forms.CharField(widget=forms.Textarea,
|
||||
label=_("Description"), required=False)
|
||||
class UpdateShareSnapshotForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Share Snapshot Name"))
|
||||
description = forms.CharField(
|
||||
widget=forms.Textarea, label=_("Description"), required=False)
|
||||
|
||||
def handle(self, request, data):
|
||||
snapshot_id = self.initial['snapshot_id']
|
||||
try:
|
||||
manila.share_snapshot_update(
|
||||
request, snapshot_id, data['name'], data['description'])
|
||||
message = _('Updating snapshot "%s"') % data['name']
|
||||
message = _('Updating share snapshot "%s"') % data['name']
|
||||
messages.success(request, message)
|
||||
return True
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to update snapshot.'))
|
||||
exceptions.handle(request, _('Unable to update share snapshot.'))
|
||||
|
||||
|
||||
class AddRule(forms.SelfHandlingForm):
|
||||
class AddShareSnapshotRule(forms.SelfHandlingForm):
|
||||
access_type = forms.ChoiceField(
|
||||
label=_("Access Type"), required=True,
|
||||
choices=(('ip', 'ip'), ('user', 'user'), ('cephx', 'cephx'),
|
||||
@@ -94,7 +92,8 @@ class AddRule(forms.SelfHandlingForm):
|
||||
messages.success(request, message)
|
||||
return True
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:shares:snapshot_manage_rules",
|
||||
args=[self.initial['snapshot_id']])
|
||||
redirect = reverse(
|
||||
"horizon:project:share_snapshots:share_snapshot_manage_rules",
|
||||
args=[self.initial['snapshot_id']])
|
||||
exceptions.handle(
|
||||
request, _('Unable to add snapshot rule.'), redirect=redirect)
|
28
manila_ui/dashboards/project/share_snapshots/panel.py
Normal file
28
manila_ui/dashboards/project/share_snapshots/panel.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.project import dashboard
|
||||
|
||||
|
||||
class ShareSnapshots(horizon.Panel):
|
||||
name = _("Share Snapshots")
|
||||
slug = 'share_snapshots'
|
||||
permissions = (
|
||||
'openstack.services.share',
|
||||
)
|
||||
|
||||
|
||||
dashboard.Project.register(ShareSnapshots)
|
@@ -20,18 +20,17 @@ from django.utils.translation import pgettext_lazy
|
||||
from django.utils.translation import string_concat # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
from manila_ui.api import manila
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
|
||||
DELETABLE_STATES = ("available", "error")
|
||||
|
||||
|
||||
class UpdateRow(tables.Row):
|
||||
class UpdateShareSnapshotRow(tables.Row):
|
||||
ajax = True
|
||||
|
||||
def get_data(self, request, snapshot_id):
|
||||
@@ -45,10 +44,10 @@ def get_size(snapshot):
|
||||
return _("%sGiB") % snapshot.size
|
||||
|
||||
|
||||
class CreateSnapshot(tables.LinkAction):
|
||||
name = "snapshots"
|
||||
verbose_name = _("Create Snapshot")
|
||||
url = "horizon:project:shares:create_snapshot"
|
||||
class CreateShareSnapshot(tables.LinkAction):
|
||||
name = "create_share_snapshot"
|
||||
verbose_name = _("Create Share Snapshot")
|
||||
url = "horizon:project:share_snapshots:share_snapshot_create"
|
||||
classes = ("ajax-modal", "btn-camera")
|
||||
policy_rules = (("share", "share:create_snapshot"),)
|
||||
|
||||
@@ -63,10 +62,10 @@ class CreateSnapshot(tables.LinkAction):
|
||||
if usages['snapshots']['available'] <= 0:
|
||||
if "disabled" not in self.classes:
|
||||
self.classes = [c for c in self.classes] + ['disabled']
|
||||
self.verbose_name = string_concat(self.verbose_name, ' ',
|
||||
_("(Quota exceeded)"))
|
||||
self.verbose_name = string_concat(
|
||||
self.verbose_name, ' ', _("(Quota exceeded)"))
|
||||
else:
|
||||
self.verbose_name = _("Create Snapshot")
|
||||
self.verbose_name = _("Create Share Snapshot")
|
||||
classes = [c for c in self.classes if c != "disabled"]
|
||||
self.classes = classes
|
||||
|
||||
@@ -81,22 +80,22 @@ class CreateSnapshot(tables.LinkAction):
|
||||
return share.status in ("available", "in-use") and snapshot_support
|
||||
|
||||
|
||||
class DeleteSnapshot(tables.DeleteAction):
|
||||
class DeleteShareSnapshot(tables.DeleteAction):
|
||||
policy_rules = (("share", "share:delete_snapshot"),)
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
u"Delete Snapshot",
|
||||
u"Delete Snapshots",
|
||||
u"Delete Share Snapshot",
|
||||
u"Delete Share Snapshots",
|
||||
count
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
u"Deleted Snapshot",
|
||||
u"Deleted Snapshots",
|
||||
u"Deleted Share Snapshot",
|
||||
u"Deleted Share Snapshots",
|
||||
count
|
||||
)
|
||||
|
||||
@@ -123,8 +122,8 @@ class DeleteSnapshot(tables.DeleteAction):
|
||||
return True
|
||||
|
||||
|
||||
class CreateShareFromSnapshot(tables.LinkAction):
|
||||
name = "create_from_snapshot"
|
||||
class CreateShareFromShareSnapshot(tables.LinkAction):
|
||||
name = "create_share_from_share_snapshot"
|
||||
verbose_name = _("Create Share")
|
||||
url = "horizon:project:shares:create"
|
||||
classes = ("ajax-modal", "btn-camera")
|
||||
@@ -139,22 +138,22 @@ class CreateShareFromSnapshot(tables.LinkAction):
|
||||
return share.status == "available"
|
||||
|
||||
|
||||
class EditSnapshot(tables.LinkAction):
|
||||
name = "edit_snapshot"
|
||||
verbose_name = _("Edit Snapshot")
|
||||
url = "horizon:project:shares:edit_snapshot"
|
||||
class EditShareSnapshot(tables.LinkAction):
|
||||
name = "edit_share_snapshot"
|
||||
verbose_name = _("Edit Share Snapshot")
|
||||
url = "horizon:project:share_snapshots:share_snapshot_edit"
|
||||
classes = ("ajax-modal", "btn-camera")
|
||||
|
||||
|
||||
class SnapshotShareNameColumn(tables.Column):
|
||||
class ShareSnapshotShareNameColumn(tables.Column):
|
||||
def get_link_url(self, snapshot):
|
||||
return reverse(self.link, args=(snapshot.share_id,))
|
||||
|
||||
|
||||
class ManageRules(tables.LinkAction):
|
||||
name = "snapshot_manage_rules"
|
||||
verbose_name = _("Manage Rules")
|
||||
url = "horizon:project:shares:snapshot_manage_rules"
|
||||
class ManageShareSnapshotRules(tables.LinkAction):
|
||||
name = "share_snapshot_manage_rules"
|
||||
verbose_name = _("Manage Share Snapshot Rules")
|
||||
url = "horizon:project:share_snapshots:share_snapshot_manage_rules"
|
||||
classes = ("btn-edit",)
|
||||
policy_rules = (("share", "share:access_get_all"),)
|
||||
|
||||
@@ -163,10 +162,10 @@ class ManageRules(tables.LinkAction):
|
||||
return share.mount_snapshot_support
|
||||
|
||||
|
||||
class AddRule(tables.LinkAction):
|
||||
name = "snapshot_rule_add"
|
||||
verbose_name = _("Add rule")
|
||||
url = 'horizon:project:shares:snapshot_rule_add'
|
||||
class AddShareSnapshotRule(tables.LinkAction):
|
||||
name = "share_snapshot_rule_add"
|
||||
verbose_name = _("Add Share Snapshot Rule")
|
||||
url = 'horizon:project:share_snapshots:share_snapshot_rule_add'
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
icon = "plus"
|
||||
policy_rules = (("share", "share:allow_access"),)
|
||||
@@ -180,22 +179,22 @@ class AddRule(tables.LinkAction):
|
||||
return reverse(self.url, args=[self.table.kwargs['snapshot_id']])
|
||||
|
||||
|
||||
class DeleteRule(tables.DeleteAction):
|
||||
class DeleteShareSnapshotRule(tables.DeleteAction):
|
||||
policy_rules = (("share", "share:deny_access"),)
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
u"Delete Rule",
|
||||
u"Delete Rules",
|
||||
u"Delete Share Snapshot Rule",
|
||||
u"Delete Share Snapshot Rules",
|
||||
count
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
u"Deleted Rule",
|
||||
u"Deleted Rules",
|
||||
u"Deleted Share Snapshot Rule",
|
||||
u"Deleted Share Snapshot Rules",
|
||||
count
|
||||
)
|
||||
|
||||
@@ -208,7 +207,7 @@ class DeleteRule(tables.DeleteAction):
|
||||
exceptions.handle(request, msg)
|
||||
|
||||
|
||||
class UpdateRuleRow(tables.Row):
|
||||
class UpdateShareSnapshotRuleRow(tables.Row):
|
||||
ajax = True
|
||||
|
||||
def get_data(self, request, rule_id):
|
||||
@@ -221,7 +220,7 @@ class UpdateRuleRow(tables.Row):
|
||||
raise exceptions.NotFound
|
||||
|
||||
|
||||
class RulesTable(tables.DataTable):
|
||||
class ShareSnapshotRulesTable(tables.DataTable):
|
||||
access_type = tables.Column("access_type", verbose_name=_("Access Type"))
|
||||
access_to = tables.Column("access_to", verbose_name=_("Access to"))
|
||||
status = tables.Column("state", verbose_name=_("Status"))
|
||||
@@ -231,17 +230,19 @@ class RulesTable(tables.DataTable):
|
||||
|
||||
class Meta(object):
|
||||
name = "rules"
|
||||
verbose_name = _("Rules")
|
||||
verbose_name = _("Share Snapshot Rules")
|
||||
status_columns = ["status"]
|
||||
row_class = UpdateRuleRow
|
||||
row_class = UpdateShareSnapshotRuleRow
|
||||
table_actions = (
|
||||
AddRule,
|
||||
DeleteRule)
|
||||
AddShareSnapshotRule,
|
||||
DeleteShareSnapshotRule,
|
||||
)
|
||||
row_actions = (
|
||||
DeleteRule,)
|
||||
DeleteShareSnapshotRule,
|
||||
)
|
||||
|
||||
|
||||
class SnapshotsTable(tables.DataTable):
|
||||
class ShareSnapshotsTable(tables.DataTable):
|
||||
STATUS_CHOICES = (
|
||||
("in-use", True),
|
||||
("available", True),
|
||||
@@ -250,43 +251,50 @@ class SnapshotsTable(tables.DataTable):
|
||||
)
|
||||
STATUS_DISPLAY_CHOICES = (
|
||||
("in-use", pgettext_lazy("Current status of snapshot", u"In-use")),
|
||||
("available", pgettext_lazy("Current status of snapshot",
|
||||
u"Available")),
|
||||
("available",
|
||||
pgettext_lazy("Current status of snapshot", u"Available")),
|
||||
("creating", pgettext_lazy("Current status of snapshot", u"Creating")),
|
||||
("error", pgettext_lazy("Current status of snapshot", u"Error")),
|
||||
)
|
||||
name = tables.Column("name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:shares:snapshot-detail")
|
||||
description = tables.Column("description",
|
||||
verbose_name=_("Description"),
|
||||
truncate=40)
|
||||
size = tables.Column(get_size,
|
||||
verbose_name=_("Size"),
|
||||
attrs={'data-type': 'size'})
|
||||
status = tables.Column("status",
|
||||
filters=(title,),
|
||||
verbose_name=_("Status"),
|
||||
status=True,
|
||||
status_choices=STATUS_CHOICES,
|
||||
display_choices=STATUS_DISPLAY_CHOICES)
|
||||
source = SnapshotShareNameColumn("share",
|
||||
verbose_name=_("Source"),
|
||||
link="horizon:project:shares:detail")
|
||||
name = tables.Column(
|
||||
"name",
|
||||
verbose_name=_("Name"),
|
||||
link="horizon:project:share_snapshots:share_snapshot_detail")
|
||||
description = tables.Column(
|
||||
"description",
|
||||
verbose_name=_("Description"),
|
||||
truncate=40)
|
||||
size = tables.Column(
|
||||
get_size,
|
||||
verbose_name=_("Size"),
|
||||
attrs={'data-type': 'size'})
|
||||
status = tables.Column(
|
||||
"status",
|
||||
filters=(title,),
|
||||
verbose_name=_("Status"),
|
||||
status=True,
|
||||
status_choices=STATUS_CHOICES,
|
||||
display_choices=STATUS_DISPLAY_CHOICES)
|
||||
source = ShareSnapshotShareNameColumn(
|
||||
"share",
|
||||
verbose_name=_("Source"),
|
||||
link="horizon:project:shares:detail")
|
||||
|
||||
def get_object_display(self, obj):
|
||||
return obj.name
|
||||
|
||||
class Meta(object):
|
||||
name = "snapshots"
|
||||
verbose_name = _("Snapshots")
|
||||
name = "share_snapshots"
|
||||
verbose_name = _("Share Snapshots")
|
||||
status_columns = ["status"]
|
||||
row_class = UpdateRow
|
||||
row_class = UpdateShareSnapshotRow
|
||||
table_actions = (
|
||||
tables.NameFilterAction,
|
||||
DeleteSnapshot)
|
||||
DeleteShareSnapshot,
|
||||
)
|
||||
row_actions = (
|
||||
EditSnapshot,
|
||||
CreateShareFromSnapshot,
|
||||
ManageRules,
|
||||
DeleteSnapshot)
|
||||
EditShareSnapshot,
|
||||
CreateShareFromShareSnapshot,
|
||||
ManageShareSnapshotRules,
|
||||
DeleteShareSnapshot,
|
||||
)
|
31
manila_ui/dashboards/project/share_snapshots/tabs.py
Normal file
31
manila_ui/dashboards/project/share_snapshots/tabs.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# 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 tabs
|
||||
|
||||
|
||||
class ShareSnapshotOverviewTab(tabs.Tab):
|
||||
name = _("Share Snapshot Overview")
|
||||
slug = "share_snapshot_overview_tab"
|
||||
template_name = "project/share_snapshots/_detail.html"
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"snapshot": self.tab_group.kwargs['snapshot']}
|
||||
|
||||
|
||||
class ShareSnapshotDetailTabs(tabs.TabGroup):
|
||||
slug = "share_snapshot_details"
|
||||
tabs = (
|
||||
ShareSnapshotOverviewTab,
|
||||
)
|
@@ -2,6 +2,6 @@
|
||||
{% load i18n %}
|
||||
{% block modal-body-right %}
|
||||
<div class="quota-dynamic">
|
||||
{% include "project/shares/snapshots/_limits_snapshots.html" with usages=usages snapshot_quota=True %}
|
||||
{% include "project/share_snapshots/_limits.html" with usages=usages snapshot_quota=True %}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -8,7 +8,7 @@
|
||||
<dd>{{ snapshot.name }}</dd>
|
||||
<dt>{% trans "ID" %}</dt>
|
||||
<dd>{{ snapshot.id }}</dd>
|
||||
{% url 'horizon:admin:shares:detail' snapshot.share_id as share_url %}
|
||||
{% url 'horizon:project:shares:detail' snapshot.share_id as share_url %}
|
||||
<dt>{% trans "Source" %}</dt>
|
||||
<dd><a href="{{ share_url }}">{{ snapshot.share_name_or_id }}</a></dd>
|
||||
{% if snapshot.description %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Create Share Snapshot" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/snapshots/_create_snapshot.html' %}
|
||||
{% include 'project/share_snapshots/_create.html' %}
|
||||
{% endblock %}
|
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Snapshot Details" %}{% endblock %}
|
||||
{% block title %}{% trans "Share Snapshot Details" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Share Snapshots" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ share_snapshots_table.render }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Share Rules" %}{% endblock %}
|
||||
{% block title %}{% trans "Share Snapshot Rules" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{{ table.render }}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Add Rule" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/snapshots/_rule_add.html' %}
|
||||
{% include 'project/share_snapshots/_rule_add.html' %}
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Edit Share Snapshot" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/snapshots/_update.html' %}
|
||||
{% include 'project/share_snapshots/_update.html' %}
|
||||
{% endblock %}
|
45
manila_ui/dashboards/project/share_snapshots/urls.py
Normal file
45
manila_ui/dashboards/project/share_snapshots/urls.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from django.conf import urls
|
||||
|
||||
from manila_ui.dashboards.project.share_snapshots import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
urls.url(
|
||||
r'^$',
|
||||
views.ShareSnapshotsView.as_view(),
|
||||
name='index'),
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/share_snapshot_create/$',
|
||||
views.CreateShareSnapshotView.as_view(),
|
||||
name='share_snapshot_create'),
|
||||
urls.url(
|
||||
r'^(?P<snapshot_id>[^/]+)/share_snapshot_edit/$',
|
||||
views.UpdateShareSnapshotView.as_view(),
|
||||
name='share_snapshot_edit'),
|
||||
urls.url(
|
||||
r'^(?P<snapshot_id>[^/]+)$',
|
||||
views.ShareSnapshotDetailView.as_view(),
|
||||
name='share_snapshot_detail'),
|
||||
urls.url(
|
||||
r'^(?P<snapshot_id>[^/]+)/share_snapshot_rules/$',
|
||||
views.ManageShareSnapshotRulesView.as_view(),
|
||||
name='share_snapshot_manage_rules'),
|
||||
urls.url(
|
||||
r'^(?P<snapshot_id>[^/]+)/share_snapshot_rule_add/$',
|
||||
views.AddShareSnapshotRuleView.as_view(),
|
||||
name='share_snapshot_rule_add'),
|
||||
]
|
@@ -15,31 +15,52 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.snapshots import forms \
|
||||
as snapshot_forms
|
||||
from manila_ui.dashboards.project.shares.snapshots \
|
||||
import tables as snapshot_tables
|
||||
from manila_ui.dashboards.project.shares.snapshots \
|
||||
import tabs as snapshot_tabs
|
||||
from manila_ui.dashboards import utils as ui_utils
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.share_snapshots import forms as ss_forms
|
||||
from manila_ui.dashboards.project.share_snapshots import tables as ss_tables
|
||||
from manila_ui.dashboards.project.share_snapshots import tabs as ss_tabs
|
||||
from manila_ui.dashboards import utils as ui_utils
|
||||
|
||||
class SnapshotDetailView(tabs.TabView):
|
||||
tab_group_class = snapshot_tabs.SnapshotDetailTabs
|
||||
template_name = 'project/shares/snapshots/snapshot_detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:shares:index')
|
||||
|
||||
class ShareSnapshotsView(tables.MultiTableView):
|
||||
table_classes = (
|
||||
ss_tables.ShareSnapshotsTable,
|
||||
)
|
||||
template_name = "project/share_snapshots/index.html"
|
||||
page_title = _("Share Snapshots")
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_share_snapshots_data(self):
|
||||
try:
|
||||
snapshots = manila.share_snapshot_list(self.request)
|
||||
shares = manila.share_list(self.request)
|
||||
share_names = dict([(share.id, share.name or share.id)
|
||||
for share in shares])
|
||||
for snapshot in snapshots:
|
||||
snapshot.share = share_names.get(snapshot.share_id)
|
||||
except Exception:
|
||||
msg = _("Unable to retrieve share snapshots list.")
|
||||
exceptions.handle(self.request, msg)
|
||||
return []
|
||||
# Gather our tenants to correlate against IDs
|
||||
return snapshots
|
||||
|
||||
|
||||
class ShareSnapshotDetailView(tabs.TabView):
|
||||
tab_group_class = ss_tabs.ShareSnapshotDetailTabs
|
||||
template_name = 'project/share_snapshots/detail.html'
|
||||
redirect_url = reverse_lazy('horizon:project:share_snapshots:index')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(SnapshotDetailView, self).get_context_data(**kwargs)
|
||||
context = super(ShareSnapshotDetailView, self).get_context_data(
|
||||
**kwargs)
|
||||
snapshot = self.get_data()
|
||||
snapshot_display_name = snapshot.name or snapshot.id
|
||||
context["snapshot"] = snapshot
|
||||
@@ -69,9 +90,10 @@ class SnapshotDetailView(tabs.TabView):
|
||||
|
||||
snapshot.share_name_or_id = share.name or share.id
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve snapshot details.'),
|
||||
redirect=self.redirect_url)
|
||||
exceptions.handle(
|
||||
self.request,
|
||||
_('Unable to retrieve snapshot details.'),
|
||||
redirect=self.redirect_url)
|
||||
return snapshot
|
||||
|
||||
def get_tabs(self, request, *args, **kwargs):
|
||||
@@ -79,19 +101,19 @@ class SnapshotDetailView(tabs.TabView):
|
||||
return self.tab_group_class(request, snapshot=snapshot, **kwargs)
|
||||
|
||||
|
||||
class CreateSnapshotView(forms.ModalFormView):
|
||||
form_class = snapshot_forms.CreateSnapshotForm
|
||||
class CreateShareSnapshotView(forms.ModalFormView):
|
||||
form_class = ss_forms.CreateShareSnapshotForm
|
||||
form_id = "create_share_snapshot"
|
||||
template_name = 'project/shares/snapshots/create_snapshot.html'
|
||||
template_name = 'project/share_snapshots/create.html'
|
||||
modal_header = _("Create Share Snapshot")
|
||||
modal_id = "create_share_snapshot_modal"
|
||||
submit_label = _("Create Share Snapshot")
|
||||
submit_url = "horizon:project:shares:create_snapshot"
|
||||
success_url = reverse_lazy('horizon:project:shares:snapshots_tab')
|
||||
submit_url = "horizon:project:share_snapshots:share_snapshot_create"
|
||||
success_url = reverse_lazy('horizon:project:share_snapshots:index')
|
||||
page_title = _('Create Share Snapshot')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateSnapshotView, self).get_context_data(**kwargs)
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
context['share_id'] = self.kwargs['share_id']
|
||||
try:
|
||||
context['usages'] = quotas.tenant_limit_usages(self.request)
|
||||
@@ -104,16 +126,16 @@ class CreateSnapshotView(forms.ModalFormView):
|
||||
return {'share_id': self.kwargs["share_id"]}
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
form_class = snapshot_forms.UpdateForm
|
||||
form_id = "update_snapshot"
|
||||
template_name = 'project/shares/snapshots/update.html'
|
||||
modal_header = _("Edit Snapshot")
|
||||
modal_id = "update_snapshot_modal"
|
||||
submit_label = _("Edit")
|
||||
submit_url = "horizon:project:shares:edit_snapshot"
|
||||
success_url = reverse_lazy('horizon:project:shares:snapshots_tab')
|
||||
page_title = _('Edit Snapshot')
|
||||
class UpdateShareSnapshotView(forms.ModalFormView):
|
||||
form_class = ss_forms.UpdateShareSnapshotForm
|
||||
form_id = "update_share_snapshot"
|
||||
template_name = 'project/share_snapshots/update.html'
|
||||
modal_header = _("Update Share Snapshot")
|
||||
modal_id = "update_share_snapshot_modal"
|
||||
submit_label = _("Update")
|
||||
submit_url = "horizon:project:share_snapshots:share_snapshot_edit"
|
||||
success_url = reverse_lazy('horizon:project:share_snapshots:index')
|
||||
page_title = _('Edit Share Snapshot')
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_object(self):
|
||||
@@ -122,13 +144,13 @@ class UpdateView(forms.ModalFormView):
|
||||
try:
|
||||
self._object = manila.share_snapshot_get(self.request, snap_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve snapshot.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
msg = _('Unable to retrieve share snapshot.')
|
||||
url = reverse('horizon:project:share_snapshots:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
@@ -140,15 +162,15 @@ class UpdateView(forms.ModalFormView):
|
||||
'description': snapshot.description}
|
||||
|
||||
|
||||
class AddRuleView(forms.ModalFormView):
|
||||
form_class = snapshot_forms.AddRule
|
||||
class AddShareSnapshotRuleView(forms.ModalFormView):
|
||||
form_class = ss_forms.AddShareSnapshotRule
|
||||
form_id = "rule_add_snap"
|
||||
template_name = 'project/shares/snapshots/rule_add.html'
|
||||
template_name = 'project/share_snapshots/rule_add.html'
|
||||
modal_header = _("Add Rule")
|
||||
modal_id = "rule_add_snap_modal"
|
||||
modal_id = "rule_add_share_snapshot_modal"
|
||||
submit_label = _("Add")
|
||||
submit_url = "horizon:project:shares:snapshot_rule_add"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
submit_url = "horizon:project:share_snapshots:share_snapshot_rule_add"
|
||||
success_url = reverse_lazy("horizon:project:share_snapshots:index")
|
||||
page_title = _('Add Rule')
|
||||
|
||||
def get_object(self):
|
||||
@@ -159,12 +181,12 @@ class AddRuleView(forms.ModalFormView):
|
||||
self.request, snapshot_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve snapshot.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
url = reverse('horizon:project:share_snapshots:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddRuleView, self).get_context_data(**kwargs)
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
@@ -176,16 +198,17 @@ class AddRuleView(forms.ModalFormView):
|
||||
'description': snapshot.description}
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("horizon:project:shares:snapshot_manage_rules",
|
||||
args=[self.kwargs['snapshot_id']])
|
||||
return reverse(
|
||||
"horizon:project:share_snapshots:share_snapshot_manage_rules",
|
||||
args=[self.kwargs['snapshot_id']])
|
||||
|
||||
|
||||
class ManageRulesView(tables.DataTableView):
|
||||
table_class = snapshot_tables.RulesTable
|
||||
template_name = 'project/shares/snapshots/manage_rules.html'
|
||||
class ManageShareSnapshotRulesView(tables.DataTableView):
|
||||
table_class = ss_tables.ShareSnapshotRulesTable
|
||||
template_name = 'project/share_snapshots/manage_rules.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ManageRulesView, self).get_context_data(**kwargs)
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
snapshot = manila.share_snapshot_get(
|
||||
self.request, self.kwargs['snapshot_id'])
|
||||
context['snapshot_display_name'] = snapshot.name or snapshot.id
|
||||
@@ -202,8 +225,9 @@ class ManageRulesView(tables.DataTableView):
|
||||
rules = manila.share_snapshot_rules_list(
|
||||
self.request, snapshot_id)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve snapshot rules.'),
|
||||
redirect=redirect)
|
||||
redirect = reverse('horizon:project:share_snapshots:index')
|
||||
exceptions.handle(
|
||||
self.request,
|
||||
_('Unable to retrieve share snapshot rules.'),
|
||||
redirect=redirect)
|
||||
return rules
|
@@ -1,79 +0,0 @@
|
||||
#
|
||||
# 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 tabs
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.api import network
|
||||
from manila_ui.dashboards.project.shares.share_networks\
|
||||
import tables as share_net_tables
|
||||
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
||||
|
||||
class ShareNetworkTab(tabs.TableTab):
|
||||
name = _("Share Networks")
|
||||
slug = "share_networks_tab"
|
||||
template_name = "horizon/common/_detail_table.html"
|
||||
|
||||
def __init__(self, tab_group, request):
|
||||
if base.is_service_enabled(request, 'network'):
|
||||
self.table_classes = (share_net_tables.ShareNetworksTable,)
|
||||
else:
|
||||
self.table_classes = (share_net_tables.NovaShareNetworkTable,)
|
||||
super(ShareNetworkTab, self).__init__(tab_group, request)
|
||||
|
||||
def get_share_networks_data(self):
|
||||
try:
|
||||
share_networks = manila.share_network_list(self.request,
|
||||
detailed=True)
|
||||
if base.is_service_enabled(self.request, 'network'):
|
||||
neutron_net_names = dict((net.id, net.name) for net in
|
||||
neutron.network_list(self.request))
|
||||
neutron_subnet_names = dict((net.id, net.name) for net in
|
||||
neutron.subnet_list(self.request))
|
||||
for sn in share_networks:
|
||||
sn.neutron_net = neutron_net_names.get(
|
||||
sn.neutron_net_id) or sn.neutron_net_id or "-"
|
||||
sn.neutron_subnet = neutron_subnet_names.get(
|
||||
sn.neutron_subnet_id) or sn.neutron_subnet_id or "-"
|
||||
else:
|
||||
nova_net_names = dict(
|
||||
[(net.id, net.label)
|
||||
for net in network.network_list(self.request)])
|
||||
for sn in share_networks:
|
||||
sn.nova_net = nova_net_names.get(
|
||||
sn.nova_net_id) or sn.nova_net_id or "-"
|
||||
except Exception:
|
||||
share_networks = []
|
||||
exceptions.handle(self.request,
|
||||
_("Unable to retrieve share networks"))
|
||||
return share_networks
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = ("project/shares/share_networks/_detail_overview.html")
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"share_network": self.tab_group.kwargs['share_network']}
|
||||
|
||||
|
||||
class ShareNetworkDetailTabs(tabs.TabGroup):
|
||||
slug = "share_network_details"
|
||||
tabs = (OverviewTab,)
|
@@ -1,77 +0,0 @@
|
||||
# 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 tabs
|
||||
|
||||
from manila_ui.api import manila
|
||||
|
||||
from manila_ui.dashboards.project.shares.shares \
|
||||
import tables as share_tables
|
||||
from manila_ui.dashboards import utils
|
||||
|
||||
|
||||
class SharesTab(tabs.TableTab):
|
||||
table_classes = (share_tables.SharesTable, )
|
||||
name = _("Shares")
|
||||
slug = "shares_tab"
|
||||
template_name = "horizon/common/_detail_table.html"
|
||||
|
||||
def _set_id_if_nameless(self, shares):
|
||||
for share in shares:
|
||||
if not share.name:
|
||||
share.name = share.id
|
||||
|
||||
def get_shares_data(self):
|
||||
share_nets_names = {}
|
||||
share_nets = manila.share_network_list(self.request)
|
||||
for share_net in share_nets:
|
||||
share_nets_names[share_net.id] = share_net.name
|
||||
try:
|
||||
shares = manila.share_list(self.request)
|
||||
for share in shares:
|
||||
share.share_network = (
|
||||
share_nets_names.get(share.share_network_id) or
|
||||
share.share_network_id)
|
||||
share.metadata = utils.metadata_to_str(share.metadata)
|
||||
|
||||
snapshots = manila.share_snapshot_list(self.request, detailed=True)
|
||||
share_ids_with_snapshots = []
|
||||
for snapshot in snapshots:
|
||||
share_ids_with_snapshots.append(snapshot.to_dict()['share_id'])
|
||||
for share in shares:
|
||||
if share.to_dict()['id'] in share_ids_with_snapshots:
|
||||
setattr(share, 'has_snapshot', True)
|
||||
else:
|
||||
setattr(share, 'has_snapshot', False)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share list.'))
|
||||
return []
|
||||
# Gather our tenants to correlate against IDs
|
||||
return shares
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = "project/shares/shares/_detail_overview.html"
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"share": self.tab_group.kwargs['share']}
|
||||
|
||||
|
||||
class ShareDetailTabs(tabs.TabGroup):
|
||||
slug = "share_details"
|
||||
tabs = (OverviewTab,)
|
@@ -1,319 +0,0 @@
|
||||
# Copyright 2012 Nebula, 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.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.shares import forms \
|
||||
as share_form
|
||||
from manila_ui.dashboards.project.shares.shares \
|
||||
import tables as shares_tables
|
||||
from manila_ui.dashboards.project.shares.shares \
|
||||
import tabs as shares_tabs
|
||||
from manila_ui.dashboards import utils as ui_utils
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
|
||||
class ShareTableMixIn(object):
|
||||
def _get_shares(self, search_opts=None):
|
||||
try:
|
||||
return manila.share_list(self.request, search_opts=search_opts)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share list.'))
|
||||
return []
|
||||
|
||||
def _set_id_if_nameless(self, shares):
|
||||
for share in shares:
|
||||
# It is possible to create a share with no name
|
||||
if not share.name:
|
||||
share.name = share.id
|
||||
|
||||
|
||||
class DetailView(tabs.TabView):
|
||||
tab_group_class = shares_tabs.ShareDetailTabs
|
||||
template_name = 'project/shares/shares/detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DetailView, self).get_context_data(**kwargs)
|
||||
share = self.get_data()
|
||||
share_display_name = share.name or share.id
|
||||
context["share"] = share
|
||||
context["share_display_name"] = share_display_name
|
||||
context["page_title"] = _("Share Details: "
|
||||
"%(share_display_name)s") % {
|
||||
'share_display_name': share_display_name}
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_data(self):
|
||||
try:
|
||||
share_id = self.kwargs['share_id']
|
||||
share = manila.share_get(self.request, share_id)
|
||||
share.rules = manila.share_rules_list(self.request, share_id)
|
||||
share.export_locations = manila.share_export_location_list(
|
||||
self.request, share_id)
|
||||
export_locations = [
|
||||
exp['path'] for exp in share.export_locations]
|
||||
share.el_size = ui_utils.calculate_longest_str_size(
|
||||
export_locations)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share details.'),
|
||||
redirect=redirect)
|
||||
return share
|
||||
|
||||
def get_tabs(self, request, *args, **kwargs):
|
||||
share = self.get_data()
|
||||
return self.tab_group_class(request, share=share, **kwargs)
|
||||
|
||||
|
||||
class CreateView(forms.ModalFormView):
|
||||
form_class = share_form.CreateForm
|
||||
form_id = "create_share"
|
||||
template_name = 'project/shares/shares/create.html'
|
||||
modal_header = _("Create Share")
|
||||
modal_id = "create_share_modal"
|
||||
submit_label = _("Create")
|
||||
submit_url = reverse_lazy("horizon:project:shares:create")
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Create a Share')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateView, self).get_context_data(**kwargs)
|
||||
try:
|
||||
context['usages'] = quotas.tenant_limit_usages(self.request)
|
||||
except Exception:
|
||||
exceptions.handle(self.request)
|
||||
return context
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
form_class = share_form.UpdateForm
|
||||
form_id = "update_share"
|
||||
template_name = 'project/shares/shares/update.html'
|
||||
modal_header = _("Edit Share")
|
||||
modal_id = "update_share_modal"
|
||||
submit_label = _("Edit")
|
||||
submit_url = "horizon:project:shares:update"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Edit Share')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
vol_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, vol_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
self.submit_url = reverse(self.submit_url, kwargs=self.kwargs)
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'name': share.name,
|
||||
'description': share.description}
|
||||
|
||||
|
||||
class UpdateMetadataView(forms.ModalFormView):
|
||||
form_class = share_form.UpdateMetadataForm
|
||||
form_id = "update_share_metadata"
|
||||
template_name = 'project/shares/shares/update_metadata.html'
|
||||
modal_header = _("Edit Share Metadata")
|
||||
modal_id = "update_share_metadata_modal"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:shares:update_metadata"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Edit Share Metadata')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
sh_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, sh_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateMetadataView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'metadata': share.metadata}
|
||||
|
||||
|
||||
class AddRuleView(forms.ModalFormView):
|
||||
form_class = share_form.AddRule
|
||||
form_id = "rule_add"
|
||||
template_name = 'project/shares/shares/rule_add.html'
|
||||
modal_header = _("Add Rule")
|
||||
modal_id = "rule_add_modal"
|
||||
submit_label = _("Add")
|
||||
submit_url = "horizon:project:shares:rule_add"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Add Rule')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
vol_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, vol_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddRuleView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'name': share.name,
|
||||
'description': share.description}
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("horizon:project:shares:manage_rules",
|
||||
args=[self.kwargs['share_id']])
|
||||
|
||||
|
||||
class ManageRulesView(tables.DataTableView):
|
||||
table_class = shares_tables.RulesTable
|
||||
template_name = 'project/shares/shares/manage_rules.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ManageRulesView, self).get_context_data(**kwargs)
|
||||
share = manila.share_get(self.request, self.kwargs['share_id'])
|
||||
context['share_display_name'] = share.name or share.id
|
||||
context["share"] = self.get_data()
|
||||
context["page_title"] = _("Share Rules: "
|
||||
"%(share_display_name)s") % {
|
||||
'share_display_name': context['share_display_name']}
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_data(self):
|
||||
try:
|
||||
share_id = self.kwargs['share_id']
|
||||
rules = manila.share_rules_list(self.request, share_id)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share rules.'),
|
||||
redirect=redirect)
|
||||
return rules
|
||||
|
||||
|
||||
class ExtendView(forms.ModalFormView):
|
||||
form_class = share_form.ExtendForm
|
||||
form_id = "extend_share"
|
||||
template_name = 'project/shares/shares/extend.html'
|
||||
modal_header = _("Extend Share")
|
||||
modal_id = "extend_share_modal"
|
||||
submit_label = _("Extend")
|
||||
submit_url = "horizon:project:shares:extend"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Extend Share')
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_object(self):
|
||||
try:
|
||||
return manila.share_get(self.request, self.kwargs['share_id'])
|
||||
except Exception:
|
||||
exceptions.handle(self.request, _('Unable to retrieve share.'))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtendView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
try:
|
||||
context['usages'] = quotas.tenant_limit_usages(self.request)
|
||||
context['usages']['totalShareGigabytesUsed'] -= int(
|
||||
self.get_object().size)
|
||||
except Exception:
|
||||
exceptions.handle(self.request)
|
||||
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
if not share or isinstance(share, Exception):
|
||||
raise exceptions.NotFound()
|
||||
return {
|
||||
'share_id': self.kwargs["share_id"],
|
||||
'name': share.name or share.id,
|
||||
'orig_size': share.size,
|
||||
'new_size': int(share.size) + 1,
|
||||
}
|
||||
|
||||
|
||||
class RevertView(forms.ModalFormView):
|
||||
form_class = share_form.RevertForm
|
||||
form_id = "revert_share"
|
||||
template_name = 'project/shares/shares/revert.html'
|
||||
modal_header = _("Revert Share to a Snapshot")
|
||||
modal_id = "revert_share_modal"
|
||||
submit_label = _("Revert share to a snapshot")
|
||||
submit_url = "horizon:project:shares:revert"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Revert Share to a Snapshot')
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_object(self):
|
||||
try:
|
||||
return manila.share_get(self.request, self.kwargs['share_id'])
|
||||
except Exception:
|
||||
exceptions.handle(self.request, _('Unable to retrieve share.'))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
if not share or isinstance(share, Exception):
|
||||
raise exceptions.NotFound()
|
||||
return {
|
||||
'share_id': self.kwargs["share_id"],
|
||||
'name': share.name or share.id,
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
#
|
||||
# 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 tabs
|
||||
|
||||
from manila_ui.api import manila
|
||||
|
||||
from manila_ui.dashboards.project.shares.snapshots \
|
||||
import tables as snapshot_tables
|
||||
|
||||
|
||||
class SnapshotsTab(tabs.TableTab):
|
||||
table_classes = (snapshot_tables.SnapshotsTable, )
|
||||
name = _("Snapshots")
|
||||
slug = "snapshots_tab"
|
||||
template_name = "horizon/common/_detail_table.html"
|
||||
|
||||
def _set_id_if_nameless(self, snapshots):
|
||||
for snap in snapshots:
|
||||
if not snap.name:
|
||||
snap.name = snap.id
|
||||
|
||||
def get_snapshots_data(self):
|
||||
try:
|
||||
snapshots = manila.share_snapshot_list(self.request)
|
||||
shares = manila.share_list(self.request)
|
||||
share_names = dict([(share.id, share.name or share.id)
|
||||
for share in shares])
|
||||
for snapshot in snapshots:
|
||||
snapshot.share = share_names.get(snapshot.share_id)
|
||||
except Exception:
|
||||
msg = _("Unable to retrieve share snapshots list.")
|
||||
exceptions.handle(self.request, msg)
|
||||
return []
|
||||
# Gather our tenants to correlate against IDs
|
||||
return snapshots
|
||||
|
||||
|
||||
class SnapshotOverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = ("project/shares/snapshots/"
|
||||
"_snapshot_detail_overview.html")
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"snapshot": self.tab_group.kwargs['snapshot']}
|
||||
|
||||
|
||||
class SnapshotDetailTabs(tabs.TabGroup):
|
||||
slug = "snapshot_details"
|
||||
tabs = (SnapshotOverviewTab,)
|
@@ -23,8 +23,7 @@ from horizon import exceptions
|
||||
from horizon import messages
|
||||
from horizon import tables
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.snapshots \
|
||||
import tables as snapshot_tables
|
||||
from manila_ui.dashboards.project.share_snapshots import tables as ss_tables
|
||||
from manila_ui.dashboards import utils
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
@@ -383,7 +382,7 @@ class SharesTable(SharesTableBase):
|
||||
EditShare,
|
||||
ExtendShare,
|
||||
RevertShare,
|
||||
snapshot_tables.CreateSnapshot,
|
||||
ss_tables.CreateShareSnapshot,
|
||||
ManageRules,
|
||||
ManageReplicas,
|
||||
EditShareMetadata,
|
30
manila_ui/dashboards/project/shares/tabs.py
Normal file
30
manila_ui/dashboards/project/shares/tabs.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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 tabs
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
slug = "overview"
|
||||
template_name = "project/shares/_detail.html"
|
||||
|
||||
def get_context_data(self, request):
|
||||
return {"share": self.tab_group.kwargs['share']}
|
||||
|
||||
|
||||
class ShareDetailTabs(tabs.TabGroup):
|
||||
slug = "share_details"
|
||||
tabs = (
|
||||
OverviewTab,
|
||||
)
|
@@ -2,6 +2,6 @@
|
||||
{% load i18n %}
|
||||
{% block modal-body-right %}
|
||||
<div class="quota-dynamic">
|
||||
{% include "project/shares/shares/_extend_limits.html" with usages=usages %}
|
||||
{% include "project/shares/_limits.html" with usages=usages %}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -33,7 +33,7 @@
|
||||
{% endfor %}
|
||||
{% if share.snapshot_id %}
|
||||
<dt>{% trans "Snapshot ID" %}</dt>
|
||||
{% url 'horizon:project:shares:snapshot-detail' share.snapshot_id as snapshot_url%}
|
||||
{% url 'horizon:project:share_snapshots:share_snapshot_detail' share.snapshot_id as snapshot_url%}
|
||||
<dd><a href="{{ snapshot_url }}">{{ share.snapshot_id }}</a></dd>
|
||||
{% endif %}
|
||||
<dt>{% trans "Visibility" %}</dt>
|
||||
@@ -58,7 +58,7 @@
|
||||
{% endif %}
|
||||
{% if share.share_network_id %}
|
||||
<dt>{% trans "Share network" %}</dt>
|
||||
{% url 'horizon:project:shares:share_network_detail' share.share_network_id as sn_url%}
|
||||
{% url 'horizon:project:share_networks:share_network_detail' share.share_network_id as sn_url%}
|
||||
<dd><a href="{{ sn_url }}">{{ share.share_network_id }}</a></dd>
|
||||
{% endif %}
|
||||
<dt>{% trans "Mount snapshot support" %}</dt>
|
@@ -2,6 +2,6 @@
|
||||
{% load i18n %}
|
||||
{% block modal-body-right %}
|
||||
<div class="quota-dynamic">
|
||||
{% include "project/shares/shares/_limits.html" with usages=usages %}
|
||||
{% include "project/shares/_extend_limits.html" with usages=usages %}
|
||||
</div>
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Create Share" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_create.html' %}
|
||||
{% include 'project/shares/_create.html' %}
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Extend Share" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_extend.html' %}
|
||||
{% endblock %}
|
||||
{% include 'project/shares/_extend.html' %}
|
||||
{% endblock %}
|
@@ -5,7 +5,7 @@
|
||||
{% block main %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ tab_group.render }}
|
||||
{{ shares_table.render }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Revert Share" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_revert.html' %}
|
||||
{% include 'project/shares/_revert.html' %}
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Add Rule" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_rule_add.html' %}
|
||||
{% include 'project/shares/_rule_add.html' %}
|
||||
{% endblock %}
|
@@ -1,60 +0,0 @@
|
||||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block form_id %}{% endblock %}
|
||||
{% block form_action %}{% url 'horizon:project:shares:add_security_service' share_network.id %}{% endblock %}
|
||||
|
||||
{% block modal_id %}add_security_service_modal{% endblock %}
|
||||
{% block modal-header %}{% trans "Add Security Service" %}{% endblock %}
|
||||
|
||||
|
||||
{% block modal-body %}
|
||||
<div class="left">
|
||||
<fieldset>
|
||||
{% include "horizon/common/_form_fields.html" %}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="right">
|
||||
<h3>{% trans "Description" %}:</h3>
|
||||
<p>{% blocktrans %}
|
||||
The security service can be used by backend drivers to
|
||||
configure clients, for more secure using of share.
|
||||
{% endblocktrans %}</p>
|
||||
</div>
|
||||
<table class="table-fixed" id="networkListSortContainer">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="actions">
|
||||
<label id="selected_network_label">{% trans "Selected Networks" %}</label>
|
||||
<ul id="selected_network" class="networklist">
|
||||
</ul>
|
||||
<label>{% trans "Available networks" %}</label>
|
||||
<ul id="available_network" class="networklist">
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="table-fixed" id="networkListIdContainer">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="actions">
|
||||
<div id="networkListId">
|
||||
{% include "horizon/common/_form_fields.html" %}
|
||||
</div>
|
||||
</td>
|
||||
<td class="help_text">
|
||||
{{ step.get_help_text }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Security Service" %}" />
|
||||
<a href="{% url 'horizon:project:shares:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Edit Share" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_update.html' %}
|
||||
{% include 'project/shares/_update.html' %}
|
||||
{% endblock %}
|
@@ -3,5 +3,5 @@
|
||||
{% block title %}{% trans "Edit Share Metadata" %}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{% include 'project/shares/shares/_update_metadata.html' %}
|
||||
{% include 'project/shares/_update_metadata.html' %}
|
||||
{% endblock %}
|
@@ -12,96 +12,68 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls import url # noqa
|
||||
from django.conf import urls
|
||||
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares.replicas\
|
||||
import views as replica_views
|
||||
from manila_ui.dashboards.project.shares.security_services \
|
||||
import views as security_services_views
|
||||
from manila_ui.dashboards.project.shares.share_networks \
|
||||
import views as share_networks_views
|
||||
from manila_ui.dashboards.project.shares.shares \
|
||||
import views as shares_views
|
||||
from manila_ui.dashboards.project.shares.snapshots\
|
||||
import views as snapshot_views
|
||||
from manila_ui.dashboards.project.shares import views
|
||||
from manila_ui.dashboards.project.shares.replicas import views as replica_views
|
||||
from manila_ui.dashboards.project.shares import views as shares_views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^\?tab=share_tabs__snapshots_tab$',
|
||||
views.IndexView.as_view(),
|
||||
name='snapshots_tab'),
|
||||
url(r'^create/$', shares_views.CreateView.as_view(), name='create'),
|
||||
url(r'^create_security_service$',
|
||||
security_services_views.CreateView.as_view(),
|
||||
name='create_security_service'),
|
||||
url(r'^create_share_network$',
|
||||
share_networks_views.Create.as_view(),
|
||||
name='create_share_network'),
|
||||
url(r'^share_networks/(?P<share_network_id>[^/]+)/update$',
|
||||
share_networks_views.Update.as_view(),
|
||||
name='update_share_network'),
|
||||
url(r'^share_networks/(?P<share_network_id>[^/]+)$',
|
||||
share_networks_views.Detail.as_view(),
|
||||
name='share_network_detail'),
|
||||
url(r'^security_services/(?P<sec_service_id>[^/]+)/update/$',
|
||||
security_services_views.UpdateView.as_view(),
|
||||
name='update_security_service'),
|
||||
url(r'^security_services/(?P<sec_service_id>[^/]+)$',
|
||||
security_services_views.Detail.as_view(),
|
||||
name='security_service_detail'),
|
||||
url(r'^snapshots/(?P<snapshot_id>[^/]+)$',
|
||||
snapshot_views.SnapshotDetailView.as_view(),
|
||||
name='snapshot-detail'),
|
||||
url(r'^(?P<share_id>[^/]+)/create_snapshot/$',
|
||||
snapshot_views.CreateSnapshotView.as_view(),
|
||||
name='create_snapshot'),
|
||||
url(r'^(?P<snapshot_id>[^/]+)/edit_snapshot/$',
|
||||
snapshot_views.UpdateView.as_view(),
|
||||
name='edit_snapshot'),
|
||||
url(r'^(?P<share_id>[^/]+)/rules/$',
|
||||
urls.url(
|
||||
r'^$',
|
||||
shares_views.SharesView.as_view(),
|
||||
name='index'),
|
||||
urls.url(
|
||||
r'^create/$',
|
||||
shares_views.CreateView.as_view(),
|
||||
name='create'),
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/rules/$',
|
||||
shares_views.ManageRulesView.as_view(),
|
||||
name='manage_rules'),
|
||||
url(r'^(?P<share_id>[^/]+)/rule_add/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/rule_add/$',
|
||||
shares_views.AddRuleView.as_view(),
|
||||
name='rule_add'),
|
||||
url(r'^(?P<share_id>[^/]+)/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/$',
|
||||
shares_views.DetailView.as_view(),
|
||||
name='detail'),
|
||||
url(r'^(?P<share_id>[^/]+)/update/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/update/$',
|
||||
shares_views.UpdateView.as_view(),
|
||||
name='update'),
|
||||
url(r'^(?P<share_id>[^/]+)/update_metadata/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/update_metadata/$',
|
||||
shares_views.UpdateMetadataView.as_view(),
|
||||
name='update_metadata'),
|
||||
url(r'^(?P<share_id>[^/]+)/extend/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/extend/$',
|
||||
shares_views.ExtendView.as_view(),
|
||||
name='extend'),
|
||||
url(r'^(?P<share_id>[^/]+)/revert/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/revert/$',
|
||||
shares_views.RevertView.as_view(),
|
||||
name='revert'),
|
||||
url(r'^(?P<snapshot_id>[^/]+)/snapshot_rules/$',
|
||||
snapshot_views.ManageRulesView.as_view(),
|
||||
name='snapshot_manage_rules'),
|
||||
url(r'^(?P<snapshot_id>[^/]+)/snapshot_rule_add/$',
|
||||
snapshot_views.AddRuleView.as_view(),
|
||||
name='snapshot_rule_add'),
|
||||
]
|
||||
|
||||
if manila.is_replication_enabled():
|
||||
urlpatterns.extend([
|
||||
url(r'^(?P<share_id>[^/]+)/create_replica/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/create_replica/$',
|
||||
replica_views.CreateReplicaView.as_view(),
|
||||
name='create_replica'),
|
||||
url(r'^(?P<share_id>[^/]+)/replicas/$',
|
||||
urls.url(
|
||||
r'^(?P<share_id>[^/]+)/replicas/$',
|
||||
replica_views.ManageReplicasView.as_view(),
|
||||
name='manage_replicas'),
|
||||
url(r'^replica/(?P<replica_id>[^/]+)$',
|
||||
urls.url(
|
||||
r'^replica/(?P<replica_id>[^/]+)$',
|
||||
replica_views.DetailReplicaView.as_view(),
|
||||
name='replica_detail'),
|
||||
url(r'^replica/(?P<replica_id>[^/]+)/set_replica_as_active$',
|
||||
urls.url(
|
||||
r'^replica/(?P<replica_id>[^/]+)/set_replica_as_active$',
|
||||
replica_views.SetReplicaAsActiveView.as_view(),
|
||||
name='set_replica_as_active'),
|
||||
])
|
||||
|
@@ -12,29 +12,342 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
|
||||
from manila_ui.dashboards.project.shares.security_services \
|
||||
import tabs as security_services_tabs
|
||||
from manila_ui.dashboards.project.shares.share_networks \
|
||||
import tabs as share_networks_tabs
|
||||
from manila_ui.dashboards.project.shares.shares \
|
||||
import tabs as shares_tabs
|
||||
from manila_ui.dashboards.project.shares.snapshots \
|
||||
import tabs as snapshots_tabs
|
||||
from manila_ui.api import manila
|
||||
from manila_ui.dashboards.project.shares import forms as share_form
|
||||
from manila_ui.dashboards.project.shares import tables as shares_tables
|
||||
from manila_ui.dashboards.project.shares import tabs as shares_tabs
|
||||
from manila_ui.dashboards import utils as ui_utils
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
|
||||
class ShareTabs(tabs.TabGroup):
|
||||
slug = "share_tabs"
|
||||
tabs = (shares_tabs.SharesTab,
|
||||
snapshots_tabs.SnapshotsTab,
|
||||
share_networks_tabs.ShareNetworkTab,
|
||||
security_services_tabs.SecurityServiceTab,)
|
||||
sticky = True
|
||||
class ShareTableMixIn(object):
|
||||
def _get_shares(self, search_opts=None):
|
||||
try:
|
||||
return manila.share_list(self.request, search_opts=search_opts)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share list.'))
|
||||
return []
|
||||
|
||||
def _set_id_if_nameless(self, shares):
|
||||
for share in shares:
|
||||
# It is possible to create a share with no name
|
||||
if not share.name:
|
||||
share.name = share.id
|
||||
|
||||
|
||||
class IndexView(tabs.TabbedTableView):
|
||||
tab_group_class = ShareTabs
|
||||
class SharesView(tables.MultiTableView, ShareTableMixIn):
|
||||
table_classes = (
|
||||
shares_tables.SharesTable,
|
||||
)
|
||||
template_name = "project/shares/index.html"
|
||||
page_title = _("Shares")
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_shares_data(self):
|
||||
share_nets_names = {}
|
||||
share_nets = manila.share_network_list(self.request)
|
||||
for share_net in share_nets:
|
||||
share_nets_names[share_net.id] = share_net.name
|
||||
try:
|
||||
shares = manila.share_list(self.request)
|
||||
for share in shares:
|
||||
share.share_network = (
|
||||
share_nets_names.get(share.share_network_id) or
|
||||
share.share_network_id)
|
||||
share.metadata = ui_utils.metadata_to_str(share.metadata)
|
||||
|
||||
snapshots = manila.share_snapshot_list(self.request, detailed=True)
|
||||
share_ids_with_snapshots = []
|
||||
for snapshot in snapshots:
|
||||
share_ids_with_snapshots.append(snapshot.to_dict()['share_id'])
|
||||
for share in shares:
|
||||
if share.to_dict()['id'] in share_ids_with_snapshots:
|
||||
setattr(share, 'has_snapshot', True)
|
||||
else:
|
||||
setattr(share, 'has_snapshot', False)
|
||||
except Exception:
|
||||
exceptions.handle(
|
||||
self.request, _('Unable to retrieve share list.'))
|
||||
return []
|
||||
# Gather our tenants to correlate against IDs
|
||||
return shares
|
||||
|
||||
|
||||
class DetailView(tabs.TabView):
|
||||
tab_group_class = shares_tabs.ShareDetailTabs
|
||||
template_name = 'project/shares/detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DetailView, self).get_context_data(**kwargs)
|
||||
share = self.get_data()
|
||||
share_display_name = share.name or share.id
|
||||
context["share"] = share
|
||||
context["share_display_name"] = share_display_name
|
||||
context["page_title"] = _("Share Details: "
|
||||
"%(share_display_name)s") % {
|
||||
'share_display_name': share_display_name}
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_data(self):
|
||||
try:
|
||||
share_id = self.kwargs['share_id']
|
||||
share = manila.share_get(self.request, share_id)
|
||||
share.rules = manila.share_rules_list(self.request, share_id)
|
||||
share.export_locations = manila.share_export_location_list(
|
||||
self.request, share_id)
|
||||
export_locations = [
|
||||
exp['path'] for exp in share.export_locations]
|
||||
share.el_size = ui_utils.calculate_longest_str_size(
|
||||
export_locations)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share details.'),
|
||||
redirect=redirect)
|
||||
return share
|
||||
|
||||
def get_tabs(self, request, *args, **kwargs):
|
||||
share = self.get_data()
|
||||
return self.tab_group_class(request, share=share, **kwargs)
|
||||
|
||||
|
||||
class CreateView(forms.ModalFormView):
|
||||
form_class = share_form.CreateForm
|
||||
form_id = "create_share"
|
||||
template_name = 'project/shares/create.html'
|
||||
modal_header = _("Create Share")
|
||||
modal_id = "create_share_modal"
|
||||
submit_label = _("Create")
|
||||
submit_url = reverse_lazy("horizon:project:shares:create")
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Create a Share')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateView, self).get_context_data(**kwargs)
|
||||
try:
|
||||
context['usages'] = quotas.tenant_limit_usages(self.request)
|
||||
except Exception:
|
||||
exceptions.handle(self.request)
|
||||
return context
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
form_class = share_form.UpdateForm
|
||||
form_id = "update_share"
|
||||
template_name = 'project/shares/update.html'
|
||||
modal_header = _("Edit Share")
|
||||
modal_id = "update_share_modal"
|
||||
submit_label = _("Edit")
|
||||
submit_url = "horizon:project:shares:update"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Edit Share')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
vol_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, vol_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
self.submit_url = reverse(self.submit_url, kwargs=self.kwargs)
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'name': share.name,
|
||||
'description': share.description}
|
||||
|
||||
|
||||
class UpdateMetadataView(forms.ModalFormView):
|
||||
form_class = share_form.UpdateMetadataForm
|
||||
form_id = "update_share_metadata"
|
||||
template_name = 'project/shares/update_metadata.html'
|
||||
modal_header = _("Edit Share Metadata")
|
||||
modal_id = "update_share_metadata_modal"
|
||||
submit_label = _("Save Changes")
|
||||
submit_url = "horizon:project:shares:update_metadata"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Edit Share Metadata')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
sh_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, sh_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UpdateMetadataView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'metadata': share.metadata}
|
||||
|
||||
|
||||
class AddRuleView(forms.ModalFormView):
|
||||
form_class = share_form.AddRule
|
||||
form_id = "rule_add"
|
||||
template_name = 'project/shares/rule_add.html'
|
||||
modal_header = _("Add Rule")
|
||||
modal_id = "rule_add_modal"
|
||||
submit_label = _("Add")
|
||||
submit_url = "horizon:project:shares:rule_add"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Add Rule')
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
vol_id = self.kwargs['share_id']
|
||||
try:
|
||||
self._object = manila.share_get(self.request, vol_id)
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve share.')
|
||||
url = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request, msg, redirect=url)
|
||||
return self._object
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddRuleView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
return {'share_id': self.kwargs["share_id"],
|
||||
'name': share.name,
|
||||
'description': share.description}
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("horizon:project:shares:manage_rules",
|
||||
args=[self.kwargs['share_id']])
|
||||
|
||||
|
||||
class ManageRulesView(tables.DataTableView):
|
||||
table_class = shares_tables.RulesTable
|
||||
template_name = 'project/shares/manage_rules.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ManageRulesView, self).get_context_data(**kwargs)
|
||||
share = manila.share_get(self.request, self.kwargs['share_id'])
|
||||
context['share_display_name'] = share.name or share.id
|
||||
context["share"] = self.get_data()
|
||||
context["page_title"] = _("Share Rules: "
|
||||
"%(share_display_name)s") % {
|
||||
'share_display_name': context['share_display_name']}
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_data(self):
|
||||
try:
|
||||
share_id = self.kwargs['share_id']
|
||||
rules = manila.share_rules_list(self.request, share_id)
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:shares:index')
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve share rules.'),
|
||||
redirect=redirect)
|
||||
return rules
|
||||
|
||||
|
||||
class ExtendView(forms.ModalFormView):
|
||||
form_class = share_form.ExtendForm
|
||||
form_id = "extend_share"
|
||||
template_name = 'project/shares/extend.html'
|
||||
modal_header = _("Extend Share")
|
||||
modal_id = "extend_share_modal"
|
||||
submit_label = _("Extend")
|
||||
submit_url = "horizon:project:shares:extend"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Extend Share')
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_object(self):
|
||||
try:
|
||||
return manila.share_get(self.request, self.kwargs['share_id'])
|
||||
except Exception:
|
||||
exceptions.handle(self.request, _('Unable to retrieve share.'))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExtendView, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
try:
|
||||
context['usages'] = quotas.tenant_limit_usages(self.request)
|
||||
context['usages']['totalShareGigabytesUsed'] -= int(
|
||||
self.get_object().size)
|
||||
except Exception:
|
||||
exceptions.handle(self.request)
|
||||
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
if not share or isinstance(share, Exception):
|
||||
raise exceptions.NotFound()
|
||||
return {
|
||||
'share_id': self.kwargs["share_id"],
|
||||
'name': share.name or share.id,
|
||||
'orig_size': share.size,
|
||||
'new_size': int(share.size) + 1,
|
||||
}
|
||||
|
||||
|
||||
class RevertView(forms.ModalFormView):
|
||||
form_class = share_form.RevertForm
|
||||
form_id = "revert_share"
|
||||
template_name = 'project/shares/revert.html'
|
||||
modal_header = _("Revert Share to a Snapshot")
|
||||
modal_id = "revert_share_modal"
|
||||
submit_label = _("Revert share to a snapshot")
|
||||
submit_url = "horizon:project:shares:revert"
|
||||
success_url = reverse_lazy("horizon:project:shares:index")
|
||||
page_title = _('Revert Share to a Snapshot')
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_object(self):
|
||||
try:
|
||||
return manila.share_get(self.request, self.kwargs['share_id'])
|
||||
except Exception:
|
||||
exceptions.handle(self.request, _('Unable to retrieve share.'))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(self.__class__, self).get_context_data(**kwargs)
|
||||
args = (self.get_object().id,)
|
||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
share = self.get_object()
|
||||
if not share or isinstance(share, Exception):
|
||||
raise exceptions.NotFound()
|
||||
return {
|
||||
'share_id': self.kwargs["share_id"],
|
||||
'name': share.name or share.id,
|
||||
}
|
||||
|
@@ -1,3 +1,17 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
# The slug of the panel group to be added to HORIZON_CONFIG. Required.
|
||||
PANEL_GROUP = 'share'
|
||||
# The display name of the PANEL_GROUP. Required.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Mirantis Inc.
|
||||
# Copyright 2017 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
|
||||
@@ -14,13 +14,14 @@
|
||||
|
||||
from manila_ui import exceptions
|
||||
|
||||
PANEL_DASHBOARD = 'project'
|
||||
PANEL_GROUP = 'compute'
|
||||
PANEL = 'shares'
|
||||
ADD_PANEL = 'manila_ui.dashboards.project.shares.panel.Shares'
|
||||
|
||||
# ADD_INSTALLED_APPS enables using html templates from within the plugin
|
||||
ADD_INSTALLED_APPS = ['manila_ui.dashboards.project']
|
||||
# The slug of the panel group to be added to HORIZON_CONFIG. Required.
|
||||
PANEL_GROUP = 'share'
|
||||
# The display name of the PANEL_GROUP. Required.
|
||||
PANEL_GROUP_NAME = 'Share'
|
||||
# The slug of the dashboard the PANEL_GROUP associated with. Required.
|
||||
PANEL_GROUP_DASHBOARD = 'project'
|
||||
|
||||
|
||||
ADD_EXCEPTIONS = {
|
||||
'recoverable': exceptions.RECOVERABLE,
|
@@ -0,0 +1,18 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
PANEL_DASHBOARD = 'project'
|
||||
PANEL_GROUP = 'share'
|
||||
PANEL = 'shares'
|
||||
ADD_PANEL = 'manila_ui.dashboards.project.shares.panel.Shares'
|
@@ -0,0 +1,18 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
PANEL_DASHBOARD = 'project'
|
||||
PANEL_GROUP = 'share'
|
||||
PANEL = 'share_snapshots'
|
||||
ADD_PANEL = 'manila_ui.dashboards.project.share_snapshots.panel.ShareSnapshots'
|
@@ -0,0 +1,18 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
PANEL_DASHBOARD = 'project'
|
||||
PANEL_GROUP = 'share'
|
||||
PANEL = 'share_networks'
|
||||
ADD_PANEL = 'manila_ui.dashboards.project.share_networks.panel.ShareNetworks'
|
@@ -0,0 +1,19 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
PANEL_DASHBOARD = 'project'
|
||||
PANEL_GROUP = 'share'
|
||||
PANEL = 'security_services'
|
||||
ADD_PANEL = (
|
||||
'manila_ui.dashboards.project.security_services.panel.SecurityServices')
|
@@ -20,7 +20,7 @@ from openstack_dashboard.api import keystone as api_keystone
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
from manila_ui.tests.test_data import keystone_data
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import mock
|
||||
from openstack_dashboard.api import keystone as api_keystone
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
|
||||
INDEX_URL = reverse('horizon:admin:share_instances:index')
|
||||
|
@@ -22,7 +22,7 @@ from openstack_dashboard.api import neutron as api_neutron
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
from manila_ui.tests.test_data import keystone_data
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import mock
|
||||
from openstack_dashboard.api import keystone as api_keystone
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
|
||||
INDEX_URL = reverse('horizon:admin:share_servers:index')
|
||||
|
@@ -20,7 +20,7 @@ from openstack_dashboard.api import keystone as api_keystone
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
from manila_ui.tests.test_data import keystone_data
|
||||
|
||||
|
@@ -20,7 +20,7 @@ from openstack_dashboard.api import neutron as api_neutron
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
from manila_ui.tests.test_data import keystone_data
|
||||
|
||||
|
@@ -18,7 +18,7 @@ from django.core.urlresolvers import reverse
|
||||
import mock
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
|
||||
from openstack_dashboard.api import neutron
|
||||
|
@@ -22,7 +22,7 @@ from openstack_dashboard.usage import quotas
|
||||
|
||||
from manila_ui.api import manila as api_manila
|
||||
from manila_ui.dashboards.admin import utils
|
||||
from manila_ui.tests.dashboards.project.shares import test_data
|
||||
from manila_ui.tests.dashboards.project import test_data
|
||||
from manila_ui.tests import helpers as test
|
||||
from manila_ui.tests.test_data import keystone_data
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user