コード例 #1
0
ファイル: tests.py プロジェクト: jakedahn/horizon
    def test_create_keypair_exception(self):
        keypair = self.keypairs.first()
        exc = novaclient_exceptions.ClientException('clientException')
        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest), keypair.name).AndRaise(exc)
        self.mox.ReplayAll()

        formData = {'method': 'CreateKeypair',
                    'name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:create')
        res = self.client.post(url, formData)

        self.assertRedirectsNoFollow(res, url)
コード例 #2
0
ファイル: tests.py プロジェクト: jakedahn/horizon
    def test_create_keypair_post(self):
        keypair = self.keypairs.first()
        keypair.private_key = "secret"

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           keypair.name).AndReturn(keypair)
        self.mox.ReplayAll()

        formData = {'method': 'CreateKeypair',
                    'name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:create')
        res = self.client.post(url, formData)
        self.assertTrue(res.has_header('Content-Disposition'))
コード例 #3
0
ファイル: tests.py プロジェクト: kumarcv/openstack-nf
    def test_generate_keypair_get(self):
        keypair = self.keypairs.first()
        keypair.private_key = "secret"

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           keypair.name).AndReturn(keypair)
        self.mox.ReplayAll()

        context = {'keypair_name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:generate',
                      kwargs={'keypair_name': keypair.name})
        res = self.client.get(url, context)

        self.assertTrue(res.has_header('content-disposition'))
コード例 #4
0
ファイル: tests.py プロジェクト: kumarcv/openstack-nf
    def test_generate_keypair_exception(self):
        keypair = self.keypairs.first()

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest), keypair.name) \
                        .AndRaise(self.exceptions.nova)
        self.mox.ReplayAll()

        context = {'keypair_name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:generate',
                      kwargs={'keypair_name': keypair.name})
        res = self.client.get(url, context)

        self.assertRedirectsNoFollow(
                res, reverse('horizon:nova:access_and_security:index'))
コード例 #5
0
ファイル: tests.py プロジェクト: zhang-hua/horizon
    def test_generate_keypair_get(self):
        keypair = self.keypairs.first()
        keypair.private_key = "secret"

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           keypair.name).AndReturn(keypair)
        self.mox.ReplayAll()

        context = {'keypair_name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:generate',
                      kwargs={'keypair_name': keypair.name})
        res = self.client.get(url, context)

        self.assertTrue(res.has_header('content-disposition'))
コード例 #6
0
ファイル: tests.py プロジェクト: zhang-hua/horizon
    def test_generate_keypair_exception(self):
        keypair = self.keypairs.first()

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest), keypair.name) \
                        .AndRaise(self.exceptions.nova)
        self.mox.ReplayAll()

        context = {'keypair_name': keypair.name}
        url = reverse('horizon:nova:access_and_security:keypairs:generate',
                      kwargs={'keypair_name': keypair.name})
        res = self.client.get(url, context)

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:access_and_security:index'))
コード例 #7
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_create_keypair_exception(self):
        KEYPAIR_NAME = 'newKeypair'

        formData = {'method': 'CreateKeypair',
                    'name': KEYPAIR_NAME,
                    }

        exception = novaclient_exceptions.ClientException('clientException',
                                                message='clientException')
        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           KEYPAIR_NAME).AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:keypairs:create'),
                               formData)

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:keypairs:create'))
コード例 #8
0
    def test_create_keypair_exception(self):
        KEYPAIR_NAME = 'newKeypair'

        formData = {'method': 'CreateKeypair',
                    'name': KEYPAIR_NAME,
                    }

        exception = novaclient_exceptions.ClientException('clientException',
                                                message='clientException')
        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           KEYPAIR_NAME).AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(
                   reverse('horizon:nova:access_and_security:keypairs:create'),
                           formData)

        self.assertRedirectsNoFollow(res,
                 reverse('horizon:nova:access_and_security:keypairs:create'))
