create keypair crashes on access limited

Bug #1262494 reported by Yu Qiang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Expired
Medium
Unassigned

Bug Description

When I set the rule in /etc/nova/policy.json.
    "compute_extension:keypairs": "",
    "compute_extension:keypairs:index": "",
    "compute_extension:keypairs:show": "",
    "compute_extension:keypairs:create": "rule:admin_api",
    "compute_extension:keypairs:delete": "rule:admin_api",
    "compute_extension:v3:keypairs:discoverable": "",
    "compute_extension:v3:keypairs": "",
    "compute_extension:v3:keypairs:index": "",
    "compute_extension:v3:keypairs:show": "",
    "compute_extension:v3:keypairs:create": "rule:admin_api",
    "compute_extension:v3:keypairs:delete": "rule:admin_api",
---------------------------------------------------------------------------------------------------
then login as a member of a project, not admin role, I want to create a keypair in Access & Security Panel of Dashboard.
After input a name of keypair, click button of create keypair, a error page occur , error information is about the /usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py , line 78.

I know a little about python but no Django, so I write some statements to prevent this error.
Hope you will correct this bug.

Revision history for this message
Yu Qiang (yq) wrote :
information type: Private Security → Public
description: updated
Revision history for this message
Victoria Martinez de la Cruz (vkmc) wrote :

Could reproduce.

Traceback,

Environment:

Request Method: GET
Request URL: http://localhost/project/access_and_security/keypairs/keypair1/generate/

Django Version: 1.5.5
Python Version: 2.7.3
Installed Applications:
['openstack_dashboard',
 'django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'compressor',
 'horizon',
 'openstack_dashboard.dashboards.project',
 'openstack_dashboard.dashboards.admin',
 'openstack_dashboard.dashboards.settings',
 'openstack_auth',
 'openstack_dashboard.dashboards.router',
 'openstack_dashboard.dashboards.project',
 'openstack_dashboard.dashboards.admin',
 'openstack_dashboard.dashboards.settings']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'horizon.middleware.HorizonMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115. response = callback(request, *callback_args, **callback_kwargs)
File "/opt/stack/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  38. return view_func(request, *args, **kwargs)
File "/opt/stack/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  54. return view_func(request, *args, **kwargs)
File "/opt/stack/horizon/openstack_dashboard/wsgi/../../horizon/decorators.py" in dec
  38. return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
  68. return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
  86. return handler(request, *args, **kwargs)
File "/opt/stack/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py" in get
  78. 'attachment; filename=%s.pem' % slugify(keypair.name)

Exception Type: UnboundLocalError at /project/access_and_security/keypairs/keypair1/generate/
Exception Value: local variable 'keypair' referenced before assignment

Changed in horizon:
status: New → Confirmed
Revision history for this message
Victoria Martinez de la Cruz (vkmc) wrote :

The patch provided works great, thanks!

Changed in horizon:
importance: Undecided → Medium
Changed in horizon:
assignee: nobody → Jeremy Moffitt (jeremy-moffitt)
Revision history for this message
Jeremy Moffitt (jeremy-moffitt) wrote :

I'm having trouble reproducing this problem. It works fine for me both with and without the patch. I'll keep at it and see if I can make it break without the patch.

Revision history for this message
Jeremy Moffitt (jeremy-moffitt) wrote :

Attached screenshot is the current behavior with or without the exception catch changes

Changed in horizon:
assignee: Jeremy Moffitt (jeremy-moffitt) → nobody
David Lyle (david-lyle)
Changed in horizon:
status: Confirmed → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenStack Dashboard (Horizon) because there has been no activity for 60 days.]

Changed in horizon:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.