Exemplo n.º 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.instance_values)
     xenapi_fake.create_vm(instance.name, 'Running')
     self.assertRaises(Exception,
                       conn.attach_volume,
                       instance.name,
                       volume['id'],
                       '/dev/sdc')
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
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.instance_values)
        vm = xenapi_fake.create_vm(instance.name, 'Running')
        result = conn.attach_volume(self._make_info(),
                                    instance.name, '/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()