示例#1
0
    def test_initialize_connection(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "initialize_connection")
        self.cinderclient.volumes.initialize_connection("id1", "connector")
        self.mox.ReplayAll()

        self.api.initialize_connection(self.ctx, {"id": "id1"}, "connector")
示例#2
0
    def test_attach(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "attach")
        self.cinderclient.volumes.attach("id1", "uuid", "point")
        self.mox.ReplayAll()

        self.api.attach(self.ctx, {"id": "id1"}, "uuid", "point")
示例#3
0
    def test_delete(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "delete")
        self.cinderclient.volumes.delete("id1")
        self.mox.ReplayAll()

        self.api.delete(self.ctx, {"id": "id1"})
示例#4
0
    def test_begin_detaching(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "begin_detaching")
        self.cinderclient.volumes.begin_detaching("id1")
        self.mox.ReplayAll()

        self.api.begin_detaching(self.ctx, {"id": "id1"})
示例#5
0
    def test_delete_snapshot(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volume_snapshots, "delete")
        self.cinderclient.volume_snapshots.delete("id1")
        self.mox.ReplayAll()

        self.api.delete_snapshot(self.ctx, "id1")
示例#6
0
    def test_get(self):
        volume_id = 'volume_id1'
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx, {'id': 'volume_id1'})
        self.mox.ReplayAll()

        self.api.get(self.ctx, volume_id)
示例#7
0
    def test_create_failed(self):
        cinder.get_cinder_client_version(self.ctx).AndReturn('2')
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.BadRequest(''))
        self.mox.ReplayAll()

        self.assertRaises(exception.InvalidInput,
                          self.api.create, self.ctx, 1, '', '')
示例#8
0
    def test_get(self):
        volume_id = "volume_id1"
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx, {"id": "volume_id1"})
        self.mox.ReplayAll()

        self.api.get(self.ctx, volume_id)
示例#9
0
    def test_get_snapshot_failed(self):
        snapshot_id = 'snapshot_id'
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.NotFound(''))
        self.mox.ReplayAll()

        self.assertRaises(exception.SnapshotNotFound,
                          self.api.get_snapshot, self.ctx, snapshot_id)
示例#10
0
    def test_terminate_connection(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "terminate_connection")
        self.cinderclient.volumes.terminate_connection("id1", "connector")
        self.mox.ReplayAll()

        self.api.terminate_connection(self.ctx, "id1", "connector")
示例#11
0
    def test_get_volume_encryption_metadata(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "get_encryption_metadata")
        self.cinderclient.volumes.get_encryption_metadata({"encryption_key_id": "fake_key"})
        self.mox.ReplayAll()

        self.api.get_volume_encryption_metadata(self.ctx, {"encryption_key_id": "fake_key"})
示例#12
0
    def test_get_all_snapshots(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_snapshot_summary_view(self.ctx, {"id": "id1"}).AndReturn("id1")
        cinder._untranslate_snapshot_summary_view(self.ctx, {"id": "id2"}).AndReturn("id2")
        self.mox.ReplayAll()

        self.assertEqual(["id1", "id2"], self.api.get_all_snapshots(self.ctx))
示例#13
0
    def test_get_snapshot(self):
        snapshot_id = "snapshot_id"
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_snapshot_summary_view(self.ctx, {"id": snapshot_id})
        self.mox.ReplayAll()

        self.api.get_snapshot(self.ctx, snapshot_id)
示例#14
0
    def test_roll_detaching(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "roll_detaching")
        self.cinderclient.volumes.roll_detaching("id1")
        self.mox.ReplayAll()

        self.api.roll_detaching(self.ctx, "id1")
示例#15
0
    def test_detach(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "detach")
        self.cinderclient.volumes.detach("id1")
        self.mox.ReplayAll()

        self.api.detach(self.ctx, "id1")
示例#16
0
    def test_unreserve_volume(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes, "unreserve")
        self.cinderclient.volumes.unreserve("id1")
        self.mox.ReplayAll()

        self.api.unreserve_volume(self.ctx, "id1")
示例#17
0
    def test_create_force(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_snapshot_summary_view(self.ctx,
                                                  {'id': 'created_id'})
        self.mox.ReplayAll()

        self.api.create_snapshot_force(self.ctx, {'id': 'id1'}, '', '')
示例#18
0
    def test_create(self):
        cinder.get_cinder_client_version(self.ctx).AndReturn('2')
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx, {'id': 'created_id'})
        self.mox.ReplayAll()

        self.api.create(self.ctx, 1, '', '')
示例#19
0
    def test_create(self):
        cinder.get_cinder_client_version(self.ctx).AndReturn("2")
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx, {"id": "created_id"})
        self.mox.ReplayAll()

        self.api.create(self.ctx, 1, "", "")
