通过SoftLayer API订购云服务器

通过SoftLayer API订购云服务器,api,ibm-cloud-infrastructure,Api,Ibm Cloud Infrastructure,我想通过python API订购SoftLayer的虚拟服务器 通过以下API调用=> client['Product_Package'].getAllObjects(mask='id, name') client['Product_Package'].getItemPrices(id=46, mask='id, itemId, recurringFee, hourlyRecurringFee, item.description, item.keyName, categories.id')`

我想通过python API订购SoftLayer的虚拟服务器

通过以下API调用=>

client['Product_Package'].getAllObjects(mask='id, name')
client['Product_Package'].getItemPrices(id=46, mask='id, itemId, recurringFee, hourlyRecurringFee, item.description, item.keyName, categories.id')`
我发现虚拟服务器的pkg id是46

另外,我通过以下API调用找到了prices id=>

client['Product_Package'].getAllObjects(mask='id, name')
client['Product_Package'].getItemPrices(id=46, mask='id, itemId, recurringFee, hourlyRecurringFee, item.description, item.keyName, categories.id')`
订购代码如下=>

order = {
    'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
    'quantity': 1,
    'virtualGuests': [
        {'hostname': 'test-template', 'domain': 'example.com'}
    ],
    'location': 449604,  # Tokyo
    'packageId': 46,  # CCI Package
    'prices': [
        {'id':34183},  # 1000 GB Bandwidth
        {'id':112483},  # 1 x 2.0 GHz Core
        {'id':32578},  # 25 GB (SAN)
        {'id':27023},  # Host Ping Monitoring
        {'id':32500},  # Email and Ticket Notifications
        {'id':31985},  # CentOS 5 - Minimal Install (32 bit)
        {'id':27052},  # 10 Mbps Private Networks
        {'id':34807},  # 1 IP Address
        {'id':112985},  # 1 GB RAM
        {'id':23070},  # Reboot / Remote Console
        {'id':32627},  # Automated Notification Response
        {'id':35310},  # Nessus Vulnerability Assessment & Reporting
        {'id':33483},  # Unlimited SSL VPN Users & 1 PPTP VPN User per account
    ],
    'imageTemplateId': templateId
}
client['SoftLayer_Product_Order'].verifyOrder(order)
但是,出现以下警报=>

Traceback (most recent call last):
  File "./ordervsByimg.py", line 45, in <module>
    result = client['SoftLayer_Product_Order'].verifyOrder(order)
  File "/usr/lib64/python2.7/site-packages/SoftLayer/API.py", line 392, in call_handler
    return self(name, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/SoftLayer/API.py", line 360, in call
    return self.client.call(self.name, name, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/SoftLayer/API.py", line 263, in call
    return self.transport(request)
  File "/usr/lib64/python2.7/site-packages/SoftLayer/transports.py", line 195, in __call__
    raise _ex(ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Public): The price for 1 x 2.0 GHz Core (#112483) is not valid for location tok02.
回溯(最近一次呼叫最后一次):
文件“/ordervsByimg.py”,第45行,在
结果=客户端['SoftLayer\u Product\u Order']。验证订单(订单)
文件“/usr/lib64/python2.7/site packages/SoftLayer/API.py”,第392行,在call\u处理程序中
返回自我(名称,*args,**kwargs)
文件“/usr/lib64/python2.7/site packages/SoftLayer/API.py”,第360行,调用中
返回self.client.call(self.name,name,*args,**kwargs)
文件“/usr/lib64/python2.7/site packages/SoftLayer/API.py”,第263行,在调用中
返回自动传输(请求)
文件“/usr/lib64/python2.7/site packages/SoftLayer/transports.py”,第195行,在调用中__
raise_ex(ex.faultCode,ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError:SoftLayerAPIError(SoftLayer_Exception_Public):1 x 2.0 GHz内核(#112483)的价格对位置tok02无效。

您能帮我解决这个问题吗?

问题是,根据您选择的位置,您还需要选择该位置的价格

价格具有一个名为“locationGroup”的属性此属性包含有关价格在哪些位置有效的信息,也为了避免每次都必须为特定位置选择特定价格,软件层具有标准价格这些价格适用于任何位置,为了获得这些价格,您需要查找“locationGroupId”为空的价格

请参阅有关以下内容的文档: