def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt,
                                             host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt,
                                              host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'], dest_volume['id'])

        # Check that we have copied destination volume DB data into source DB
        # entry so we can keep the id
        src_volume = objects.Volume.get_by_id(ctxt, src_volume['id'])
        self.assertEqual('dest', src_volume.host)
        self.assertEqual('available', src_volume.status)
        self.assertIsNone(src_volume.migration_status)

        # Check that we have copied source volume DB data into destination DB
        # entry and we are setting it to deleting
        dest_volume = objects.Volume.get_by_id(ctxt, dest_volume['id'])
        self.assertEqual('src', dest_volume.host)
        self.assertEqual('deleting', dest_volume.status)
        self.assertEqual('deleting', dest_volume.migration_status)
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt, host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt, host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'], dest_volume['id'])

        # Check that we have copied destination volume DB data into source DB
        # entry so we can keep the id
        src_volume = objects.Volume.get_by_id(ctxt, src_volume['id'])
        self.assertEqual('dest', src_volume.host)
        self.assertEqual('available', src_volume.status)
        self.assertIsNone(src_volume.migration_status)

        # Check that we have copied source volume DB data into destination DB
        # entry and we are setting it to deleting
        dest_volume = objects.Volume.get_by_id(ctxt, dest_volume['id'])
        self.assertEqual('src', dest_volume.host)
        self.assertEqual('deleting', dest_volume.status)
        self.assertEqual('deleting', dest_volume.migration_status)
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id="user_id", project_id="project_id", is_admin=True)
        src_volume = testutils.create_volume(ctxt, host="src", migration_status="migrating", status="available")
        dest_volume = testutils.create_volume(ctxt, host="dest", migration_status="target:fake", status="available")
        db.finish_volume_migration(ctxt, src_volume["id"], dest_volume["id"])

        src_volume = db.volume_get(ctxt, src_volume["id"])
        expected_name = "volume-%s" % dest_volume["id"]
        self.assertEqual(src_volume["_name_id"], dest_volume["id"])
        self.assertEqual(src_volume["name"], expected_name)
        self.assertEqual(src_volume["host"], "dest")
        self.assertEqual(src_volume["status"], "available")
        self.assertIsNone(src_volume["migration_status"])
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt, host='src',
                                             status='migrating')
        dest_volume = testutils.create_volume(ctxt, host='dest',
                                              status='migration_target')
        db.finish_volume_migration(ctxt, src_volume['id'],
                                   dest_volume['id'])

        self.assertRaises(exception.VolumeNotFound, db.volume_get, ctxt,
                          dest_volume['id'])
        src_volume = db.volume_get(ctxt, src_volume['id'])
        self.assertEqual(src_volume['host'], 'dest')
        self.assertEqual(src_volume['status'], 'migrating')
Exemple #5
0
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt,
                                             host='src',
                                             status='migrating')
        dest_volume = testutils.create_volume(ctxt,
                                              host='dest',
                                              status='migration_target')
        db.finish_volume_migration(ctxt, src_volume['id'], dest_volume['id'])

        self.assertRaises(exception.VolumeNotFound, db.volume_get, ctxt,
                          dest_volume['id'])
        src_volume = db.volume_get(ctxt, src_volume['id'])
        self.assertEqual(src_volume['host'], 'dest')
        self.assertEqual(src_volume['status'], 'migrating')
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt, host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt, host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'],
                                   dest_volume['id'])

        src_volume = db.volume_get(ctxt, src_volume['id'])
        self.assertEqual('dest', src_volume['host'])
        self.assertEqual('available', src_volume['status'])
        self.assertIsNone(src_volume['migration_status'])
Exemple #7
0
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt,
                                             host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt,
                                              host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'], dest_volume['id'])

        src_volume = db.volume_get(ctxt, src_volume['id'])
        self.assertEqual('dest', src_volume['host'])
        self.assertEqual('available', src_volume['status'])
        self.assertIsNone(src_volume['migration_status'])
    def _test_finish_volume_migration(self, source_type=None, dest_type=None):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        source_type_id = None
        dest_type_id = None
        if source_type:
            source_type_id = db.volume_type_create(ctxt, source_type).id
        if dest_type:
            dest_type_id = db.volume_type_create(ctxt, dest_type).id

        src_volume = testutils.create_volume(ctxt, host='src',
                                             migration_status='migrating',
                                             status='available',
                                             volume_type_id=source_type_id)
        dest_volume = testutils.create_volume(ctxt, host='dest',
                                              migration_status='target:fake',
                                              status='available',
                                              volume_type_id=dest_type_id)
        db.finish_volume_migration(ctxt, src_volume.id, dest_volume.id)

        # Check that we have copied destination volume DB data into source DB
        # entry so we can keep the id
        src_volume = objects.Volume.get_by_id(ctxt, src_volume.id)
        self.assertEqual('dest', src_volume.host)
        self.assertEqual('available', src_volume.status)
        self.assertIsNone(src_volume.migration_status)
        if dest_type:
            self.assertEqual(dest_type_id, src_volume.volume_type_id)
        else:
            self.assertIsNone(src_volume.volume_type_id)

        # Check that we have copied source volume DB data into destination DB
        # entry and we are setting it to deleting
        dest_volume = objects.Volume.get_by_id(ctxt, dest_volume.id)
        self.assertEqual('src', dest_volume.host)
        self.assertEqual('deleting', dest_volume.status)
        self.assertEqual('deleting', dest_volume.migration_status)
        if source_type:
            self.assertEqual(source_type_id, dest_volume.volume_type_id)
        else:
            self.assertIsNone(dest_volume.volume_type_id)
Exemple #9
0
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt, host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt, host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'],
                                   dest_volume['id'])

        self.assertRaises(exception.VolumeNotFound, db.volume_get, ctxt,
                          dest_volume['id'])
        src_volume = db.volume_get(ctxt, src_volume['id'])
        expected_name = 'volume-%s' % dest_volume['id']
        self.assertEqual(src_volume['_name_id'], dest_volume['id'])
        self.assertEqual(src_volume['name'], expected_name)
        self.assertEqual(src_volume['host'], 'dest')
        self.assertEqual(src_volume['status'], 'available')
        self.assertEqual(src_volume['migration_status'], None)
Exemple #10
0
    def test_finish_volume_migration(self):
        ctxt = context.RequestContext(user_id='user_id',
                                      project_id='project_id',
                                      is_admin=True)
        src_volume = testutils.create_volume(ctxt,
                                             host='src',
                                             migration_status='migrating',
                                             status='available')
        dest_volume = testutils.create_volume(ctxt,
                                              host='dest',
                                              migration_status='target:fake',
                                              status='available')
        db.finish_volume_migration(ctxt, src_volume['id'], dest_volume['id'])

        self.assertRaises(exception.VolumeNotFound, db.volume_get, ctxt,
                          dest_volume['id'])
        src_volume = db.volume_get(ctxt, src_volume['id'])
        expected_name = 'volume-%s' % dest_volume['id']
        self.assertEqual(src_volume['_name_id'], dest_volume['id'])
        self.assertEqual(src_volume['name'], expected_name)
        self.assertEqual(src_volume['host'], 'dest')
        self.assertEqual(src_volume['status'], 'available')
        self.assertEqual(src_volume['migration_status'], None)