예제 #1
0
 def test_attach_volume_raise_exception(self):
     """This shows how to test when exceptions are raised."""
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeFailedTests)
     conn = xenapi_conn.get_connection(False)
     volume = self._create_volume()
     instance = db.instance_create(self.context, self.values)
     xenapi_fake.create_vm(instance.name, "Running")
     self.assertRaises(Exception, conn.attach_volume, instance.name, volume["id"], "/dev/sdc")
예제 #2
0
 def test_attach_volume_raise_exception(self):
     """This shows how to test when exceptions are raised."""
     stubs.stubout_session(self.stubs,
                           stubs.FakeSessionForVolumeFailedTests)
     conn = xenapi_conn.get_connection(False)
     volume = self._create_volume()
     instance = db.instance_create(self.context, self.values)
     xenapi_fake.create_vm(instance.name, 'Running')
     self.assertRaises(Exception, conn.attach_volume, instance.name,
                       volume['id'], '/dev/sdc')
예제 #3
0
파일: stubs.py 프로젝트: pombredanne/nova
    def VM_snapshot(self, session_ref, vm_ref, label):
        status = "Running"
        template_vm_ref = fake.create_vm(label, status, is_a_template=True, is_control_domain=False)

        sr_ref = "fakesr"
        template_vdi_ref = fake.create_vdi(label, read_only=True, sr_ref=sr_ref, sharable=False)

        template_vbd_ref = fake.create_vbd(template_vm_ref, template_vdi_ref)
        return template_vm_ref
예제 #4
0
    def test_get_instance_vdis_for_sr_no_vbd(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(driver._session, vm_ref, sr_ref))

        self.assertEquals([], result)
예제 #5
0
파일: stubs.py 프로젝트: kiall/nova
    def VM_snapshot(self, session_ref, vm_ref, label):
        status = "Running"
        template_vm_ref = fake.create_vm(label, status, is_a_template=True,
            is_control_domain=False)

        sr_ref = "fakesr"
        template_vdi_ref = fake.create_vdi(label, sr_ref, read_only=True)

        template_vbd_ref = fake.create_vbd(template_vm_ref, template_vdi_ref)
        return template_vm_ref
예제 #6
0
    def test_get_instance_vdis_for_sr_no_vbd(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(
            driver._session, vm_ref, sr_ref))

        self.assertEquals([], result)
예제 #7
0
 def setUp(self):
     super(GenerateDiskTestCase, self).setUp()
     self.flags(disable_process_locking=True,
                instance_name_template='%d',
                firewall_driver='nova.virt.xenapi.firewall.'
                                'Dom0IptablesFirewallDriver',
                xenapi_connection_url='test_url',
                xenapi_connection_password='******',)
     stubs.stubout_session(self.stubs, fake.SessionBase)
     driver = xenapi_conn.XenAPIDriver(False)
     self.session = driver._session
     self.vm_ref = fake.create_vm("foo", "Running")
예제 #8
0
 def setUp(self):
     super(GenerateDiskTestCase, self).setUp()
     self.flags(disable_process_locking=True,
                instance_name_template='%d',
                firewall_driver='nova.virt.xenapi.firewall.'
                                'Dom0IptablesFirewallDriver',
                xenapi_connection_url='test_url',
                xenapi_connection_password='******',)
     stubs.stubout_session(self.stubs, fake.SessionBase)
     driver = xenapi_conn.XenAPIDriver(False)
     self.session = driver._session
     self.session.is_local_connection = False
     self.vm_ref = fake.create_vm("foo", "Running")
예제 #9
0
    def test_get_instance_vdis_for_sr(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        vdi_1 = fake.create_vdi("vdiname1", sr_ref)
        vdi_2 = fake.create_vdi("vdiname2", sr_ref)

        for vdi_ref in [vdi_1, vdi_2]:
            fake.create_vbd(vm_ref, vdi_ref)

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(driver._session, vm_ref, sr_ref))

        self.assertEquals([vdi_1, vdi_2], result)
예제 #10
0
    def test_get_instance_vdis_for_sr(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        vdi_1 = fake.create_vdi('vdiname1', sr_ref)
        vdi_2 = fake.create_vdi('vdiname2', sr_ref)

        for vdi_ref in [vdi_1, vdi_2]:
            fake.create_vbd(vm_ref, vdi_ref)

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(
            driver._session, vm_ref, sr_ref))

        self.assertEquals([vdi_1, vdi_2], result)
예제 #11
0
    def test_attach_volume(self):
        """This shows how to test Ops classes' methods."""
        stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests)
        conn = xenapi_conn.get_connection(False)
        volume = self._create_volume()
        instance = db.instance_create(self.context, self.values)
        vm = xenapi_fake.create_vm(instance.name, 'Running')
        result = conn.attach_volume(instance.name, volume['id'], '/dev/sdc')

        def check():
            # check that the VM has a VBD attached to it
            # Get XenAPI record for VBD
            vbds = xenapi_fake.get_all('VBD')
            vbd = xenapi_fake.get_record('VBD', vbds[0])
            vm_ref = vbd['VM']
            self.assertEqual(vm_ref, vm)

        check()
예제 #12
0
 def create_vm(self, name, state="running"):
     vm_ref = xenapi_fake.create_vm(name, state)
     self.vms.append(vm_ref)
     vm = xenapi_fake.get_record("VM", vm_ref)
     return vm, vm_ref
예제 #13
0
파일: test_vmops.py 프로젝트: PFZheng/nova
 def create_vm(self, name, state="Running"):
     vm_ref = xenapi_fake.create_vm(name, state)
     self.vms.append(vm_ref)
     vm = xenapi_fake.get_record("VM", vm_ref)
     return vm, vm_ref
예제 #14
0
파일: test_vmops.py 프로젝트: DavidYan/nova
 def _create_vm(self, name, state):
     vm = xenapi_fake.create_vm(name, state)
     self.vms.append(vm)
     return vm
예제 #15
0
 def _create_vm(self, name, state):
     vm = xenapi_fake.create_vm(name, state)
     self.vms.append(vm)
     return vm