首页 文章

如何在softlayer上创建 Cloud 对象存储?

提问于
浏览
0

我想使用python API创建 Cloud 对象存储,并引用链接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,“price”:[{“id”:177725}]}]}'client [ 'SoftLayer_Product_Order'] .placeOrder(payload)client ['SoftLayer_Product_Order'] . placeOrder(payload)Traceback(最近一次调用last):文件“”,第1行,在文件“/usr/local/lib/python2.7/dist中-packages / SoftLayer / API.py“,第392行,在call_handler中返回self(name,* args,** kwargs)文件”/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py“ ,第360行,在调用返回self.client.call(self.name,name,* args,** kwargs)文件“/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py”,第263行,在调用return self.transport(request)文件“/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py”,第195行,在call raise _ex中(ex.faultCode,ex . faultString)SoftLayer.exceptions.SoftLayerAPIError:SoftLayerAPIError(SoftLayer_Exception_Order_InvalidContainer):指定的容器无效:SoftLayer_Container_Product_Ord呃 . 订购服务器或服务需要特定的容器类型,而不是通用的基本订单容器 .

1 回答

  • 0

    为了使用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)
    

    问候

相关问题