2016-10-05 7 views
0

カスタム画像テンプレートを使用してソフトレイヤーVMを作成しました。私はカールを使用して私のVMにSANディスクを追加することができますが、私はPython SoftLayerライブラリでこれをしようとして失敗しています。私は、次のエラーが表示されます。ここSoftLayer Python APIのplaceOrderを使用してvmにディスクを追加する

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. 

は私のコードです:

self.client = SoftLayer.Client(username='[email protected]mail.com', api_key='key') 
console_id = 11111111 

order = { 
     "parameters": [{ 
      "virtualGuests": [{"id": console_id}], 
      "prices": [{ 
       "id": 113031, 
       "categories": [{ 
        "categoryCode": "guest_disk1", 
        "complexType": "SoftLayer_Product_Item_Category" 
       }], 
       "complexType": "SoftLayer_Product_Item_Price" 
      }, 
       { 
        "id": 112707, 
        "categories": [{ 
         "categoryCode": "guest_disk2", 
         "complexType": "SoftLayer_Product_Item_Category" 
        }], 
        "complexType": "SoftLayer_Product_Item_Price" 
       } 
      ], 
      "properties": [ 
       {"name": "NOTE_GENERAL", "value": "adding disks"}, 
       {"name": "MAINTENANCE_WINDOW", "value": "now"} 
      ], 
      "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade" 
     }] 
    } 

# response = self.client['Product_Order'].placeOrder(order, False)   
response = self.client.call('Product_Order', 'placeOrder', order) 

print response 

私は、次のcurlコマンドを実行した場合しかし、私のVMの更新が成功している:updatefileの

curl -X POST --data @updatefile https://myusername%40email%2Ecom:[email protected]/rest/v3.1/SoftLayer_Product_Order/placeOrder 

内容:

{ 
"parameters": [{ 
    "virtualGuests":[{"id":11111111}], 
    "prices": [{ 
     "id": 113031, 
     "categories": [{ 
      "categoryCode": "guest_disk1", 
      "complexType": "SoftLayer_Product_Item_Category" 
     }], 
     "complexType": "SoftLayer_Product_Item_Price" 
    }, 

    { 
     "id": 112707, 
     "categories": [{ 
      "categoryCode": "guest_disk2", 
      "complexType": "SoftLayer_Product_Item_Category" 
     }], 
     "complexType": "SoftLayer_Product_Item_Price" 
    } 
    ], 
    "properties": [ 
    {"name": "NOTE_GENERAL","value": "adding disks"}, 
    {"name": "MAINTENANCE_WINDOW","value": "now"} 
    ], 
    "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade" 
}] 
} 

私が間違っていることは何か考えていますか?

答えて

0

あなたがSoftlayerのpythonクライアントを使用しているときに、RESTfulな要求のためだけの "paramters"プロパティを指定する必要がないので、それを削除すれば動作するはずです。

これを試してみてください:

self.client = SoftLayer.Client(username='[email protected]', api_key='key') 
console_id = 11111111 

order = { 
      "virtualGuests": [{"id": console_id}], 
      "prices": [{ 
       "id": 113031, 
       "categories": [{ 
        "categoryCode": "guest_disk1", 
        "complexType": "SoftLayer_Product_Item_Category" 
       }], 
       "complexType": "SoftLayer_Product_Item_Price" 
      }, 
       { 
        "id": 112707, 
        "categories": [{ 
         "categoryCode": "guest_disk2", 
         "complexType": "SoftLayer_Product_Item_Category" 
        }], 
        "complexType": "SoftLayer_Product_Item_Price" 
       } 
      ], 
      "properties": [ 
       {"name": "NOTE_GENERAL", "value": "adding disks"}, 
       {"name": "MAINTENANCE_WINDOW", "value": "now"} 
      ], 
      "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade" 
    } 

response = self.client['Product_Order'].placeOrder(order)   


print response 

よろしく

関連する問題