如何在软层上创建云对象存储?
How to create cloud object storage on softlayer?
我想使用 python API 创建云对象存储并参考 link https://sldn.softlayer.com/blog/waelriac/managing-softlayer-object-storage-through-rest-apis。
当我用下面命令命令CLOUD_OBJECT_STORAGE时,提示错误。我是否遗漏了某些配置或提供了错误的配置?
payload = '{"parameters" : [{"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Hub", "quantity": 1, "packageId": 206, "prices": [{"id": 177725}]}]}'
client['SoftLayer_Product_Order'].placeOrder(payload)
client['SoftLayer_Product_Order'].placeOrder(payload)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 392, in call_handler
return self(name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 360, in call
return self.client.call(self.name, name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 263, in call
return self.transport(request)
File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 195, in call
raise _ex(ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Order_InvalidContainer): Invalid container specified: SoftLayer_Container_Product_Order. Ordering a server or service requires a specific container type, not the generic base order container.
好吧,为了使用 Soflayer 的 Python 客户端调用 Softlayer 的 API 方法,请求与 REST 请求不同,我建议您查看文档以获取更多信息。
这是您需要使用的代码:
import SoftLayer
USERNAME="set me"
APIKEY="set me"
client = SoftLayer.create_client_from_env(
username=USERNAME,
api_key=APIKEY
)
order = {
"quantity": 1,
"packageId": 206,
"prices": [{
"id": 177725
}]
}
result = client['SoftLayer_Product_Order'].verifyOrder(order)
print (result)
另一点要指出的是,您需要确保您使用的是正确的价格,每个帐户的价格可能不同,所以为了确保您使用的是正确的价格,我建议您调用 SoftLayer_Product_Package:getItemPrices
使用 Python 使用这个:
result = client['SoftLayer_Product_Package'].getItemPrices(id=206)
print (result)
此致
我想使用 python API 创建云对象存储并参考 link https://sldn.softlayer.com/blog/waelriac/managing-softlayer-object-storage-through-rest-apis。 当我用下面命令命令CLOUD_OBJECT_STORAGE时,提示错误。我是否遗漏了某些配置或提供了错误的配置?
payload = '{"parameters" : [{"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Hub", "quantity": 1, "packageId": 206, "prices": [{"id": 177725}]}]}'
client['SoftLayer_Product_Order'].placeOrder(payload)
client['SoftLayer_Product_Order'].placeOrder(payload) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 392, in call_handler return self(name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 360, in call return self.client.call(self.name, name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 263, in call return self.transport(request) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 195, in call raise _ex(ex.faultCode, ex.faultString) SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Order_InvalidContainer): Invalid container specified: SoftLayer_Container_Product_Order. Ordering a server or service requires a specific container type, not the generic base order container.
好吧,为了使用 Soflayer 的 Python 客户端调用 Softlayer 的 API 方法,请求与 REST 请求不同,我建议您查看文档以获取更多信息。
这是您需要使用的代码:
import SoftLayer
USERNAME="set me"
APIKEY="set me"
client = SoftLayer.create_client_from_env(
username=USERNAME,
api_key=APIKEY
)
order = {
"quantity": 1,
"packageId": 206,
"prices": [{
"id": 177725
}]
}
result = client['SoftLayer_Product_Order'].verifyOrder(order)
print (result)
另一点要指出的是,您需要确保您使用的是正确的价格,每个帐户的价格可能不同,所以为了确保您使用的是正确的价格,我建议您调用 SoftLayer_Product_Package:getItemPrices
使用 Python 使用这个:
result = client['SoftLayer_Product_Package'].getItemPrices(id=206)
print (result)
此致