diff options
Diffstat (limited to 'openstack_dashboard/dashboards/admin/info/tables.py')
-rw-r--r-- | openstack_dashboard/dashboards/admin/info/tables.py | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/openstack_dashboard/dashboards/admin/info/tables.py b/openstack_dashboard/dashboards/admin/info/tables.py deleted file mode 100644 index 56a3cabb..00000000 --- a/openstack_dashboard/dashboards/admin/info/tables.py +++ /dev/null @@ -1,121 +0,0 @@ -import logging - -from django import template -from django.template.defaultfilters import timesince -from django.utils.translation import ugettext_lazy as _ - -from horizon import tables -from horizon.utils.filters import parse_isotime - - -LOG = logging.getLogger(__name__) - - -class QuotaFilterAction(tables.FilterAction): - def filter(self, table, tenants, filter_string): - q = filter_string.lower() - - def comp(tenant): - if q in tenant.name.lower(): - return True - return False - - return filter(comp, tenants) - - -def get_quota_name(quota): - if quota.name == "cores": - return _('VCPUs') - if quota.name == "floating_ips": - return _('Floating IPs') - return quota.name.replace("_", " ").title() - - -class QuotasTable(tables.DataTable): - name = tables.Column(get_quota_name, verbose_name=_('Quota Name')) - limit = tables.Column("limit", verbose_name=_('Limit')) - - def get_object_id(self, obj): - return obj.name - - class Meta: - name = "quotas" - verbose_name = _("Quotas") - table_actions = (QuotaFilterAction,) - multi_select = False - - -class ServiceFilterAction(tables.FilterAction): - def filter(self, table, services, filter_string): - q = filter_string.lower() - - def comp(service): - if q in service.type.lower(): - return True - return False - - return filter(comp, services) - - -def get_stats(service): - return template.loader.render_to_string('admin/services/_stats.html', - {'service': service}) - - -def get_enabled(service, reverse=False): - options = ["Enabled", "Disabled"] - if reverse: - options.reverse() - # if not configured in this region, neither option makes sense - if service.host: - return options[0] if not service.disabled else options[1] - return None - - -class ServicesTable(tables.DataTable): - id = tables.Column('id', verbose_name=_('Id'), hidden=True) - name = tables.Column("name", verbose_name=_('Name')) - service_type = tables.Column('__unicode__', verbose_name=_('Service')) - host = tables.Column('host', verbose_name=_('Host')) - enabled = tables.Column(get_enabled, - verbose_name=_('Enabled'), - status=True) - - class Meta: - name = "services" - verbose_name = _("Services") - table_actions = (ServiceFilterAction,) - multi_select = False - status_columns = ["enabled"] - - -class NovaServiceFilterAction(tables.FilterAction): - def filter(self, table, services, filter_string): - q = filter_string.lower() - - def comp(service): - if q in service.type.lower(): - return True - return False - - return filter(comp, services) - - -class NovaServicesTable(tables.DataTable): - binary = tables.Column("binary", verbose_name=_('Name')) - host = tables.Column('host', verbose_name=_('Host')) - zone = tables.Column('zone', verbose_name=_('Zone')) - status = tables.Column('status', verbose_name=_('Status')) - state = tables.Column('state', verbose_name=_('State')) - updated_at = tables.Column('updated_at', - verbose_name=_('Updated At'), - filters=(parse_isotime, timesince)) - - def get_object_id(self, obj): - return "%s-%s-%s" % (obj.binary, obj.host, obj.zone) - - class Meta: - name = "nova_services" - verbose_name = _("Compute Services") - table_actions = (NovaServiceFilterAction,) - multi_select = False |