Exemplo n.º 1
0
    def test_bless_instance_exception(self):
        self.vmsconn.set_return_val("bless", utils.TestInducedException())
        self.vmsconn.set_return_val("get_instance_info",
            {'state': power_state.RUNNING})
        self.vmsconn.set_return_val("unpause_instance", None)

        blessed_uuid = utils.create_pre_blessed_instance(self.context)

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertTrue(blessed_instance['disable_terminate'])

        try:
            self.cobalt.bless_instance(self.context,
                                       instance_uuid=blessed_uuid,
                                       migration_url=None)
            self.fail("The bless error should have been re-raised up.")
        except utils.TestInducedException:
            pass

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertEquals(vm_states.ERROR, blessed_instance['vm_state'])
        system_metadata = db.instance_system_metadata_get(self.context, blessed_uuid)
        self.assertEquals(None, system_metadata.get('images', None))
        self.assertEquals(None, system_metadata.get('blessed', None))
        self.assertEquals(None, blessed_instance['launched_at'])
        self.assertTrue(blessed_instance['disable_terminate'])
Exemplo n.º 2
0
    def test_bless_instance_exception(self):
        self.vmsconn.set_return_val("bless", utils.TestInducedException())
        self.vmsconn.set_return_val("get_instance_info",
                                    {'state': power_state.RUNNING})
        self.vmsconn.set_return_val("unpause_instance", None)

        blessed_uuid = utils.create_pre_blessed_instance(self.context)

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertTrue(blessed_instance['disable_terminate'])

        try:
            self.cobalt.bless_instance(self.context,
                                       instance_uuid=blessed_uuid,
                                       migration_url=None)
            self.fail("The bless error should have been re-raised up.")
        except utils.TestInducedException:
            pass

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertEquals(vm_states.ERROR, blessed_instance['vm_state'])
        system_metadata = db.instance_system_metadata_get(
            self.context, blessed_uuid)
        self.assertEquals(None, system_metadata.get('images', None))
        self.assertEquals(None, system_metadata.get('blessed', None))
        self.assertEquals(None, blessed_instance['launched_at'])
        self.assertTrue(blessed_instance['disable_terminate'])
Exemplo n.º 3
0
    def test_bless_instance(self):

        self.vmsconn.set_return_val("bless",
                                    ("newname", "migration_url", ["file1", "file2", "file3"],[]))
        self.vmsconn.set_return_val("post_bless", ["file1_ref", "file2_ref", "file3_ref"])
        self.vmsconn.set_return_val("bless_cleanup", None)
        self.vmsconn.set_return_val("get_instance_info",
                                    {'state': power_state.RUNNING})

        pre_bless_time = datetime.utcnow()
        blessed_uuid = utils.create_pre_blessed_instance(self.context)
        migration_url, instance_ref = self.cobalt.bless_instance(
                                                    self.context,
                                                    instance_uuid=blessed_uuid,
                                                    migration_url=None)

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertEquals("blessed", blessed_instance['vm_state'])
        self.assertEquals("migration_url", migration_url)
        system_metadata = db.instance_system_metadata_get(self.context, blessed_uuid)
        self.assertEquals("file1_ref,file2_ref,file3_ref", system_metadata['images'])

        self.assertTrue(pre_bless_time <= blessed_instance['launched_at'])

        self.assertTrue(blessed_instance['disable_terminate'])
Exemplo n.º 4
0
    def test_bless_instance(self):

        self.vmsconn.set_return_val(
            "bless",
            ("newname", "migration_url", ["file1", "file2", "file3"], []))
        self.vmsconn.set_return_val("post_bless",
                                    ["file1_ref", "file2_ref", "file3_ref"])
        self.vmsconn.set_return_val("bless_cleanup", None)
        self.vmsconn.set_return_val("get_instance_info",
                                    {'state': power_state.RUNNING})

        pre_bless_time = datetime.utcnow()
        blessed_uuid = utils.create_pre_blessed_instance(self.context)
        migration_url, instance_ref = self.cobalt.bless_instance(
            self.context, instance_uuid=blessed_uuid, migration_url=None)

        blessed_instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        self.assertEquals("blessed", blessed_instance['vm_state'])
        self.assertEquals("migration_url", migration_url)
        system_metadata = db.instance_system_metadata_get(
            self.context, blessed_uuid)
        self.assertEquals("file1_ref,file2_ref,file3_ref",
                          system_metadata['images'])

        self.assertTrue(pre_bless_time <= blessed_instance['launched_at'])

        self.assertTrue(blessed_instance['disable_terminate'])