From a82c99bbf5afcbac98ba33dbd8a89a92d4bfd430 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 16:16:07 -0700 Subject: [PATCH] added quotas to syspanel --- .../django_openstack/syspanel/urls.py | 4 ++ .../django_openstack/syspanel/views/quotas.py | 28 +++++++++++ .../templates/_syspanel_sidebar.html | 1 + .../dashboard/templates/syspanel_quotas.html | 48 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 django-openstack/django_openstack/syspanel/views/quotas.py create mode 100644 openstack-dashboard/dashboard/templates/syspanel_quotas.html diff --git a/django-openstack/django_openstack/syspanel/urls.py b/django-openstack/django_openstack/syspanel/urls.py index b0102343b..c4db03270 100644 --- a/django-openstack/django_openstack/syspanel/urls.py +++ b/django-openstack/django_openstack/syspanel/urls.py @@ -26,6 +26,10 @@ urlpatterns += patterns('django_openstack.syspanel.views.images', ) +urlpatterns += patterns('django_openstack.syspanel.views.quotas', + url(r'^quotas/$', 'index', name='syspanel_quotas'), +) + urlpatterns += patterns('django_openstack.syspanel.views.flavors', url(r'^flavors/$', 'index', name='syspanel_flavors'), url(r'^flavors/create/$', 'create', name='syspanel_flavors_create'), diff --git a/django-openstack/django_openstack/syspanel/views/quotas.py b/django-openstack/django_openstack/syspanel/views/quotas.py new file mode 100644 index 000000000..2b4597e88 --- /dev/null +++ b/django-openstack/django_openstack/syspanel/views/quotas.py @@ -0,0 +1,28 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +from operator import itemgetter + +from django import template +from django import http +from django.conf import settings +from django.contrib import messages +from django.contrib.auth.decorators import login_required +from django.shortcuts import redirect +from django.shortcuts import render_to_response +from openstackx.api import exceptions as api_exceptions + + +from django_openstack import api +from django_openstack import forms + + +@login_required +def index(request): + quotas = api.admin_api(request).quota_sets.get(True)._info + quotas['ram'] = int(quotas['ram']) / 100 + quotas.pop('id') + messages.success(request, quotas) + return render_to_response('syspanel_quotas.html',{ + 'quotas': quotas, + }, context_instance = template.RequestContext(request)) + diff --git a/openstack-dashboard/dashboard/templates/_syspanel_sidebar.html b/openstack-dashboard/dashboard/templates/_syspanel_sidebar.html index 884169e89..45883f786 100644 --- a/openstack-dashboard/dashboard/templates/_syspanel_sidebar.html +++ b/openstack-dashboard/dashboard/templates/_syspanel_sidebar.html @@ -8,5 +8,6 @@
  • Images
  • Tenants
  • Users
  • +
  • Quotas
  • diff --git a/openstack-dashboard/dashboard/templates/syspanel_quotas.html b/openstack-dashboard/dashboard/templates/syspanel_quotas.html new file mode 100644 index 000000000..b7b43ea11 --- /dev/null +++ b/openstack-dashboard/dashboard/templates/syspanel_quotas.html @@ -0,0 +1,48 @@ +{% extends 'syspanel_base.html' %} +{# list of tenants #} +{# standard nav, sidebar, list of instances in main #} + +{% block sidebar %} + {% with current_sidebar="quotas" %} + {{block.super}} + {% endwith %} +{% endblock %} + +{% block main %} + + {% include "_messages.html" %} +
    +
    +

    Default Quotas

    + Refresh List + +
    + + + + + + + {% for name,value in quotas.items %} + + + + + {% endfor %} + +
    Quota NameLimit
    {{name}}{{value}}
    + + Create New Tenant +
    +{% endblock %} +