Example #1
0
 def blockInfo(self, source):
     if not self._has_disk_block:
         raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR,
                          "no such disk in this VM")
     # capacity, allocation, physical
     info = self._block_disk.info()
     return [info[1], info[2], info[1]]
Example #2
0
    def test_set_new_threshold_when_state_unset_but_fails(self):
        with make_env(events_enabled=True,
                      drive_infos=self.DRIVE_INFOS) as (testvm, dom, drives):

            for drive in drives:
                self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.UNSET)

            # Simulate setBlockThreshold failure
            testvm._dom.errors["setBlockThreshold"] = fake.Error(
                libvirt.VIR_ERR_OPERATION_FAILED, "fake error")

            # first run: does nothing but set the block thresholds
            testvm.monitor_drives()

            for drive in drives:
                self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.UNSET)
    def test_block_threshold_set_failure_after_drive_extended(self):
        with make_env(
                events_enabled=True,
                drive_infos=self.DRIVE_INFOS) as (testvm, dom, drives):

            # first run: does nothing but set the block thresholds
            testvm.monitor_drives()

            # Simulate write on drive vdb
            vdb = dom.block_info['/virtio/1']

            # The BLOCK_THRESHOLD event contains the highest allocated
            # block...
            alloc = allocation_threshold_for_resize_mb(
                vdb, drives[1]) + 1 * MB

            # ... but we repeat the check in monitor_drives(),
            # so we need to set both locations to the correct value.
            vdb['allocation'] = alloc

            # Simulating block threshold event
            testvm.drive_monitor.on_block_threshold(
                'vdb', '/virtio/1', alloc, 1 * MB)

            # Simulating periodic check
            testvm.monitor_drives()
            self.assertEqual(len(testvm.cif.irs.extensions), 1)

            # Simulate completed extend operation, invoking callback

            # Simulate setBlockThreshold failure
            testvm._dom.errors["setBlockThreshold"] = fake.Error(
                libvirt.VIR_ERR_OPERATION_FAILED, "fake error")

            simulate_extend_callback(testvm.cif.irs, extension_id=0)

            drv = drives[1]
            self.assertEqual(drv.threshold_state, BLOCK_THRESHOLD.UNSET)
Example #4
0
def lookupByIDFailure(id):
    raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN, 'Domain not exists')
Example #5
0
def lookupByNameFailure(name):
    raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN, 'Domain not exists')
Example #6
0
def legacylistAllDomainsWrongRaise():
    raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN, 'Domain not exists')
Example #7
0
def legacylistAllDomains():
    raise fake.Error(libvirt.VIR_ERR_NO_SUPPORT, 'Method not supported')
Example #8
0
 def internal_error(name):
     raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
Example #9
0
 def internal_error(flags=0):
     raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
Example #10
0
 def lookupByID(self, id):
     for vm in self._vms:
         if vm.ID() == id:
             return vm
     raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN,
                      'virDomainLookupByID() failed')
Example #11
0
 def lookupByName(self, name):
     for vm in self._vms:
         if vm.name() == name:
             return vm
     raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN,
                      'virDomainLookupByName() failed')
Example #12
0
 def fail(uuid):
     raise vmfakelib.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
Example #13
0
 def fail(*args):
     raise fake.Error(libvirt.VIR_ERR_NO_DOMAIN)
Example #14
0
 def fail(*args):
     raise fake.Error(errcode)
Example #15
0
 def storageVolLookupByPath(self, name):
     if not any([vm._has_disk_volume for vm in self._vms]):
         raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR,
                          "no volume in storage")
     return FakeVolume()
Example #16
0
 def blockPeek(self, disk, pos, size):
     if not self._has_disk_block:
         raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR,
                          "no such disk in this VM")
     self._block_disk.seek(pos)
     return self._block_disk.read(size)