Beispiel #1
0
    def test_launch_instance_images(self):
        self.vmsconn.set_return_val("launch", None)
        blessed_uuid = utils.create_blessed_instance(self.context,
            instance={'system_metadata':{'images':'image1'}})

        instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        system_metadata = db.instance_system_metadata_get(self.context, instance['uuid'])
        self.assertEquals('image1', system_metadata.get('images', ''))

        launched_uuid = utils.create_pre_launched_instance(self.context, source_uuid=blessed_uuid)

        self.cobalt.launch_instance(self.context, instance_uuid=launched_uuid)

        # Ensure that image1 was passed to vmsconn.launch
        self.assertEquals(['image1'], self.vmsconn.params_passed[0]['kwargs']['image_refs'])
Beispiel #2
0
    def test_launch_instance_exception(self):

        self.vmsconn.set_return_val("launch", utils.TestInducedException())
        launched_uuid = utils.create_pre_launched_instance(self.context)

        try:
            self.cobalt.launch_instance(self.context, instance_uuid=launched_uuid)
            self.fail("The exception from launch should be re-raised up.")
        except utils.TestInducedException:
            pass

        launched_instance = db.instance_get_by_uuid(self.context, launched_uuid)
        self.assertEquals("error", launched_instance['vm_state'])
        self.assertEquals(None, launched_instance['task_state'])
        self.assertEquals(None, launched_instance['launched_at'])
        self.assertEquals(self.cobalt.host, launched_instance['host'])
        self.assertEquals(self.cobalt.nodename, launched_instance['node'])
Beispiel #3
0
    def test_launch_instance_exception(self):

        self.vmsconn.set_return_val("launch", utils.TestInducedException())
        launched_uuid = utils.create_pre_launched_instance(self.context)

        try:
            self.cobalt.launch_instance(self.context,
                                        instance_uuid=launched_uuid)
            self.fail("The exception from launch should be re-raised up.")
        except utils.TestInducedException:
            pass

        launched_instance = db.instance_get_by_uuid(self.context,
                                                    launched_uuid)
        self.assertEquals("error", launched_instance['vm_state'])
        self.assertEquals(None, launched_instance['task_state'])
        self.assertEquals(None, launched_instance['launched_at'])
        self.assertEquals(self.cobalt.host, launched_instance['host'])
        self.assertEquals(self.cobalt.nodename, launched_instance['node'])
Beispiel #4
0
    def test_launch_instance_images(self):
        self.vmsconn.set_return_val("launch", None)
        blessed_uuid = utils.create_blessed_instance(
            self.context, instance={'system_metadata': {
                'images': 'image1'
            }})

        instance = db.instance_get_by_uuid(self.context, blessed_uuid)
        system_metadata = db.instance_system_metadata_get(
            self.context, instance['uuid'])
        self.assertEquals('image1', system_metadata.get('images', ''))

        launched_uuid = utils.create_pre_launched_instance(
            self.context, source_uuid=blessed_uuid)

        self.cobalt.launch_instance(self.context, instance_uuid=launched_uuid)

        # Ensure that image1 was passed to vmsconn.launch
        self.assertEquals(
            ['image1'], self.vmsconn.params_passed[0]['kwargs']['image_refs'])
Beispiel #5
0
    def test_launch_instance(self):

        self.vmsconn.set_return_val("launch", None)
        blessed_uuid = utils.create_blessed_instance(self.context)
        launched_uuid = utils.create_pre_launched_instance(self.context,
                                                source_uuid=blessed_uuid)

        pre_launch_time = datetime.utcnow()
        self.cobalt.launch_instance(self.context, instance_uuid=launched_uuid)

        launched_instance = db.instance_get_by_uuid(self.context, launched_uuid)
        self.assertNotEquals(None, launched_instance['power_state'])
        self.assertEquals("active", launched_instance['vm_state'])
        self.assertTrue(pre_launch_time <= launched_instance['launched_at'])
        self.assertEquals(None, launched_instance['task_state'])
        self.assertEquals(self.cobalt.host, launched_instance['host'])
        self.assertEquals(self.cobalt.nodename, launched_instance['node'])

        # Ensure the proper vms policy is passed into vmsconn
        self.assertEquals(';blessed=%s;;flavor=m1.tiny;;tenant=fake;;uuid=%s;'\
                             % (blessed_uuid, launched_uuid),
            self.vmsconn.params_passed[0]['kwargs']['vms_policy'])
Beispiel #6
0
    def test_launch_instance(self):

        self.vmsconn.set_return_val("launch", None)
        blessed_uuid = utils.create_blessed_instance(self.context)
        launched_uuid = utils.create_pre_launched_instance(
            self.context, source_uuid=blessed_uuid)

        pre_launch_time = datetime.utcnow()
        self.cobalt.launch_instance(self.context, instance_uuid=launched_uuid)

        launched_instance = db.instance_get_by_uuid(self.context,
                                                    launched_uuid)
        self.assertNotEquals(None, launched_instance['power_state'])
        self.assertEquals("active", launched_instance['vm_state'])
        self.assertTrue(pre_launch_time <= launched_instance['launched_at'])
        self.assertEquals(None, launched_instance['task_state'])
        self.assertEquals(self.cobalt.host, launched_instance['host'])
        self.assertEquals(self.cobalt.nodename, launched_instance['node'])

        # Ensure the proper vms policy is passed into vmsconn
        self.assertEquals(';blessed=%s;;flavor=m1.tiny;;tenant=fake;;uuid=%s;'\
                             % (blessed_uuid, launched_uuid),
            self.vmsconn.params_passed[0]['kwargs']['vms_policy'])