Ejemplo n.º 1
0
 def expected_locks(self, subchain):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, subchain.sd_id)
     return [
         resourceManager.ResourceManagerLock(sc.STORAGE, subchain.sd_id, resourceManager.SHARED),
         resourceManager.ResourceManagerLock(img_ns, subchain.img_id, resourceManager.EXCLUSIVE),
         volume.VolumeLease(subchain.host_id, subchain.sd_id, subchain.img_id, subchain.base_id),
     ]
Ejemplo n.º 2
0
 def locks(self):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
     ret = [rm.ResourceManagerLock(sc.STORAGE, self.sd_id, rm.SHARED),
            rm.ResourceManagerLock(img_ns, self.img_id, rm.EXCLUSIVE)]
     dom = sdCache.produce_manifest(self.sd_id)
     if dom.hasVolumeLeases():
         ret.append(volume.VolumeLease(self._host_id, self.sd_id,
                                       self.img_id, self.vol_id))
     return ret
Ejemplo n.º 3
0
 def locks(self):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
     mode = rm.EXCLUSIVE if self._writable else rm.SHARED
     ret = [rm.ResourceManagerLock(sc.STORAGE, self.sd_id, rm.SHARED),
            rm.ResourceManagerLock(img_ns, self.img_id, mode)]
     if self._writable:
         ret.append(volume.VolumeLease(self._host_id, self.sd_id,
                                       self.img_id, self.vol_id))
     return ret
Ejemplo n.º 4
0
 def locks(self):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
     return [
         rm.ResourceManagerLock(sc.STORAGE, self.sd_id, rm.SHARED),
         rm.ResourceManagerLock(img_ns, self.img_id, rm.EXCLUSIVE),
         # We take only the base lease since no other volumes are modified
         volume.VolumeLease(self.host_id, self.sd_id, self.img_id,
                            self.base_id)
     ]
Ejemplo n.º 5
0
 def locks(self):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
     mode = rm.EXCLUSIVE if self._writable else rm.SHARED
     ret = [rm.ResourceManagerLock(sc.STORAGE, self.sd_id, rm.SHARED),
            rm.ResourceManagerLock(img_ns, self.img_id, mode)]
     if self._writable:
         ret.append(volume.VolumeLease(self._host_id, self.sd_id,
                                       self.img_id, self.vol_id))
     return ret
Ejemplo n.º 6
0
 def expected_locks(self, src_vol, dst_vol):
     src_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, src_vol.sdUUID)
     dst_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, dst_vol.sdUUID)
     ret = [
         # Domain lock for each volume
         resourceManager.ResourceManagerLock(sc.STORAGE, src_vol.sdUUID,
                                             resourceManager.SHARED),
         resourceManager.ResourceManagerLock(sc.STORAGE, dst_vol.sdUUID,
                                             resourceManager.SHARED),
         # Image lock for each volume, exclusive for the destination
         resourceManager.ResourceManagerLock(src_img_ns, src_vol.imgUUID,
                                             resourceManager.SHARED),
         resourceManager.ResourceManagerLock(dst_img_ns, dst_vol.imgUUID,
                                             resourceManager.EXCLUSIVE),
         # Volume lease for the destination volume
         volume.VolumeLease(0, dst_vol.sdUUID, dst_vol.imgUUID,
                            dst_vol.volUUID)
     ]
     return ret
Ejemplo n.º 7
0
 def expected_locks(self, src_vol, dst_vol):
     src_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, src_vol.sdUUID)
     dst_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, dst_vol.sdUUID)
     ret = [
         # Domain lock for each volume
         resourceManager.ResourceManagerLock(
             sc.STORAGE, src_vol.sdUUID, resourceManager.SHARED),
         resourceManager.ResourceManagerLock(
             sc.STORAGE, dst_vol.sdUUID, resourceManager.SHARED),
         # Image lock for each volume, exclusive for the destination
         resourceManager.ResourceManagerLock(
             src_img_ns, src_vol.imgUUID, resourceManager.SHARED),
         resourceManager.ResourceManagerLock(
             dst_img_ns, dst_vol.imgUUID, resourceManager.EXCLUSIVE),
         # Volume lease for the destination volume
         volume.VolumeLease(
             0, dst_vol.sdUUID, dst_vol.imgUUID, dst_vol.volUUID)
     ]
     return ret
Ejemplo n.º 8
0
Archivo: merge.py Proyecto: EdDev/vdsm
 def locks(self):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
     ret = [rm.ResourceManagerLock(sc.STORAGE, self.sd_id, rm.SHARED),
            rm.ResourceManagerLock(img_ns, self.img_id, rm.EXCLUSIVE)]
     dom = sdCache.produce_manifest(self.sd_id)
     if dom.hasVolumeLeases():
         # We take only the base lease since no other volumes are modified
         ret.append(volume.VolumeLease(self.host_id, self.sd_id,
                                       self.img_id, self.base_id))
     return ret
