def create(self,
               media_type,
               protection_domain_id,
               checksum_enabled=None,
               compression_method=None,
               data_layout=None,
               external_acceleration_type=None,
               fgl_accp_id=None,
               name=None,
               rmcache_write_handling_mode=None,
               spare_percentage=None,
               use_rfcache=None,
               use_rmcache=None,
               zero_padding_enabled=None):
        """Create PowerFlex storage pool.

        :param media_type: one of predefined attributes of MediaType
        :type media_type: str
        :type protection_domain_id: str
        :type checksum_enabled: bool
        :param compression_method: one of predefined attributes of
                                   CompressionMethod
        :type compression_method: str
        :param data_layout: one of predefined attributes of DataLayout
        :type data_layout: str
        :param external_acceleration_type: one of predefined attributes of
                                           ExternalAccelerationType
        :type external_acceleration_type: str
        :type fgl_accp_id: str
        :type name: str
        :param rmcache_write_handling_mode: one of predefined attributes of
                                            RmcacheWriteHandlingMode
        :type spare_percentage: int
        :type use_rfcache: bool
        :type use_rmcache: bool
        :type zero_padding_enabled: bool
        :rtype: dict
        """

        if data_layout == DataLayout.fine and not fgl_accp_id:
            msg = 'fgl_accp_id must be set for Fine Granular Storage Pool.'
            raise exceptions.InvalidInput(msg)
        params = dict(
            mediaType=media_type,
            protectionDomainId=protection_domain_id,
            checksumEnabled=checksum_enabled,
            compressionMethod=compression_method,
            dataLayout=data_layout,
            externalAccelerationType=external_acceleration_type,
            fglAccpId=fgl_accp_id,
            name=name,
            rmcacheWriteHandlingMode=rmcache_write_handling_mode,
            sparePercentage=spare_percentage,
            useRfcache=use_rfcache,
            useRmcache=use_rmcache,
            zeroPaddingEnabled=zero_padding_enabled
        )

        return self._create_entity(params)
示例#2
0
    def remove_mapped_sdc(self,
                          volume_id,
                          sdc_id=None,
                          sdc_guid=None,
                          all_sdcs=None,
                          skip_appliance_validation=None,
                          allow_ext_managed=None):
        """Unmap PowerFlex volume from SDC.

        :param volume_id: str
        :param sdc_id: str
        :param sdc_guid: str
        :param all_sdcs: bool
        :param skip_appliance_validation: bool
        :param allow_ext_managed: bool
        :return: dict
        """

        action = 'removeMappedSdc'

        if (
                all([sdc_id, sdc_guid, all_sdcs]) or
                not any([sdc_id, sdc_guid, all_sdcs])
        ):
            msg = 'Either sdc_id or sdc_guid or all_sdcs must be set.'
            raise exceptions.InvalidInput(msg)

        params = dict(
            sdcId=sdc_id,
            guid=sdc_guid,
            allSdcs=all_sdcs,
            skipApplianceValidation=skip_appliance_validation,
            allowOnExtManagedVol=allow_ext_managed
        )

        r, response = self.send_post_request(self.base_action_url,
                                             action=action,
                                             entity=self.entity,
                                             entity_id=volume_id,
                                             params=params)
        if r.status_code != requests.codes.ok:
            msg = ('Failed to unmap PowerFlex {entity} with id {_id} '
                   'from SDC.'.format(entity=self.entity, _id=volume_id))
            LOG.error(msg)
            raise exceptions.PowerFlexClientException(msg)

        return self.get(entity_id=volume_id)
    def set_external_acceleration_type(
            self,
            storage_pool_id,
            external_acceleration_type,
            override_device_configuration=None,
            keep_device_ext_acceleration=None
    ):
        """Set external acceleration type for PowerFlex storage pool.

        :type storage_pool_id: str
        :param external_acceleration_type: one of predefined attributes of
                                           ExternalAccelerationType
        :type external_acceleration_type: str
        :type override_device_configuration: bool
        :type keep_device_ext_acceleration: bool
        :rtype: dict
        """

        action = 'setExternalAccelerationType'

        if all([override_device_configuration, keep_device_ext_acceleration]):
            msg = ('Either override_device_configuration or '
                   'keep_device_specific_external_acceleration can be set.')
            raise exceptions.InvalidInput(msg)
        params = dict(
            externalAccelerationType=external_acceleration_type,
            overrideDeviceConfiguration=override_device_configuration,
            keepDeviceSpecificExternalAcceleration=keep_device_ext_acceleration
        )

        r, response = self.send_post_request(self.base_action_url,
                                             action=action,
                                             entity=self.entity,
                                             entity_id=storage_pool_id,
                                             params=params)
        if r.status_code != requests.codes.ok:
            msg = ('Failed to set external acceleration type for PowerFlex '
                   '{entity} with id {_id}.'.format(entity=self.entity,
                                                    _id=storage_pool_id))
            LOG.error(msg)
            raise exceptions.PowerFlexClientException(msg)

        return self.get(entity_id=storage_pool_id)
示例#4
0
    def add_mapped_sdc(self,
                       volume_id,
                       sdc_id=None,
                       sdc_guid=None,
                       allow_multiple_mappings=None,
                       allow_ext_managed=None,
                       access_mode=None):
        """Map PowerFlex volume to SDC.

        :param volume_id: str
        :param sdc_id: str
        :param sdc_guid: str
        :param allow_multiple_mappings: bool
        :param allow_ext_managed: bool
        :type access_mode: str
        :return: dict
        """

        action = 'addMappedSdc'

        if all([sdc_id, sdc_guid]) or not any([sdc_id, sdc_guid]):
            msg = 'Either sdc_id or sdc_guid must be set.'
            raise exceptions.InvalidInput(msg)
        params = dict(sdcId=sdc_id,
                      guid=sdc_guid,
                      allowMultipleMappings=allow_multiple_mappings,
                      allowOnExtManagedVol=allow_ext_managed,
                      accessMode=access_mode)

        r, response = self.send_post_request(self.base_action_url,
                                             action=action,
                                             entity=self.entity,
                                             entity_id=volume_id,
                                             params=params)
        if r.status_code != requests.codes.ok:
            msg = ('Failed to map PowerFlex {entity} with id {_id} '
                   'to SDC. Error: {response}'.format(entity=self.entity,
                                                      _id=volume_id,
                                                      response=response))
            LOG.error(msg)
            raise exceptions.PowerFlexClientException(msg)

        return self.get(entity_id=volume_id)
示例#5
0
    def create(self,
               current_pathname,
               sds_id,
               acceleration_pool_id=None,
               external_acceleration_type=None,
               force=None,
               media_type=None,
               name=None,
               storage_pool_id=None):
        """Create PowerFlex device.

        :type current_pathname: str
        :type sds_id: str
        :type acceleration_pool_id: str
        :param external_acceleration_type: one of predefined attributes of
                                           ExternalAccelerationType
        :type external_acceleration_type: str
        :type force: bool
        :param media_type: one of predefined attributes of MediaType
        :type media_type: str
        :type name: str
        :type storage_pool_id: str
        :rtype: dict
        """

        if (all([storage_pool_id, acceleration_pool_id])
                or not any([storage_pool_id, acceleration_pool_id])):
            msg = 'Either storage_pool_id or acceleration_pool_id must be ' \
                  'set.'
            raise exceptions.InvalidInput(msg)

        params = dict(deviceCurrentPathname=current_pathname,
                      sdsId=sds_id,
                      accelerationPoolId=acceleration_pool_id,
                      externalAccelerationType=external_acceleration_type,
                      forceDeviceTakeover=force,
                      mediaType=media_type,
                      name=name,
                      storagePoolId=storage_pool_id)

        return self._create_entity(params)
示例#6
0
    def get(self, entity_id=None, filter_fields=None, fields=None):
        url = self.base_entity_list_or_create_url
        url_params = dict(entity=self.entity)

        if entity_id:
            url = self.base_entity_url
            url_params['entity_id'] = entity_id
            if filter_fields:
                msg = 'Can not apply filtering while querying entity by id.'
                raise exceptions.InvalidInput(msg)

        r, response = self.send_get_request(url, **url_params)
        if r.status_code != requests.codes.ok:
            exc = exceptions.PowerFlexFailQuerying(self.entity, entity_id)
            LOG.error(exc.message)
            raise exc
        if filter_fields:
            response = utils.filter_response(response, filter_fields)
        if fields:
            response = utils.query_response_fields(response, fields)
        return response
    def create(self,
               media_type,
               protection_domain_id,
               name=None,
               isRfcache=None):
        """Create PowerFlex acceleration pool.

        :param media_type: one of predefined attributes of MediaType
        :type media_type: str
        :type protection_domain_id: str
        :type name: str
        :type isRfcache: bool
        :rtype: dict
        """

        if media_type == MediaType.ssd and not isRfcache:
            msg = 'isRfcache must be set for media_type SSD.'
            raise exceptions.InvalidInput(msg)
        params = dict(mediaType=media_type,
                      protectionDomainId=protection_domain_id,
                      name=name,
                      isRfcache=isRfcache)

        return self._create_entity(params)