예제 #1
0
    def test_migration_get_unconfirmed_by_dest_compute(self):
        ctxt = context.get_admin_context()

        # Ensure no migrations are returned.
        results = db.migration_get_unconfirmed_by_dest_compute(ctxt, 10, "fake_host")
        self.assertEqual(0, len(results))

        # Ensure no migrations are returned.
        results = db.migration_get_unconfirmed_by_dest_compute(ctxt, 10, "fake_host2")
        self.assertEqual(0, len(results))

        updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00)
        values = {"status": "finished", "updated_at": updated_at, "dest_compute": "fake_host2"}
        migration = db.migration_create(ctxt, values)

        # Ensure different host is not returned
        results = db.migration_get_unconfirmed_by_dest_compute(ctxt, 10, "fake_host")
        self.assertEqual(0, len(results))

        # Ensure one migration older than 10 seconds is returned.
        results = db.migration_get_unconfirmed_by_dest_compute(ctxt, 10, "fake_host2")
        self.assertEqual(1, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})

        # Ensure the new migration is not returned.
        updated_at = timeutils.utcnow()
        values = {"status": "finished", "updated_at": updated_at, "dest_compute": "fake_host2"}
        migration = db.migration_create(ctxt, values)
        results = db.migration_get_unconfirmed_by_dest_compute(ctxt, 10, "fake_host2")
        self.assertEqual(0, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})
예제 #2
0
 def test_save(self):
     ctxt = context.get_admin_context()
     self.mox.StubOutWithMock(db, 'migration_update')
     db.migration_update(ctxt, 123, {'source_compute': 'foo'}
                         ).AndReturn(fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration()
     mig.id = 123
     mig.source_compute = 'foo'
     mig.save(ctxt)
     self.assertEqual(fake_migration['dest_compute'], mig.dest_compute)
예제 #3
0
 def test_save(self):
     ctxt = context.get_admin_context()
     fake_migration = fake_db_migration()
     self.mox.StubOutWithMock(db, 'migration_update')
     db.migration_update(ctxt, 123, {'source_compute': 'foo'}
                         ).AndReturn(fake_migration)
     self.mox.ReplayAll()
     mig = migration.Migration(context=ctxt)
     mig.id = 123
     mig.source_compute = 'foo'
     mig.save()
     self.assertEqual(fake_migration['dest_compute'], mig.dest_compute)
예제 #4
0
 def save(self, context):
     updates = {}
     for key in self.obj_what_changed():
         updates[key] = self[key]
     updates.pop('id', None)
     db_migration = db.migration_update(context, self.id, updates)
     self._from_db_object(context, self, db_migration)
     self.obj_reset_changes()
예제 #5
0
 def save(self, context):
     updates = {}
     for key in self.obj_what_changed():
         updates[key] = self[key]
     updates.pop('id', None)
     db_migration = db.migration_update(context, self.id, updates)
     self._from_db_object(context, self, db_migration)
     self.obj_reset_changes()
예제 #6
0
    def test_migration_get_all_unconfirmed(self):
        ctxt = context.get_admin_context()

        # Ensure no migrations are returned.
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(0, len(results))

        # Ensure one migration older than 10 seconds is returned.
        updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00)
        values = {"status": "FINISHED", "updated_at": updated_at}
        migration = db.migration_create(ctxt, values)
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(1, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})

        # Ensure the new migration is not returned.
        updated_at = datetime.datetime.utcnow()
        values = {"status": "FINISHED", "updated_at": updated_at}
        migration = db.migration_create(ctxt, values)
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(0, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})
예제 #7
0
파일: test_db_api.py 프로젝트: TMG-nl/nova
    def test_migration_get_all_unconfirmed(self):
        ctxt = context.get_admin_context()

        # Ensure no migrations are returned.
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(0, len(results))

        # Ensure one migration older than 10 seconds is returned.
        updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00)
        values = {"status": "FINISHED", "updated_at": updated_at}
        migration = db.migration_create(ctxt, values)
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(1, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})

        # Ensure the new migration is not returned.
        updated_at = datetime.datetime.utcnow()
        values = {"status": "FINISHED", "updated_at": updated_at}
        migration = db.migration_create(ctxt, values)
        results = db.migration_get_all_unconfirmed(ctxt, 10)
        self.assertEqual(0, len(results))
        db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})
예제 #8
0
 def save(self, context):
     updates = self.obj_get_changes()
     updates.pop('id', None)
     db_migration = db.migration_update(context, self.id, updates)
     self._from_db_object(context, self, db_migration)
     self.obj_reset_changes()
예제 #9
0
파일: migration.py 프로젝트: 375670450/nova
 def save(self):
     updates = self.obj_get_changes()
     updates.pop('id', None)
     db_migration = db.migration_update(self._context, self.id, updates)
     self._from_db_object(self._context, self, db_migration)
     self.obj_reset_changes()
예제 #10
0
 def confirm_resize(self, context, migration, status='confirmed'):
     """Cleanup usage for a confirmed resize"""
     elevated = context.elevated()
     db.migration_update(elevated, migration['id'], {'status': status})
     self.update_available_resource(elevated)
예제 #11
0
 def confirm_resize(self, context, migration, status='confirmed'):
     """Cleanup usage for a confirmed resize."""
     elevated = context.elevated()
     db.migration_update(elevated, migration['id'],
                         {'status': status})
     self.update_available_resource(elevated)
예제 #12
0
 def confirm_resize(self, context, migration, status="confirmed"):
     """Cleanup usage for a confirmed resize"""
     elevated = context.elevated()
     db.migration_update(elevated, migration["id"], {"status": status})
     self.update_available_resource(elevated)