예제 #1
0
파일: volume.py 프로젝트: fancyKai/vdsm
 def clone(self, dstPath, volFormat):
     """
     Clone self volume to the specified dst_image_dir/dst_volUUID
     """
     wasleaf = False
     taskName = "parent volume rollback: " + self.volUUID
     vars.task.pushRecovery(
         task.Recovery(taskName, "volume", "Volume", "parentVolumeRollback",
                       [self.sdUUID, self.imgUUID, self.volUUID]))
     if self.isLeaf():
         wasleaf = True
         self.setInternal()
     try:
         self.prepare(rw=False)
         self.log.debug('cloning volume %s to %s', self.volumePath, dstPath)
         parent = getBackingVolumePath(self.imgUUID, self.volUUID)
         qemuimg.create(dstPath,
                        backing=parent,
                        format=fmt2str(volFormat),
                        backingFormat=fmt2str(self.getFormat()))
         self.teardown(self.sdUUID, self.volUUID)
     except Exception as e:
         self.log.exception('cannot clone image %s volume %s to %s',
                            self.imgUUID, self.volUUID, dstPath)
         # FIXME: might race with other clones
         if wasleaf:
             self.setLeaf()
         self.teardown(self.sdUUID, self.volUUID)
         raise se.CannotCloneVolume(self.volumePath, dstPath, str(e))
예제 #2
0
파일: volume.py 프로젝트: vikas-lamba/vdsm
 def clone(self, dst_image_dir, dst_volUUID, volFormat, preallocate):
     """
     Clone self volume to the specified dst_image_dir/dst_volUUID
     """
     wasleaf = False
     dst_path = None
     taskName = "parent volume rollback: " + self.volUUID
     vars.task.pushRecovery(task.Recovery(taskName, "volume", "Volume", "parentVolumeRollback",
                                          [self.sdUUID, self.imgUUID, self.volUUID]))
     if self.isLeaf():
         wasleaf = True
         self.setInternal()
     try:
         self.prepare(rw=False)
         dst_path = os.path.join(dst_image_dir, dst_volUUID)
         self.log.debug("Volume.clone: %s to %s" % (self.volumePath, dst_path))
         size = int(self.getMetaParam(SIZE))
         parent = self.getVolumePath()
         parent_format = fmt2str(self.getFormat())
         # We should use parent's relative path instead of full path
         parent = os.path.join(os.path.basename(os.path.dirname(parent)),
                                                os.path.basename(parent))
         createVolume(parent, parent_format, dst_path, size, volFormat, preallocate)
         self.teardown(self.sdUUID, self.volUUID)
     except Exception, e:
         # FIXME: might race with other clones
         if wasleaf:
             self.setLeaf()
         self.teardown(self.sdUUID, self.volUUID)
         self.log.error("Volume.clone: can't clone: %s to %s" % (self.volumePath, dst_path))
         raise se.CannotCloneVolume(self.volumePath, dst_path, str(e))