コード例 #1
0
    def volume_set(self,
                   vol_name,
                   options=None,
                   advance=False,
                   experimental=False,
                   deprecated=False):
        """
        Start Gluster Volume.

        :param vol_name: (string) Volume Name
        :param options: (dict) options to set on volume
        :param advance: (bool) advance flag to set options
        :param experimental: (bool) experimental flag to set options
        :param deprecated: (bool) deprecated flag to set options
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(vol_name)

        if options is None:
            raise GlusterApiInvalidInputs("cannot set empty options")

        vol_options = dict()
        req = dict()
        for key in options:
            vol_options[key] = options[key]
        req['options'] = vol_options
        req['advanced'] = advance
        req['experimental'] = experimental
        req['deprecated'] = deprecated
        return self._handle_request(self._post, httplib.OK,
                                    "/v1/volumes/%s/options" % vol_name,
                                    json.dumps(req))
コード例 #2
0
    def snapshot_create(self,
                        volume_name,
                        snap_name,
                        timestamp=False,
                        description="",
                        force=False):
        """
        Gluster snapshot create.

        :param volume_name: (string) volume name
        :param snap_name: (string) snapshot name
        :param timestamp: (bool)  timestamp for snapshot
        :param description: (string) snapshot description
         :param force: (bool)  force create snapshot
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(volume_name)
        validate_snap_name(snap_name)

        req = {
            "volname": volume_name,
            "snapname": snap_name,
            "timestamp": timestamp,
            "description": description,
            "force": force
        }
        return self._handle_request(self._post, httplib.CREATED,
                                    "/v1/snapshot", json.dumps(req))
コード例 #3
0
    def volume_get(self, vol_name, options=None):
        """
        Get Gluster Volume Options.

        :param vol_name: (string) Volume Name
        :param options: (dict) get volumes based on options
        :raises: GlusterAPIError on failure
        """
        validate_volume_name(vol_name)
コード例 #4
0
    def volume_reset(self, vol_name, options=None):
        """
        Start Gluster Volume.

        :param vol_name: (string) Volume Name
        :param options: (dict) options to set on volume
        :raises: GlusterAPIError or failure
        """
        validate_volume_name(vol_name)
コード例 #5
0
    def snapshot_list(self, vol_name):
        """
        Gluster list snapshot.

        :param vol_name: (string) volume  name
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(vol_name)
        # TODO need to be implemented
        pass
コード例 #6
0
    def volume_status(self, vol_name):
        """
        Gluster Volume Status.

        :param vol_name: (string) Volume Name
        :raises: GlusterAPIError on failure
        """
        validate_volume_name(vol_name)

        return self._handle_request(self._get, httplib.OK,
                                    '/v1/volumes/%s/status' % vol_name)
コード例 #7
0
    def volume_delete(self, vol_name):
        """
        Start Gluster Volume.

        :param vol_name: (string) Volume Name
        :raises: GlusterAPIError or failure
        """
        validate_volume_name(vol_name)

        return self._handle_request(self._delete, httplib.NO_CONTENT,
                                    "/v1/volumes/%s" % vol_name, None)
コード例 #8
0
    def volume_stop(self, vol_name):
        """
        Start Gluster Volume.

        :param vol_name: (string) Volume Name
        :raises: GlusterAPIError or failure
        """
        validate_volume_name(vol_name)

        return self._handle_request(self._post, httplib.OK,
                                    "/v1/volumes/%s/stop" % vol_name, None)
コード例 #9
0
    def bitrot_enable(self, volume):
        """
        Gluster enable bitrot for a volume.

        :param volume: (string) volume name
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(volume)

        return self._handle_request(self._post, httplib.OK,
                                    "/v1/volumes/%s/bitrot/enable" % volume,
                                    None)
コード例 #10
0
    def bitrot_scrub_status(self, volume):
        """
        Gluster get bitrot scrub status of a volume.

        :param volume: (string) volume name
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(volume)

        return self._handle_request(
            self._post, httplib.OK,
            "/v1/volumes/%s/bitrot/scrubstatus" % volume, None)
コード例 #11
0
    def bitrot_scrub(self, volume):
        """
        Gluster starts bitrot scrubber on demand for a volume.

        :param volume: (string) volume name
        :raises: GlusterApiError or GlusterApiInvalidInputs on failure
        """
        validate_volume_name(volume)

        return self._handle_request(
            self._post, httplib.OK,
            "/v1/volumes/%s/bitrot/scrubondemand" % volume, None)
コード例 #12
0
    def volume_restart(self, vol_name, force=False):
        """
        Restart Gluster Volume.

        :param vol_name: (string) Volume Name
        :param force: (bool) Restart the Volume with Force
        :raises: GlusterAPIError or failure
        """
        validate_volume_name(vol_name)

        self.volume_stop(vol_name)
        return self.volume_start(vol_name, force)
コード例 #13
0
    def volume_start(self, vol_name, force=False):
        """
        Start Gluster Volume.

        :param vol_name: (string) Volume Name
        :param force: (bool) Start Volume with Force
        :raises: GlusterAPIError or failure
        """
        validate_volume_name(vol_name)

        data = {"force-start-bricks": force}
        return self._handle_request(self._post,
                                    httplib.OK,
                                    "/v1/volumes/%s/start" % vol_name,
                                    data=json.dumps(data))
コード例 #14
0
    def volume_list(self, vol_name=None, key=None, value=None):
        """
        Get Volume list.

        :param vol_name: (string) volume name
        :param key: (string) key to filter volumes
        :param value: (string) value to filter volumes
        :raises: GlusterAPIError on failure
        """
        url = "/v1/volumes"
        param = {}
        if vol_name is None:
            if key:
                param['key'] = key
            if value:
                param['value'] = value
        else:
            validate_volume_name(vol_name)
            url = url + "/" + vol_name

        return self._handle_request(self._get, httplib.OK, url, param=param)