Ejemplo n.º 9
0
 def expected_locks(self, base_vol):
     img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, base_vol.sdUUID)
     ret = [
         # Domain lock
         resourceManager.ResourceManagerLock(
             sc.STORAGE, base_vol.sdUUID, resourceManager.SHARED),
         # Image lock
         resourceManager.ResourceManagerLock(
             img_ns, base_vol.imgUUID, resourceManager.EXCLUSIVE),
         # Volume lease
         volume.VolumeLease(
             0, base_vol.sdUUID, base_vol.imgUUID, base_vol.volUUID)
     ]
     return ret
Ejemplo n.º 10
0
    def _run(self):
        vol_format = sc.name2type(self.vol_info.vol_format)

        with self.sd_manifest.domain_lock(self.host_id):
            image_res_ns = sd.getNamespace(sc.IMAGE_NAMESPACE,
                                           self.sd_manifest.sdUUID)
            with rm.acquireResource(image_res_ns, self.vol_info.img_id,
                                    rm.EXCLUSIVE):
                artifacts = self.sd_manifest.get_volume_artifacts(
                    self.vol_info.img_id, self.vol_info.vol_id)
                artifacts.create(
                    self.vol_info.virtual_size, vol_format,
                    self.vol_info.disk_type, self.vol_info.description,
                    self.vol_info.parent, self.vol_info.initial_size)
                artifacts.commit()
Ejemplo n.º 11
0
    def _run(self):
        vol_format = sc.name2type(self.vol_info.vol_format)

        with self.sd_manifest.domain_lock(self.host_id):
            image_res_ns = sd.getNamespace(self.sd_manifest.sdUUID,
                                           IMAGE_NAMESPACE)
            with rmanager.acquireResource(image_res_ns, self.vol_info.img_id,
                                          rm.LockType.exclusive):
                artifacts = self.sd_manifest.get_volume_artifacts(
                    self.vol_info.img_id, self.vol_info.vol_id)
                artifacts.create(self.vol_info.virtual_size, vol_format,
                                 self.vol_info.disk_type,
                                 self.vol_info.description,
                                 self.vol_info.parent,
                                 self.vol_info.initial_size)
                artifacts.commit()
Ejemplo n.º 12
0
    def test_create_volume(self):
        args = self._get_args()
        job = storage.sdm.api.create_volume.Job(**args)

        with self._fake_env():
            job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.DONE, job.status)
        self.assertIsNone(job.progress)
        self.assertNotIn('error', job.info())

        # Verify that the domain lock was acquired and released
        self.assertEqual([('acquireDomainLock', (1, ), {}),
                          ('releaseDomainLock', (), {})],
                         args['sd_manifest'].__calls__)

        # Verify that the image resource was locked and released
        image_ns = sd.getNamespace(job.sd_manifest.sdUUID, sc.IMAGE_NAMESPACE)
        rm_args = (image_ns, job.vol_info.img_id, rm.LockType.exclusive)
        self.assertEqual([('acquireResource', rm_args, {}),
                          ('releaseResource', rm_args, {})], self.rm.__calls__)
    def test_create_volume(self):
        args = self._get_args()
        job = storage.sdm.api.create_volume.Job(**args)

        with self._fake_env():
            job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.DONE, job.status)
        self.assertIsNone(job.progress)
        self.assertNotIn('error', job.info())

        # Verify that the domain lock was acquired and released
        self.assertEqual([('acquireDomainLock', (1,), {}),
                          ('releaseDomainLock', (), {})],
                         args['sd_manifest'].__calls__)

        # Verify that the image resource was locked and released
        image_ns = sd.getNamespace(job.sd_manifest.sdUUID, IMAGE_NAMESPACE)
        rm_args = (image_ns, job.vol_info.img_id, rm.LockType.exclusive)
        self.assertEqual([('acquireResource', rm_args, {}),
                          ('releaseResource', rm_args, {})],
                         self.rm.__calls__)
Ejemplo n.º 14
0
 def test_properties(self):
     a = volume.VolumeLease(HOST_ID, 'dom', 'img', 'vol')
     self.assertEqual(sd.getNamespace(sc.VOLUME_LEASE_NAMESPACE, 'dom'),
                      a.ns)
     self.assertEqual('vol', a.name)
     self.assertEqual(rm.EXCLUSIVE, a.mode)
Ejemplo n.º 15
0
 def test_properties(self):
     a = volume.VolumeLease(HOST_ID, 'dom', 'img', 'vol')
     self.assertEqual(sd.getNamespace(sc.VOLUME_LEASE_NAMESPACE, 'dom'),
                      a.ns)
     self.assertEqual('vol', a.name)
     self.assertEqual(rm.EXCLUSIVE, a.mode)