Exemple #1
0
    def _create_metadata_artifact(self, size, vol_format, prealloc, disk_type,
                                  desc, parent):
        if self._oop.fileUtils.pathExists(self.meta_path):
            raise se.VolumeAlreadyExists("metadata exists: %r" %
                                         self.meta_path)

        if self._oop.fileUtils.pathExists(self.meta_volatile_path):
            raise se.DomainHasGarbage("metadata artifact exists: %r" %
                                      self.meta_volatile_path)

        parent_vol_id = parent.vol_id if parent else sc.BLANK_UUID
        # Create the metadata artifact.  The metadata file is created with a
        # special extension to prevent these artifacts from being recognized as
        # a volume until FileVolumeArtifacts.commit() is called.
        meta = VolumeMetadata(
            self.sd_manifest.sdUUID,
            self.img_id,
            parent_vol_id,
            size / sc.BLOCK_SIZE,  # Size is stored as number of blocks
            sc.type2name(vol_format),
            sc.type2name(prealloc),
            sc.type2name(sc.LEAF_VOL),
            disk_type,
            desc,
            sc.LEGAL_VOL)
        self._oop.writeFile(self.meta_volatile_path, meta.storage_format())
Exemple #2
0
    def _create_image_artifact(self):
        self.log.debug("Creating image artifact directory: %r",
                       self.artifacts_dir)
        try:
            self._oop.os.mkdir(self.artifacts_dir)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

            # We have existing artifacts in the way.  Time to run
            # garbage collection
            raise se.DomainHasGarbage("artifacts directory exists: %r" %
                                      self.artifacts_dir)
    def _create_lv_artifact(self, parent, lv_size):
        try:
            lv = lvm.getLV(self.sd_manifest.sdUUID, self.vol_id)
        except se.LogicalVolumeDoesNotExistError:
            pass
        else:
            if sc.TEMP_VOL_LVTAG in lv.tags:
                raise se.DomainHasGarbage("Logical volume artifact %s exists" %
                                          self.vol_id)
            else:
                raise se.VolumeAlreadyExists("Logical volume %s exists" %
                                             self.vol_id)

        parent_vol_id = parent.vol_id if parent else sc.BLANK_UUID
        tags = (sc.TEMP_VOL_LVTAG,
                sc.TAG_PREFIX_PARENT + parent_vol_id,
                sc.TAG_PREFIX_IMAGE + self.img_id)
        lvm.createLV(self.sd_manifest.sdUUID, self.vol_id, lv_size,
                     activate=True, initialTags=tags)