Performance storage We are selecting Storage size

2019-03-05 06:33发布

问题:

I am working on performance storage. When I am selecting Storage Size 250/500 then no data In IOPS. When I was select storage size 100/20/80/1000/2000gb then I am getting IOPS. I am facing problem only 250/500gb. this is the API i am using

https://[username]:[apikey]@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/222/getItemPrices?objectFilter={"itemPrices": { "attributes": { "value": { "operation": 20 } },  "categories": { "categoryCode": {    "operation": "performance_storage_iops" } },    "locationGroupId": {    "operation": "is null" } } }

I am sending screenshot when i was select storage size 50/500gb what I am getting response. So could you kindly provide the information to me.

回答1:

I already answered this here, If you see the result you will notice that it contains "capacityRestrictionMinimum" and "capacityRestrictionMaximum" that means that those IOPS are valid for storage size from 100 to 1000. if do not believe me (I think that is the case) try using those IOPS in an order using the verifyOrder method.



回答2:

As I understand, you want to retrieve IOPS item prices according the storage size, aren't you?

If that is the case, there is not possible retrieve these kind of data using REST, because we need to apply a filter with a range between "capacityRestrictionMaximum" and "capacityRestrictionMinimum". These data are returned as String datatype, and it's not possible to apply a filter between integers (storage type) and strings.

However, this can be possible using a programming language, try the following Python script:

"""
This script retrieves performance storage iops per Storage Size

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices
http://sldn.softlayer.com/article/object-filters

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer

# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'

# Define Package Id
packageId = 222

# Define the Storage Size
storageGb = 250

# Define an object filter, to retrieve performance_storage_iops category 
objectFilter = {'itemPrices':{'categories': {'categoryCode':{'operation':'performance_storage_iops'}}, 'locationGroupId': { 'operation': 'is null' }}}

# Create a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

try:
    prices = client['Product_Package'].getItemPrices(id=packageId, filter=objectFilter, mask='mask[categories]')
    for price in prices:
        if (storageGb <= int(price['capacityRestrictionMaximum']) and storageGb >= int(price['capacityRestrictionMinimum'])):
            # print (price)
            print('Price Id: %s Item Id: %s IOPS: %s' % (price['id'], price['item']['id'], price['item']['description']))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to retrieve IOPSr faultCode=%s, faultString=%s"
          % (e.faultCode, e.faultString))
    exit(1)

See the following link, to get more information about programming languages supported by SoftLayer:

http://sldn.softlayer.com/

I hope it really helps you



回答3:

Using “SoftLayer_Product_Package::getItemPrices” with some objectFilters and objectMasks’, we can get some information to get valid“IOPS”according to“Storage Space”`.

The "attributes" property will show you a range of capacity of "GB Storage Space" (minimum/maximum "GB" supported), but not a specific value like "250/500GB".

We execute the below request to get valid “IOPS” according to “Storage Space”:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Package/222/getItemPrices?objectMask=mask[id,item[keyName,description],pricingLocationGroup[locations[id, name, longName]],categories.categoryCode,attributes[itemPriceAttributeType.keyname,value]]&objectFilter={   "itemPrices": {     "item": {       "description": {         "operation": "1200 IOPS"       }     },     "categories": {       "categoryCode": {         "operation": "performance_storage_iops"       }     },     "locationGroupId": {       "operation": "is null"     }   } }

Method: GET

The response will display an amount of items. But, what of them do we have to choose?

In my response, the price_id to select is this one:

{
    "id": 41608,
    "attributes": [
      {
        "value": "100",
        "itemPriceAttributeType": {
          "keyname": "CAPACITY_RESTRICTION_MIN"
        }
      },
      {
        "value": "1000",
        "itemPriceAttributeType": {
          "keyname": "CAPACITY_RESTRICTION_MAX"
        }
      },
      {
        "value": "STORAGE_SPACE",
        "itemPriceAttributeType": {
          "keyname": "CAPACITY_RESTRICTION_TYPE"
        }
      }
    ],
    "categories": [
      {
        "categoryCode": "performance_storage_iops"
      }
    ],
    "item": {
      "description": "1200 IOPS",
      "keyName": "1200_IOPS_3"
    }
  }

Why?

Because, the item with "description:1200 IOPS", is into range[100 - 1000 GB STORAGE_SPACE]. In our case the configuration is: “Storage Size: 500GB”

I hope this information help you.