Ejemplo n.º 1
0
    def throttle(self, sdc_id=None, sdc_guid=None, iops=None, mbps=None):
        """Throttles I/O on current volume.

        :param iops: I/O operations in seconds (> 10)
        :param mbps: network bandwidth as megabytes in seconds
        """

        if sdc_id and sdc_guid:
            raise exceptions.ScaleIONotBothParameters("sdc_id", "sdc_guid")

        if iops is None and mbps is None:
            raise exceptions.ScaleIORequiredParameters("iops", "mbps")

        if iops is not None and iops != 0 and iops <= 10:
            raise exceptions.ScaleIOInvalidLimit("iops", "must be greater than 10.")

        if mbps is not None:
            mbps = mbps * constants.KILOBYTE
            if bool(mbps % constants.KILOBYTE):
                raise exceptions.ScaleIOInvalidLimit("mbps", "must be granular to 1024 Kbps")

        data = {}
        if sdc_id:
            data["sdcId"] = sdc_id
        if sdc_guid:
            data["guid"] = sdc_guid
        if iops is not None:
            data["iopsLimit"] = str(iops)
        if mbps is not None:
            data["bandwidthLimitInKbps"] = str(mbps)

        return super(Volume, self).perform("setMappedSdcLimits", data)
Ejemplo n.º 2
0
    def __init__(self, client, instance_id=None, instance=None):
        self._client = client
        self._scheme = {}

        if instance_id and instance:
            raise exceptions.ScaleIONotBothParameters("instance_id", "instance")

        if instance_id:
            instance = self._client.get_instance_of(self._get_name(), instance_id)

        self._instance = self._validate(instance or {})
Ejemplo n.º 3
0
def _get_client(kwargs):
    """
    Returns ScaleIOClient instance by specified kwargs.
    Attention: for internal use only!
    """

    host, client = kwargs.pop("host", None), kwargs.pop("client", None)
    if host and client:
        raise exceptions.ScaleIONotBothParameters("host", "client")

    if client:
        if not isinstance(client, ScaleIOClient):
            raise exceptions.ScaleIOInvalidClient()
        return client
    else:
        return pyscaleio.get_client(host)
Ejemplo n.º 4
0
    def unexport(self, sdc_id=None, sdc_guid=None):
        """Unexports volume from specified SDC.
        Without parameters unexports volume from all SDCs

        :param sdc_id: id of SDC instance
        :param sdc_guid: guid if SDC instance
        """

        if sdc_id and sdc_guid:
            raise exceptions.ScaleIONotBothParameters("sdc_id", "sdc_guid")

        data = {}
        if sdc_id:
            data["sdcId"] = sdc_id
        elif sdc_guid:
            data["guid"] = sdc_guid
        else:
            data["allSdcs"] = ""

        return super(Volume, self).perform("removeMappedSdc", data)
Ejemplo n.º 5
0
    def export(self, sdc_id=None, sdc_guid=None, multiple=False):
        """Exports volume to specified SDC.

        :param sdc_id: id of SDC instance
        :param sdc_guid: guid of SDC instance
        :param multiple: allows export to multiple SDCs (optional)
        """

        if sdc_id and sdc_guid:
            raise exceptions.ScaleIONotBothParameters("sdc_id", "sdc_guid")

        data = {}
        if sdc_id:
            data["sdcId"] = sdc_id
        if sdc_guid:
            data["guid"] = sdc_guid

        if multiple:
            data["allowMultipleMappings"] = utils.bool_to_str(multiple)

        return super(Volume, self).perform("addMappedSdc", data)