Example #1
0
    def test_create_snapshot_post_exception(self):
        SNAPSHOT_NAME = 'snappy'

        new_snapshot = self.mox.CreateMock(api.Image)
        new_snapshot.name = SNAPSHOT_NAME

        formData = {
            'method': 'CreateSnapshot',
            'tenant_id': self.TEST_TENANT,
            'instance_id': self.good_server.id,
            'name': SNAPSHOT_NAME
        }

        self.mox.StubOutWithMock(api, 'snapshot_create')
        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')
        api.snapshot_create(IsA(http.HttpRequest),
                            str(self.good_server.id), SNAPSHOT_NAME).\
                            AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(
            reverse('steer:engine:images_and_snapshots:snapshots:create',
                    args=[self.good_server.id]), formData)

        self.assertRedirectsNoFollow(
            res,
            reverse('steer:engine:images_and_snapshots:snapshots:create',
                    args=[self.good_server.id]))
Example #2
0
    def test_create_snapshot_post_exception(self):
        SNAPSHOT_NAME = 'snappy'

        new_snapshot = self.mox.CreateMock(api.Image)
        new_snapshot.name = SNAPSHOT_NAME

        formData = {'method': 'CreateSnapshot',
                    'tenant_id': self.TEST_TENANT,
                    'instance_id': self.good_server.id,
                    'name': SNAPSHOT_NAME}

        self.mox.StubOutWithMock(api, 'snapshot_create')
        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')
        api.snapshot_create(IsA(http.HttpRequest),
                            str(self.good_server.id), SNAPSHOT_NAME).\
                            AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.post(
                reverse('steer:engine:images_and_snapshots:snapshots:create',
                        args=[self.good_server.id]),
                        formData)

        self.assertRedirectsNoFollow(res,
                 reverse('steer:engine:images_and_snapshots:snapshots:create',
                 args=[self.good_server.id]))
Example #3
0
    def handle(self, request, data):
        try:
            LOG.info('Creating snapshot "%s"' % data['name'])
            snapshot = api.snapshot_create(request,
                    data['instance_id'],
                    data['name'])
            instance = api.server_get(request, data['instance_id'])

            messages.info(request,
                     _('Snapshot "%(name)s" created for instance "%(inst)s"') %
                    {"name": data['name'], "inst": instance.name})
            return shortcuts.redirect('steer:engine:images_and_snapshots'
                                      ':snapshots:index')
        except api_exceptions.ApiException, e:
            msg = _('Error Creating Snapshot: %s') % e.message
            LOG.exception(msg)
            messages.error(request, msg)
            return shortcuts.redirect(request.build_absolute_uri())
Example #4
0
    def handle(self, request, data):
        try:
            LOG.info('Creating snapshot "%s"' % data['name'])
            snapshot = api.snapshot_create(request, data['instance_id'],
                                           data['name'])
            instance = api.server_get(request, data['instance_id'])

            messages.info(
                request,
                _('Snapshot "%(name)s" created for instance "%(inst)s"') % {
                    "name": data['name'],
                    "inst": instance.name
                })
            return shortcuts.redirect('steer:engine:images_and_snapshots'
                                      ':snapshots:index')
        except api_exceptions.ApiException, e:
            msg = _('Error Creating Snapshot: %s') % e.message
            LOG.exception(msg)
            messages.error(request, msg)
            return shortcuts.redirect(request.build_absolute_uri())