我想通过python API订购SoftLayer的虚拟服务器。
通过以下API调用=>
client['Product_Package'].getAllObjects(mask='id, name')
我发现虚拟服务器的pkg id是46。
另外,我通过以下API调用=>
找到了价格IDclient['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)
然而,有以下alert =>
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.
你能帮我解决这个问题吗?
答案 0 :(得分:0)
问题在于,根据您选择的位置,您还需要选择该位置的价格。
价格有一个名为“locationGroup”的属性这个属性包含有关价格在哪些位置工作的信息,也是为了避免每次特定位置的特定价格必须选择softlayer有标准价格这些价格工作对于任何地点,为了获得这些价格,您需要查找“locationGroupId”为空的价格。
请查看此文档:
http://sldn.softlayer.com/blog/cmporter/location-based-pricing-and-you