2016-12-14 13 views
1

我創建了一個圖像模板,並且想要使用此模板創建一個虛擬服務器。我可以在WEB GUI上執行此操作。對於rest API,我看到operatingSystemReferenceCode用於創建虛擬服務器。我認爲operatingSystemReferenceCode與圖像模板不同。如何使用標準模板柔性層使用rest api創建虛擬服務器?

我想知道在使用圖像模板創建虛擬服務器時使用哪個api,並且非常高興給出一個示例。謝謝!

回答

1

那麼最簡單的方法是使用CreateObject方法,該方法可以傳遞你想使用更多信息,圖像看到:

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject

你只需要配置在該屬性請求:

enter image description here

這裏一個RESTful例如:

POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/createObject 有效載荷:

{ 
"parameters":[ 
    { 
     "hostname": "host1", 
     "domain": "example.com", 
     "startCpus": 1, 
     "maxMemory": 1024, 
     "hourlyBillingFlag": true, 
     "localDiskFlag": true, 
     "datacenter": { 
      "name": "dal05" 
     } 
     "blockDeviceTemplateGroup": { 
      "globalIdentifier": "07beadaa-1e11-476e-a188-3f7795feb9fb" 
     } 
    } 
] 
} 

可能你想知道如何得到你想要使用的tamplate的globalIdentifier,也有兩種類型的圖像模板:私人和公共。

http://sldn.softlayer.com/reference/services/SoftLayer_Account/getBlockDeviceTemplateGroups

在另一隻手的公共模板可以用這種方法獲取:

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getPublicImages

私人模板(您創建的那些)可以用這種方法來獲取

我希望它能幫到你

Regards

+0

你的回答非常詳細,真的很感謝!我還有一個關於softlayer rest api的問題。在創建虛擬服務器之後,我想要獲取此虛擬服務器的ID。目前我使用'https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests'來查找所有虛擬服務器信息,然後找到所需的ID。我想,如果有一種簡單的方法通過此虛擬服務器的主機名或通過其他方法獲取ID。希望你能提供答案。謝謝! – Hengguo

+0

當您使用我發佈的方法訂購虛擬訪客時,執行結果將返回新創建的VSI的ID,因此您無需使用getVirtualGuests方法。另外,您可能想知道如何知道服務器何時開通。我推薦您查看這些帖子http://sldn.softlayer.com/blog/phil/simplified-cci-creation http://sldn.softlayer.com/blog/phil/getting-started-ccis –

+0

你也可以使用objectFilters來獲得VSI,你正在尋找請求應該是這樣的:https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests ?objectFilter = {「virtualGuests」:{「hostname」:{「operation」:「myHostnameI want」}}}有關objectFilters的更多信息,請參閱http://sldn.softlayer.com/article/object-filters –

相關問題