~ubuntu-branches/ubuntu/precise/horizon/precise-updates

« back to all changes in this revision

Viewing changes to horizon/horizon/dashboards/nova/access_and_security/keypairs/forms.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-02-24 10:49:27 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120224104927-0v71grkyxtu106l4
Tags: 2012.1~e4~20120224.1386-0ubuntu1
New upstream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import logging
22
22
 
23
 
from django import http
24
23
from django import shortcuts
25
24
from django.contrib import messages
26
25
from django.core import validators
27
 
from django.template.defaultfilters import slugify
28
26
from django.utils.translation import ugettext as _
29
27
from novaclient import exceptions as novaclient_exceptions
30
28
 
45
43
 
46
44
    def handle(self, request, data):
47
45
        try:
48
 
            LOG.info('Creating keypair "%s"' % data['name'])
49
 
            keypair = api.keypair_create(request, data['name'])
50
 
            response = http.HttpResponse(mimetype='application/binary')
51
 
            response['Content-Disposition'] = \
52
 
                     'attachment; filename=%s.pem' % slugify(keypair.name)
53
 
            response.write(keypair.private_key)
54
 
            response['Content-Length'] = str(len(response.content))
55
 
            return response
 
46
            return shortcuts.redirect(
 
47
                    'horizon:nova:access_and_security:keypairs:download',
 
48
                    keypair_name=data['name'])
56
49
        except novaclient_exceptions.ClientException, e:
57
50
            LOG.exception("ClientException in CreateKeyPair")
58
51
            messages.error(request,