From b562358c8e427dccda650070d2c1d980b5734d22 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Fri, 8 Jul 2011 22:59:24 -0700 Subject: [PATCH 01/12] quotas update form mostly working --- .../django_openstack/syspanel/urls.py | 3 +- .../syspanel/views/tenants.py | 62 +++++++++++++++++++ .../syspanel/_update_quotas_form.html | 6 ++ .../dashboard/templates/_quotas_form.html | 12 ++++ .../templates/_syspanel_tenant_list.html | 1 + .../templates/syspanel_tenant_quotas.html | 33 ++++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 django-openstack/django_openstack/templates/django_openstack/syspanel/_update_quotas_form.html create mode 100644 openstack-dashboard/dashboard/templates/_quotas_form.html create mode 100644 openstack-dashboard/dashboard/templates/syspanel_tenant_quotas.html diff --git a/django-openstack/django_openstack/syspanel/urls.py b/django-openstack/django_openstack/syspanel/urls.py index 887255439..924d22ab1 100644 --- a/django-openstack/django_openstack/syspanel/urls.py +++ b/django-openstack/django_openstack/syspanel/urls.py @@ -45,7 +45,8 @@ urlpatterns += patterns('django_openstack.syspanel.views.services', urlpatterns += patterns('django_openstack.syspanel.views.tenants', url(r'^tenants/$', 'index', name='syspanel_tenants'), + url(r'^tenants/create$', 'create', name='syspanel_tenants_create'), url(TENANTS % 'update', 'update', name='syspanel_tenant_update'), url(TENANTS % 'users', 'users', name='syspanel_tenant_users'), - url(r'^tenants/create$', 'create', name='syspanel_tenants_create'), + url(TENANTS % 'quotas', 'quotas', name='syspanel_tenant_quotas'), ) diff --git a/django-openstack/django_openstack/syspanel/views/tenants.py b/django-openstack/django_openstack/syspanel/views/tenants.py index 10bed2fab..69b985d75 100644 --- a/django-openstack/django_openstack/syspanel/views/tenants.py +++ b/django-openstack/django_openstack/syspanel/views/tenants.py @@ -92,6 +92,39 @@ class UpdateTenant(forms.SelfHandlingForm): messages.error(request, 'Unable to update tenant: %s' % e.message) return redirect('syspanel_tenants') +class UpdateQuotas(forms.SelfHandlingForm): + tenant_id = forms.CharField(label="ID (name)", widget=forms.TextInput(attrs={'readonly':'readonly'})) + metadata_items = forms.CharField(label="Metadata Items") + injected_files = forms.CharField(label="Injected Files") + injected_file_content_bytes = forms.CharField(label="Injected File Content Bytes") + cores = forms.CharField(label="VCPUs") + instances = forms.CharField(label="Instances") + volumes = forms.CharField(label="Volumes") + gigabytes = forms.CharField(label="Gigabytes") + ram = forms.CharField(label="RAM (in MB)") + floating_ips = forms.CharField(label="Floating IPs") + + def handle(self, request, data): + try: + api.admin_api(request).quotas.update(request, + tenantId=data['tenant_id'], + metadata_items=data['metadata_items'], + injected_file_content_bytes= + data['injected_file_content_bytes'], + volumes=data['volumes'], + gigabytes=data['gigabytes'], + ram=int(data['ram']) * 100, + floating_ips=data['floating_ips'], + instances=data['instances'], + injected_files=data['injected_files'], + cores=data['cores'], + ) + messages.success(request, + 'Quotas for %s were successfully updated.' + % data['tenant_id']) + except api_exceptions.ApiException, e: + messages.error(request, 'Unable to update quotas: %s' % e.message) + return redirect('syspanel_tenants') @login_required def index(request): @@ -161,3 +194,32 @@ def users(request, tenant_id): 'tenant_id': tenant_id, 'users': users, }, context_instance = template.RequestContext(request)) + +@login_required +def quotas(request, tenant_id): + for f in (UpdateQuotas,): + _, handled = f.maybe_handle(request) + if handled: + return handled + + quotas = api.admin_api(request).quotas.get(tenant_id) + quota_set = { + 'tenant_id': quotas.tenantId, + 'metadata_items': quotas.metadata_items, + 'injected_file_content_bytes': quotas.injected_file_content_bytes, + 'volumes': quotas.volumes, + 'gigabytes': quotas.gigabytes, + 'ram': int(quotas.ram) / 100, + 'floating_ips': quotas.floating_ips, + 'instances': quotas.instances, + 'injected_files': quotas.injected_files, + 'cores': quotas.cores, + } + form = UpdateQuotas(initial=quota_set) + + return render_to_response( + 'syspanel_tenant_quotas.html',{ + 'form': form, + 'tenant_id': tenant_id, + 'quotas': quotas, + }, context_instance = template.RequestContext(request)) diff --git a/django-openstack/django_openstack/templates/django_openstack/syspanel/_update_quotas_form.html b/django-openstack/django_openstack/templates/django_openstack/syspanel/_update_quotas_form.html new file mode 100644 index 000000000..9ed551ddf --- /dev/null +++ b/django-openstack/django_openstack/templates/django_openstack/syspanel/_update_quotas_form.html @@ -0,0 +1,6 @@ +{% extends "_quotas_form.html" %} + +{% block submit %} + +{% endblock %} + diff --git a/openstack-dashboard/dashboard/templates/_quotas_form.html b/openstack-dashboard/dashboard/templates/_quotas_form.html new file mode 100644 index 000000000..a2168618c --- /dev/null +++ b/openstack-dashboard/dashboard/templates/_quotas_form.html @@ -0,0 +1,12 @@ +
+ {% csrf_token %} + {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} + {% for field in form.visible_fields %} + {{ field.label_tag }} + {{ field.errors }} + {{ field }} + {% endfor %} + {% block submit %} + {% endblock %} +
+ diff --git a/openstack-dashboard/dashboard/templates/_syspanel_tenant_list.html b/openstack-dashboard/dashboard/templates/_syspanel_tenant_list.html index e9694e0fc..fcb7f8edf 100644 --- a/openstack-dashboard/dashboard/templates/_syspanel_tenant_list.html +++ b/openstack-dashboard/dashboard/templates/_syspanel_tenant_list.html @@ -15,6 +15,7 @@
  • {% include "_tenant_delete.html" with form=tenant_delete_form %}
  • Edit
  • View Members
  • +
  • Modify Quotas
  • diff --git a/openstack-dashboard/dashboard/templates/syspanel_tenant_quotas.html b/openstack-dashboard/dashboard/templates/syspanel_tenant_quotas.html new file mode 100644 index 000000000..321aaf368 --- /dev/null +++ b/openstack-dashboard/dashboard/templates/syspanel_tenant_quotas.html @@ -0,0 +1,33 @@ +{% extends 'syspanel_base.html' %} +{# list of tenants #} +{# standard nav, sidebar, list of instances in main #} + +{% block sidebar %} + {% with current_sidebar="tenants" %} + {{block.super}} + {% endwith %} +{% endblock %} + +{% block main %} + + {% include "_messages.html" %} + +
    +
    +
    +

    Update Tenant Quotas

    +
    + {% include 'django_openstack/syspanel/_update_quotas_form.html' with form=form %} + +
    +

    Description:

    +

    From here you can edit quotas (max limits) for the tenant {{tenant_id}}.

    +
    +
    +
    +{% endblock %} + + From 2cffb6bf3d718a73f30887659ea7ff24475c42f1 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Fri, 8 Jul 2011 23:32:22 -0700 Subject: [PATCH 02/12] attempting to get quota info on image launch page for user --- django-openstack/django_openstack/api.py | 2 ++ django-openstack/django_openstack/dash/views/images.py | 3 ++- .../dashboard/templates/dash_launch.html | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/django-openstack/django_openstack/api.py b/django-openstack/django_openstack/api.py index 5e336ccfb..fd6bb503f 100644 --- a/django-openstack/django_openstack/api.py +++ b/django-openstack/django_openstack/api.py @@ -185,6 +185,8 @@ def tenant_update(request, tenant_id, description, enabled): def token_create(request, tenant, username, password): return auth_api().tokens.create(tenant, username, password) +def tenant_quota_get(request, tenant): + return admin_api(request).quotas.get(tenant) def token_info(request, token): hdrs = {"Content-type": "application/json", diff --git a/django-openstack/django_openstack/dash/views/images.py b/django-openstack/django_openstack/dash/views/images.py index 7dda9e539..ee0534ce7 100644 --- a/django-openstack/django_openstack/dash/views/images.py +++ b/django-openstack/django_openstack/dash/views/images.py @@ -168,7 +168,7 @@ def launch(request, tenant_id, image_id): image = api.image_get(request, image_id) tenant = api.token_get_tenant(request, request.user.tenant) - + quotas = api.tenant_quota_get(request, request.user.tenant) form, handled = LaunchForm.maybe_handle( request, initial={'flavorlist': flavorlist(), 'keynamelist': keynamelist(), @@ -181,4 +181,5 @@ def launch(request, tenant_id, image_id): 'tenant': tenant, 'image': image, 'form': form, + 'quotas': quotas, }, context_instance=template.RequestContext(request)) diff --git a/openstack-dashboard/dashboard/templates/dash_launch.html b/openstack-dashboard/dashboard/templates/dash_launch.html index 73eb28b63..27ad60a9b 100644 --- a/openstack-dashboard/dashboard/templates/dash_launch.html +++ b/openstack-dashboard/dashboard/templates/dash_launch.html @@ -28,7 +28,15 @@

    Description:

    Specify the details for launching an instance.

    -
    + + {% for qutoa in quotas %} + + + + + {% endfor %} +
    {{quota.0}}{{quota.1}}
    + {% endblock %} From c81089eaa3100afb0c4a6eead0bf4b9c414ebd19 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Sat, 9 Jul 2011 00:26:31 -0700 Subject: [PATCH 03/12] adding relevant quota information to the image launch page --- .../django_openstack/dash/views/images.py | 1 + .../dashboard/templates/dash_launch.html | 35 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/django-openstack/django_openstack/dash/views/images.py b/django-openstack/django_openstack/dash/views/images.py index ee0534ce7..ade3739b8 100644 --- a/django-openstack/django_openstack/dash/views/images.py +++ b/django-openstack/django_openstack/dash/views/images.py @@ -169,6 +169,7 @@ def launch(request, tenant_id, image_id): image = api.image_get(request, image_id) tenant = api.token_get_tenant(request, request.user.tenant) quotas = api.tenant_quota_get(request, request.user.tenant) + quotas.ram = int(quotas.ram)/100 form, handled = LaunchForm.maybe_handle( request, initial={'flavorlist': flavorlist(), 'keynamelist': keynamelist(), diff --git a/openstack-dashboard/dashboard/templates/dash_launch.html b/openstack-dashboard/dashboard/templates/dash_launch.html index 27ad60a9b..8427dd74a 100644 --- a/openstack-dashboard/dashboard/templates/dash_launch.html +++ b/openstack-dashboard/dashboard/templates/dash_launch.html @@ -24,17 +24,34 @@ {% include '_launch.html' %} -

    Description:

    -

    Specify the details for launching an instance.

    - - {% for qutoa in quotas %} - - - - - {% endfor %} +

    Specify the details for launching an instance. Also please make note of the table below; all tenants have quotas which define the limit of resources you are allowed to provision.

    +
    {{quota.0}}{{quota.1}}
    + + + + + + + + + + + + + + + + + + + + + + + +
    Quota NameLimit
    RAM (MB){{quotas.ram}}MB
    Floating IPs{{quotas.floating_ips}}
    Instances{{quotas.instances}}
    Volumes{{quotas.volumes}}
    Gigabytes{{quotas.gigabytes}}GB
    From fae654dfeb6c7fc1d8d9844e18694afb745ed227 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Sat, 9 Jul 2011 00:58:35 -0700 Subject: [PATCH 04/12] adding auto refresh for dashboard instances --- .../django_openstack/dash/urls.py | 1 + .../django_openstack/dash/views/instances.py | 27 +++++++++++++++++++ .../dashboard/templates/dash_instances.html | 26 ++++++++++++++++++ .../media/dashboard/css/style.css | 8 ++++++ 4 files changed, 62 insertions(+) diff --git a/django-openstack/django_openstack/dash/urls.py b/django-openstack/django_openstack/dash/urls.py index e9bc62cfd..003c08137 100644 --- a/django-openstack/django_openstack/dash/urls.py +++ b/django-openstack/django_openstack/dash/urls.py @@ -10,6 +10,7 @@ KEYPAIRS = r'^(?P[^/]+)/keypairs/%s$' urlpatterns = patterns('django_openstack.dash.views.instances', url(r'^(?P[^/]+)/$', 'usage', name='dash_usage'), url(r'^(?P[^/]+)/instances/$', 'index', name='dash_instances'), + url(r'^(?P[^/]+)/instances/refresh$', 'refresh', name='dash_instances_refresh'), url(INSTANCES % 'console', 'console', name='dash_instances_console'), url(INSTANCES % 'vnc', 'vnc', name='dash_instances_vnc'), ) diff --git a/django-openstack/django_openstack/dash/views/instances.py b/django-openstack/django_openstack/dash/views/instances.py index c214c5597..bd1163b52 100644 --- a/django-openstack/django_openstack/dash/views/instances.py +++ b/django-openstack/django_openstack/dash/views/instances.py @@ -102,7 +102,34 @@ def index(request, tenant_id): 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request)) +@login_required +def refresh(request, tenant_id): + for f in (TerminateInstance, RebootInstance): + _, handled = f.maybe_handle(request) + if handled: + return handled + instances = [] + try: + image_dict = api.image_all_metadata(request) + instances = api.server_list(request) + for instance in instances: + # FIXME - ported this over, but it is hacky + instance.attrs['image_name'] =\ + image_dict.get(int(instance.attrs['image_ref']),{}).get('name') + except Exception as e: + messages.error(request, 'Unable to get instance list: %s' % e.message) + # We don't have any way of showing errors for these, so don't bother + # trying to reuse the forms from above + terminate_form = TerminateInstance() + reboot_form = RebootInstance() + + return render_to_response('_instance_list.html', { + 'instances': instances, + 'terminate_form': terminate_form, + 'reboot_form': reboot_form, + }, context_instance=template.RequestContext(request)) + @login_required def usage(request, tenant_id=None): today = datetime.date.today() diff --git a/openstack-dashboard/dashboard/templates/dash_instances.html b/openstack-dashboard/dashboard/templates/dash_instances.html index d9c64d18a..042f0686f 100644 --- a/openstack-dashboard/dashboard/templates/dash_instances.html +++ b/openstack-dashboard/dashboard/templates/dash_instances.html @@ -12,6 +12,7 @@ {% include "_messages.html" %} @@ -41,3 +42,28 @@ {% endblock %} + + +{% block footer_js %} + +{% endblock footer_js %} \ No newline at end of file diff --git a/openstack-dashboard/media/dashboard/css/style.css b/openstack-dashboard/media/dashboard/css/style.css index d82d90fde..00ee07273 100644 --- a/openstack-dashboard/media/dashboard/css/style.css +++ b/openstack-dashboard/media/dashboard/css/style.css @@ -1692,3 +1692,11 @@ li.title h4{ margin-left: 25px; } +#spinner { + background: url(../images/spinner.gif) top left no-repeat; + float: right; + width: 24px; + height: 24px; + text-indent: -9999px; + margin-right: 19px; +} From 075c0771c27b58b4da4334abc58d09d9fb1dc762 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Sat, 9 Jul 2011 01:11:26 -0700 Subject: [PATCH 05/12] adding autorefresh to syspanel instance list and fixing spinner styles --- .../django_openstack/syspanel/urls.py | 1 + .../syspanel/views/instances.py | 29 +++++++++++++++++++ .../templates/_syspanel_instance_list.html | 2 +- .../dashboard/templates/dash_instances.html | 4 +-- .../templates/syspanel_instances.html | 23 +++++++++++++++ .../media/dashboard/css/style.css | 17 ++++++++++- 6 files changed, 71 insertions(+), 5 deletions(-) diff --git a/django-openstack/django_openstack/syspanel/urls.py b/django-openstack/django_openstack/syspanel/urls.py index 887255439..6eaf3fbdf 100644 --- a/django-openstack/django_openstack/syspanel/urls.py +++ b/django-openstack/django_openstack/syspanel/urls.py @@ -12,6 +12,7 @@ urlpatterns = patterns('django_openstack.syspanel.views.instances', url(r'^usage/(?P[^/]+)$', 'tenant_usage', name='syspanel_tenant_usage'), url(r'^instances/$', 'index', name='syspanel_instances'), + url(r'^instances/refresh$', 'refresh', name='syspanel_instances_refresh'), # NOTE(termie): currently just using the 'dash' versions #url(INSTANCES % 'console', 'console', name='syspanel_instances_console'), #url(INSTANCES % 'vnc', 'vnc', name='syspanel_instances_vnc'), diff --git a/django-openstack/django_openstack/syspanel/views/instances.py b/django-openstack/django_openstack/syspanel/views/instances.py index 1c72fbff2..3dd6d056f 100644 --- a/django-openstack/django_openstack/syspanel/views/instances.py +++ b/django-openstack/django_openstack/syspanel/views/instances.py @@ -196,3 +196,32 @@ def index(request): 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request)) + +@login_required +def refresh(request): + for f in (TerminateInstance, RebootInstance): + _, handled = f.maybe_handle(request) + if handled: + return handled + + instances = [] + try: + image_dict = api.image_all_metadata(request) + instances = api.server_list(request) + for instance in instances: + # FIXME - ported this over, but it is hacky + instance._info['attrs']['image_name'] =\ + image_dict.get(int(instance.attrs['image_ref']),{}).get('name') + except Exception as e: + messages.error(request, 'Unable to get instance list: %s' % e.message) + + # We don't have any way of showing errors for these, so don't bother + # trying to reuse the forms from above + terminate_form = TerminateInstance() + reboot_form = RebootInstance() + + return render_to_response('_syspanel_instance_list.html', { + 'instances': instances, + 'terminate_form': terminate_form, + 'reboot_form': reboot_form, + }, context_instance=template.RequestContext(request)) diff --git a/openstack-dashboard/dashboard/templates/_syspanel_instance_list.html b/openstack-dashboard/dashboard/templates/_syspanel_instance_list.html index 71a995d63..faf7a24d4 100644 --- a/openstack-dashboard/dashboard/templates/_syspanel_instance_list.html +++ b/openstack-dashboard/dashboard/templates/_syspanel_instance_list.html @@ -1,5 +1,5 @@ {% load parse_date %} - +
    diff --git a/openstack-dashboard/dashboard/templates/dash_instances.html b/openstack-dashboard/dashboard/templates/dash_instances.html index 042f0686f..522f8b35a 100644 --- a/openstack-dashboard/dashboard/templates/dash_instances.html +++ b/openstack-dashboard/dashboard/templates/dash_instances.html @@ -12,7 +12,7 @@ {% include "_messages.html" %} @@ -62,8 +62,6 @@ e.preventDefault() loadInstances(); }) - }) - {% endblock footer_js %} \ No newline at end of file diff --git a/openstack-dashboard/dashboard/templates/syspanel_instances.html b/openstack-dashboard/dashboard/templates/syspanel_instances.html index 9ad55d52e..4cca836e8 100644 --- a/openstack-dashboard/dashboard/templates/syspanel_instances.html +++ b/openstack-dashboard/dashboard/templates/syspanel_instances.html @@ -12,6 +12,7 @@ {% include "_messages.html" %} @@ -43,3 +44,25 @@ {% endif %} {% endblock %} + +{% block footer_js %} + +{% endblock footer_js %} \ No newline at end of file diff --git a/openstack-dashboard/media/dashboard/css/style.css b/openstack-dashboard/media/dashboard/css/style.css index 00ee07273..77ba5e9d5 100644 --- a/openstack-dashboard/media/dashboard/css/style.css +++ b/openstack-dashboard/media/dashboard/css/style.css @@ -1698,5 +1698,20 @@ li.title h4{ width: 24px; height: 24px; text-indent: -9999px; - margin-right: 19px; +} + +#spinner.dash { + position: relative; + right: 10px; + bottom: 0; + margin-bottom: -24px; + top: -10px; +} + +#spinner.syspanel { + position: relative; + right: 20px; + top: -24px; + bottom: 0; + margin-bottom: -24px; } From eec4ae6a9c61375a18f3a0edf8dc53bfe530a696 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 10:18:39 -0700 Subject: [PATCH 06/12] tenant_id now pulls from quotas.id --- django-openstack/django_openstack/syspanel/views/tenants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-openstack/django_openstack/syspanel/views/tenants.py b/django-openstack/django_openstack/syspanel/views/tenants.py index 69b985d75..67faf43fb 100644 --- a/django-openstack/django_openstack/syspanel/views/tenants.py +++ b/django-openstack/django_openstack/syspanel/views/tenants.py @@ -204,7 +204,7 @@ def quotas(request, tenant_id): quotas = api.admin_api(request).quotas.get(tenant_id) quota_set = { - 'tenant_id': quotas.tenantId, + 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, 'injected_file_content_bytes': quotas.injected_file_content_bytes, 'volumes': quotas.volumes, From ab5ebab7991cc599b395962080c2f32a136166f9 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 13:01:32 -0700 Subject: [PATCH 07/12] modifying quotas now works --- django-openstack/django_openstack/syspanel/views/tenants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django-openstack/django_openstack/syspanel/views/tenants.py b/django-openstack/django_openstack/syspanel/views/tenants.py index 67faf43fb..e9673521f 100644 --- a/django-openstack/django_openstack/syspanel/views/tenants.py +++ b/django-openstack/django_openstack/syspanel/views/tenants.py @@ -106,8 +106,8 @@ class UpdateQuotas(forms.SelfHandlingForm): def handle(self, request, data): try: - api.admin_api(request).quotas.update(request, - tenantId=data['tenant_id'], + messages.error(request, data['tenant_id']) + api.admin_api(request).quotas.update(data['tenant_id'], metadata_items=data['metadata_items'], injected_file_content_bytes= data['injected_file_content_bytes'], From 5286068017518ab17d28935a313332454f7e92c4 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 13:15:30 -0700 Subject: [PATCH 08/12] removing debug message --- django-openstack/django_openstack/syspanel/views/tenants.py | 1 - 1 file changed, 1 deletion(-) diff --git a/django-openstack/django_openstack/syspanel/views/tenants.py b/django-openstack/django_openstack/syspanel/views/tenants.py index e9673521f..35b25dca5 100644 --- a/django-openstack/django_openstack/syspanel/views/tenants.py +++ b/django-openstack/django_openstack/syspanel/views/tenants.py @@ -106,7 +106,6 @@ class UpdateQuotas(forms.SelfHandlingForm): def handle(self, request, data): try: - messages.error(request, data['tenant_id']) api.admin_api(request).quotas.update(data['tenant_id'], metadata_items=data['metadata_items'], injected_file_content_bytes= From 4643f9bbc5af94ecb60b2af9610a9b020ef9455c Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 13:55:23 -0700 Subject: [PATCH 09/12] renaming method endpoint for quotas --- django-openstack/django_openstack/api.py | 2 +- django-openstack/django_openstack/syspanel/views/tenants.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django-openstack/django_openstack/api.py b/django-openstack/django_openstack/api.py index fd6bb503f..503eeb9e3 100644 --- a/django-openstack/django_openstack/api.py +++ b/django-openstack/django_openstack/api.py @@ -186,7 +186,7 @@ def token_create(request, tenant, username, password): return auth_api().tokens.create(tenant, username, password) def tenant_quota_get(request, tenant): - return admin_api(request).quotas.get(tenant) + return admin_api(request).quota_sets.get(tenant) def token_info(request, token): hdrs = {"Content-type": "application/json", diff --git a/django-openstack/django_openstack/syspanel/views/tenants.py b/django-openstack/django_openstack/syspanel/views/tenants.py index 35b25dca5..e23b87f72 100644 --- a/django-openstack/django_openstack/syspanel/views/tenants.py +++ b/django-openstack/django_openstack/syspanel/views/tenants.py @@ -106,7 +106,7 @@ class UpdateQuotas(forms.SelfHandlingForm): def handle(self, request, data): try: - api.admin_api(request).quotas.update(data['tenant_id'], + api.admin_api(request).quota_sets.update(data['tenant_id'], metadata_items=data['metadata_items'], injected_file_content_bytes= data['injected_file_content_bytes'], @@ -201,7 +201,7 @@ def quotas(request, tenant_id): if handled: return handled - quotas = api.admin_api(request).quotas.get(tenant_id) + quotas = api.admin_api(request).quota_sets.get(tenant_id) quota_set = { 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, From a82c99bbf5afcbac98ba33dbd8a89a92d4bfd430 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 16:16:07 -0700 Subject: [PATCH 10/12] 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 + +
    + +
    Id User
    + + + + + {% for name,value in quotas.items %} + + + + + {% endfor %} + +
    Quota NameLimit
    {{name}}{{value}}
    + + Create New Tenant + +{% endblock %} + From 94a3d9d549394bb1bd2204eeda1a870a7971489d Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 16:16:43 -0700 Subject: [PATCH 11/12] killing debug message --- django-openstack/django_openstack/syspanel/views/quotas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-openstack/django_openstack/syspanel/views/quotas.py b/django-openstack/django_openstack/syspanel/views/quotas.py index 2b4597e88..26ec261aa 100644 --- a/django-openstack/django_openstack/syspanel/views/quotas.py +++ b/django-openstack/django_openstack/syspanel/views/quotas.py @@ -21,7 +21,7 @@ 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)) From e2c07377e204ed587fc2f558e82f10a4e8b97305 Mon Sep 17 00:00:00 2001 From: Jake Dahn Date: Mon, 11 Jul 2011 16:19:52 -0700 Subject: [PATCH 12/12] changing refresh link --- openstack-dashboard/dashboard/templates/syspanel_quotas.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstack-dashboard/dashboard/templates/syspanel_quotas.html b/openstack-dashboard/dashboard/templates/syspanel_quotas.html index b7b43ea11..a4f5b04f5 100644 --- a/openstack-dashboard/dashboard/templates/syspanel_quotas.html +++ b/openstack-dashboard/dashboard/templates/syspanel_quotas.html @@ -17,7 +17,7 @@

    Default Quotas

    - Refresh List + Refresh List