我一直在提到createObject应用程序接口,作为我订购虚拟机的请求的一部分,我想为该机器配置一个公共接口和一个私有接口。以下是工作的JSON的相关部分-
{
"parameters":[{
"hostname": "hostname-test",
"domain": "domain-test",
"startCpus": 8,
"maxMemory": 16384,
"hourlyBillingFlag": true,
"operatingSystemReferenceCode": "ubuntu_14_64",
"localDiskFlag": true,
"privateNetworkOnlyFlag": false,
"networkComponents": [
{
"maxSpeed": 1000
}
]
}]
}但是,我也想设置一个有限的公共带宽,类似于web界面上显示的选项。读取network component structure以及上面引用的create object调用,我无法破译用于选择特定带宽的字段。
我也发现没有提到getCreateObjectOptions中的带宽选项。任何帮助都是最好的。
发布于 2017-01-31 20:39:40
使用此方法可显示createObject方法的所有可用选项:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getCreateObjectOptions
关于网络配置,上面的方法将返回如下值:
"networkComponents": [
{
"itemPrice": {
"hourlyRecurringFee": "0",
"recurringFee": "0",
"item": {
"description": "10 Mbps Public & Private Network Uplinks"
}
},
"template": {
"id": null,
"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false
}
}在上面的JSON中,您可以看到"10 Mbps公网和内网上行链路“这一项,如果您想按您的顺序配置该项,您需要按照”模板“配置,在这种情况下,您需要添加以下配置:
"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false就是这样,但是createObject方法有一个缺点,您只能配置由方法getCreateObjectOptions显示的选项,但是门户提供了许多使用createObject方法无法使用的其他选项。如果您目前需要高级选项来订购,则需要使用placeOrder方法,本文可以帮助您理解和使用placeOrder方法:
https://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-3
问候
发布于 2017-02-03 00:50:00
在这里为后人添加这一点。
这是一个JSON模板,可以作为构建其他配置的基础:
{ "parameters": [{ "imageTemplateId": null, "location": "449500", "packageId": 46, "prices": [{ "hourlyRecurringFee": ".131", "id": 30823, "recurringFee": "87", "item": { "description": "8 x 2.0 GHz Cores" } }, { "hourlyRecurringFee": ".153", "id": 29663, "recurringFee": "101.5", "item": { "description": "16 GB " } }, { "hourlyRecurringFee": "0", "id": 37204, "recurringFee": "0", "item": { "description": "Ubuntu Linux 14.04 LTS Trusty Tahr - Minimal Install (64 bit)" } }, { "hourlyRecurringFee": ".004", "id": 26466, "recurringFee": "2.9", "item": { "description": "100 GB (LOCAL)" } }, { "hourlyRecurringFee": "0", "id": 23070, "recurringFee": "0", "item": { "description": "Reboot / Remote Console" } }, { "hourlyRecurringFee": ".014", "id": 23777, "recurringFee": "5", "item": { "description": "1 Gbps Private Network Uplink" } }, { "hourlyRecurringFee": "0", "id": 34183, "item": { "description": "0 GB Bandwidth" } }, { "hourlyRecurringFee": "0", "id": 34807, "recurringFee": "0", "item": { "description": "1 IP Address" } }, { "hourlyRecurringFee": "0", "id": 27023, "recurringFee": "0", "item": { "description": "Host Ping" } }, { "hourlyRecurringFee": "0", "id": 32500, "recurringFee": "0", "item": { "description": "Email and Ticket" } }, { "hourlyRecurringFee": "0", "id": 32627, "recurringFee": "0", "item": { "description": "Automated Notification" } }, { "hourlyRecurringFee": "0", "id": 33483, "recurringFee": "0", "item": { "description": "Unlimited SSL VPN Users & 1 PPTP VPN User per account" } }, { "hourlyRecurringFee": "0", "id": 35310, "recurringFee": "0", "item": { "description": "Nessus Vulnerability Assessment & Reporting" } }], "quantity": 1, "sourceVirtualGuestId": null, "sshKeys": [{ "sshKeyIds": [ 12345 ] }], "useHourlyPricing": true, "virtualGuests": [{ "domain": "domain.test", "hostname": "hostname.test" }], "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest" }] }
所需的ID:
最后,使用JSON模板可以验证和下单。
(PS:仅使用虚拟机订单进行了测试。例如,SSH密钥ID应替换为有效的ID。)
https://stackoverflow.com/questions/41948957
复制相似问题