Exemple #1
0
    def _cmd_fs_subvolume_rm(self, inbuf, cmd):
        vol_name = cmd['vol_name']
        sub_name = cmd['sub_name']

        fs = self._volume_get_fs(vol_name)
        if fs is None:
            return 0, "", "Volume '{0}' already deleted".format(vol_name)

        vol_fscid = fs['id']

        with CephFSVolumeClient(rados=self.rados) as vc:
            # TODO: support real subvolume groups rather than just
            # always having them 1:1 with subvolumes.
            vp = VolumePath(sub_name, sub_name)

            vc.delete_volume(vp)

        # TODO: create a progress event
        self._background_jobs.put(PurgeJob(vol_fscid, vp))

        return 0, "", ""
Exemple #2
0
    def _cmd_fs_subvolume_create(self, inbuf, cmd):
        vol_name = cmd['vol_name']
        sub_name = cmd['sub_name']

        size = cmd.get('size', None)

        if not self._volume_exists(vol_name):
            return -errno.ENOENT, "", \
                   "Volume not found, create it with `ceph volume create` " \
                   "before trying to create subvolumes"

        # TODO: validate that subvol size fits in volume size

        with CephFSVolumeClient(rados=self.rados) as vc:
            # TODO: support real subvolume groups rather than just
            # always having them 1:1 with subvolumes.
            vp = VolumePath(sub_name, sub_name)

            vc.create_volume(vp, size)

        return 0, "", ""