Exemplo n.º 1
0
    def test_create_snapshot_post(self):
        volume = self.volumes.first()
        snapshot = self.volume_snapshots.first()

        self.mox.StubOutWithMock(api, "volume_snapshot_create")
        api.volume_snapshot_create(
            IsA(http.HttpRequest), volume.id, snapshot.display_name, snapshot.display_description
        ).AndReturn(snapshot)
        self.mox.ReplayAll()

        formData = {
            "method": "CreateSnapshotForm",
            "tenant_id": self.tenant.id,
            "volume_id": volume.id,
            "name": snapshot.display_name,
            "description": snapshot.display_description,
        }
        url = reverse("horizon:project:volumes:create_snapshot", args=[volume.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Exemplo n.º 2
0
    def handle(self, request, data):
        try:
            snapshot = api.volume_snapshot_create(request, data['volume_id'],
                                                  data['name'],
                                                  data['description'])

            message = _('Creating volume snapshot "%s"') % data['name']
            messages.info(request, message)
            return snapshot
        except:
            redirect = reverse("horizon:project:images_and_snapshots:index")
            exceptions.handle(request,
                              _('Unable to create volume snapshot.'),
                              redirect=redirect)
Exemplo n.º 3
0
    def test_create_snapshot_post(self):
        volume = self.volumes.first()
        snapshot = self.volume_snapshots.first()

        self.mox.StubOutWithMock(api, 'volume_snapshot_create')
        api.volume_snapshot_create(IsA(http.HttpRequest),
                                   volume.id,
                                   snapshot.display_name,
                                   snapshot.display_description) \
                                   .AndReturn(snapshot)
        self.mox.ReplayAll()

        formData = {
            'method': 'CreateSnapshotForm',
            'tenant_id': self.tenant.id,
            'volume_id': volume.id,
            'name': snapshot.display_name,
            'description': snapshot.display_description
        }
        url = reverse('horizon:project:volumes:create_snapshot',
                      args=[volume.id])
        res = self.client.post(url, formData)
        self.assertRedirectsNoFollow(res, INDEX_URL)
Exemplo n.º 4
0
    def handle(self, request, data):
        try:
            snapshot = api.volume_snapshot_create(request,
                                                  data['volume_id'],
                                                  data['name'],
                                                  data['description'])

            message = _('Creating volume snapshot "%s"') % data['name']
            messages.info(request, message)
            return snapshot
        except:
            redirect = reverse("horizon:project:images_and_snapshots:index")
            exceptions.handle(request,
                              _('Unable to create volume snapshot.'),
                              redirect=redirect)