示例#20
0
    def test_delete_snapshot(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volume_snapshots,
                                 'delete')
        self.cinderclient.volume_snapshots.delete('id1')
        self.mox.ReplayAll()

        self.api.delete_snapshot(self.ctx, {'id': 'id1'})
示例#21
0
    def test_get_snapshot_failed(self):
        snapshot_id = "snapshot_id"
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.NotFound(""))
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.ConnectionError(""))
        self.mox.ReplayAll()

        self.assertRaises(exception.SnapshotNotFound, self.api.get_snapshot, self.ctx, snapshot_id)
        self.assertRaises(exception.CinderConnectionFailed, self.api.get_snapshot, self.ctx, snapshot_id)
示例#22
0
    def test_attach(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'attach')
        self.cinderclient.volumes.attach('id1', 'uuid', 'point')
        self.mox.ReplayAll()

        self.api.attach(self.ctx, 'id1', 'uuid', 'point')
示例#23
0
    def test_initialize_connection(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'initialize_connection')
        self.cinderclient.volumes.initialize_connection('id1', 'connector')
        self.mox.ReplayAll()

        self.api.initialize_connection(self.ctx, {'id': 'id1'}, 'connector')
示例#24
0
 def test_update_snapshot_status(self):
     cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
     self.mox.StubOutWithMock(self.cinderclient.volume_snapshots,
                              'update_snapshot_status')
     self.cinderclient.volume_snapshots.update_snapshot_status(
         'id1', {'status': 'error', 'progress': '90%'})
     self.mox.ReplayAll()
     self.api.update_snapshot_status(self.ctx, 'id1', 'error')
示例#25
0
    def test_get_failed(self):
        volume_id = "volume_id"
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.NotFound(""))
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.BadRequest(""))
        self.mox.ReplayAll()

        self.assertRaises(exception.VolumeNotFound, self.api.get, self.ctx, volume_id)
        self.assertRaises(exception.InvalidInput, self.api.get, self.ctx, volume_id)
示例#26
0
    def test_get_all_with_search(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx,
                                                {'id': 'id1'}).AndReturn('id1')
        self.mox.ReplayAll()

        self.assertEqual(['id1'], self.api.get_all(self.ctx,
                                                   search_opts={'id': 'id1'}))
示例#27
0
    def test_delete(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'delete')
        self.cinderclient.volumes.delete('id1')
        self.mox.ReplayAll()

        self.api.delete(self.ctx, 'id1')
示例#28
0
    def test_terminate_connection(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'terminate_connection')
        self.cinderclient.volumes.terminate_connection('id1', 'connector')
        self.mox.ReplayAll()

        self.api.terminate_connection(self.ctx, 'id1', 'connector')
示例#29
0
    def test_begin_detaching(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'begin_detaching')
        self.cinderclient.volumes.begin_detaching('id1')
        self.mox.ReplayAll()

        self.api.begin_detaching(self.ctx, 'id1')
示例#30
0
    def test_reserve_volume(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        self.mox.StubOutWithMock(self.cinderclient.volumes,
                                 'reserve')
        self.cinderclient.volumes.reserve('id1')
        self.mox.ReplayAll()

        self.api.reserve_volume(self.ctx, 'id1')
示例#31
0
    def test_create_failed(self):
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.NotFound(''))
        self.mox.ReplayAll()

        self.assertRaises(exception.VolumeNotFound, self.api.create, self.ctx,
                          1, '', '')
示例#32
0
 def create_client(self):
     return cinder.cinderclient(self.context)
示例#33
0
    def test_create_failed(self):
        cinder.cinderclient(self.ctx).AndRaise(cinder_exception.BadRequest(''))
        self.mox.ReplayAll()

        self.assertRaises(exception.InvalidInput, self.api.create, self.ctx, 1,
                          '', '')
示例#34
0
    def test_create(self):
        cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
        cinder._untranslate_volume_summary_view(self.ctx, {'id': 'created_id'})
        self.mox.ReplayAll()

        self.api.create(self.ctx, 1, '', '')