
The previous manila-ui approach to show shared-file-system default quotas is too hacky and fragile as the bug reveals. This commit applies EXTRA_TABS/EXTRA_STEPS plugin interface introduced to horizon in Rocky to show the manila quota tab in the default quotas table and quota related forms. monkey-patching from manila quotas has been dropped. Note that EXTRA_STEPS feature is being reviewd in horizon https://review.openstack.org/#/c/560679/ so workflow steps related to manila in the project quota form and the default quota form are not shown until the corresponding horizon feature is merged. However, this commit will unblock manila-ui CI so I believe this is a good compromise. Note that manila support in the project overview panel is dropped temporarily as further refactoring in the project overview panel is being done in horizon side (which will land in Rocky-2). Closes-Bug: #1759340 Co-Authored-By: Victoria Martinez de la Cruz <victoria@redhat.com> Change-Id: I22ed7d757c5e5e902f1e85a15c33b34de6c609f1
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
# 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 openstack_dashboard.api import base
|
|
from openstack_dashboard.usage import base as usage
|
|
|
|
from manila_ui.api import manila
|
|
|
|
#
|
|
# Add extra pie charts to project/compute overview
|
|
#
|
|
|
|
|
|
class ManilaUsage(usage.ProjectUsage):
|
|
|
|
def get_manila_limits(self):
|
|
"""Get share limits if manila is enabled."""
|
|
if not base.is_service_enabled(self.request, 'share'):
|
|
return
|
|
try:
|
|
self.limits.update(manila.tenant_absolute_limits(self.request))
|
|
except Exception:
|
|
msg = _("Unable to retrieve share limit information.")
|
|
exceptions.handle(self.request, msg)
|
|
return
|
|
|
|
def get_limits(self):
|
|
super(self.__class__, self).get_limits()
|
|
self.get_manila_limits()
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super(self.__class__, self).get_context_data(**kwargs)
|
|
types = (
|
|
("totalSharesUsed", "maxTotalShares", _("Shares")),
|
|
("totalShareGigabytesUsed", "maxTotalShareGigabytes",
|
|
_("Share Storage")),
|
|
("totalShareSnapshotsUsed", "maxTotalShareSnapshots",
|
|
_("Share Snapshots")),
|
|
("totalSnapshotGigabytesUsed", "maxTotalSnapshotGigabytes",
|
|
_("Share Snapshots Storage")),
|
|
("totalShareNetworksUsed", "maxTotalShareNetworks",
|
|
_("Share Networks")),
|
|
)
|
|
for t in types:
|
|
if t[0] in self.usage.limits and t[1] in self.usage.limits:
|
|
context['charts'].append({
|
|
'type': t[0],
|
|
'name': t[2],
|
|
'used': self.usage.limits[t[0]],
|
|
'max': self.usage.limits[t[1]],
|
|
'text': False,
|
|
})
|
|
return context
|