コード例 #9
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_create_keypair_post(self):
        KEYPAIR_NAME = 'newKeypair'
        PRIVATE_KEY = 'privateKey'

        newKeyPair = self.mox.CreateMock(api.KeyPair)
        newKeyPair.name = KEYPAIR_NAME
        newKeyPair.private_key = PRIVATE_KEY

        formData = {'method': 'CreateKeypair',
                    'name': KEYPAIR_NAME,
                    }

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           KEYPAIR_NAME).AndReturn(newKeyPair)

        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:nova:keypairs:create'),
                               formData)

        self.assertTrue(res.has_header('Content-Disposition'))
コード例 #10
0
    def test_create_keypair_post(self):
        KEYPAIR_NAME = 'newKeypair'
        PRIVATE_KEY = 'privateKey'

        newKeyPair = self.mox.CreateMock(api.KeyPair)
        newKeyPair.name = KEYPAIR_NAME
        newKeyPair.private_key = PRIVATE_KEY

        formData = {'method': 'CreateKeypair',
                    'name': KEYPAIR_NAME,
                    }

        self.mox.StubOutWithMock(api, 'keypair_create')
        api.keypair_create(IsA(http.HttpRequest),
                           KEYPAIR_NAME).AndReturn(newKeyPair)

        self.mox.ReplayAll()

        res = self.client.post(
                   reverse('horizon:nova:access_and_security:keypairs:create'),
                           formData)

        self.assertTrue(res.has_header('Content-Disposition'))
コード例 #11
0
ファイル: forms.py プロジェクト: BillTheBest/horizon
 def handle(self, request, data):
     try:
         LOG.info('Creating keypair "%s"' % data['name'])
         keypair = api.keypair_create(request, data['name'])
         response = http.HttpResponse(mimetype='application/binary')
         response['Content-Disposition'] = \
                  'attachment; filename=%s.pem' % keypair.name
         response.write(keypair.private_key)
         return response
     except novaclient_exceptions.ClientException, e:
         LOG.exception("ClientException in CreateKeyPair")
         messages.error(request,
                        _('Error Creating Keypair: %s') % e.message)
         return shortcuts.redirect(request.build_absolute_uri())
コード例 #12
0
ファイル: forms.py プロジェクト: termie/horizon
 def handle(self, request, data):
     try:
         LOG.info('Creating keypair "%s"' % data['name'])
         keypair = api.keypair_create(request, data['name'])
         response = http.HttpResponse(mimetype='application/binary')
         response['Content-Disposition'] = \
                  'attachment; filename=%s.pem' % keypair.name
         response.write(keypair.private_key)
         return response
     except novaclient_exceptions.ClientException, e:
         LOG.exception("ClientException in CreateKeyPair")
         messages.error(request,
                        _('Error Creating Keypair: %s') % e.message)
         return shortcuts.redirect(request.build_absolute_uri())
コード例 #13
0
ファイル: views.py プロジェクト: asomya/horizon
    def get(self, request, keypair_name=None):
        try:
            keypair = api.keypair_create(request, keypair_name)
        except:
            redirect = reverse('horizon:nova:access_and_security:index')
            exceptions.handle(self.request,
                              _('Unable to create keypair: %(exc)s'),
                              redirect=redirect)

        response = http.HttpResponse(mimetype='application/binary')
        response['Content-Disposition'] = \
                'attachment; filename=%s.pem' % slugify(keypair.name)
        response.write(keypair.private_key)
        response['Content-Length'] = str(len(response.content))
        return response
コード例 #14
0
ファイル: views.py プロジェクト: liangxiaobi/chinahorizon
    def get(self, request, keypair_name=None):
        try:
            keypair = api.keypair_create(request, keypair_name)
        except:
            redirect = reverse('horizon:project:access_and_security:index')
            exceptions.handle(self.request,
                              _('Unable to create keypair: %(exc)s'),
                              redirect=redirect)

        response = http.HttpResponse(mimetype='application/binary')
        response['Content-Disposition'] = \
                'attachment; filename=%s.pem' % slugify(keypair.name)
        response.write(keypair.private_key)
        response['Content-Length'] = str(len(response.content))
        return response