创建对象网络组件



一直在引用createObject API,作为订购虚拟机请求的一部分,我想为该机器配置公共和私有接口。以下是工作的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
}
]
}]
}

然而,我也想设置一个有限的公共带宽,类似于网络界面上的选项。读取网络组件结构以及上述创建对象调用时,我无法破译用于选择特定带宽的字段。

我在getCreateObjectOptions中也没有提到带宽选项。任何帮助都会很棒。

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中,你可以看到项目"10Mbps公共和专用网络上行链路"。如果你想按顺序配置该项目,你需要遵循"模板"配置。在这种情况下,它说你需要添加以下配置:

"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false

仅此而已,但是createObject方法有一个缺点,您只能配置方法getCreateObjectOptions显示的选项,但门户提供了许多其他选项,这些选项使用createObject方法是不可用的。如果你现在需要高级选项来订购,你需要使用placeOrder方法,本文可以帮助你了解placeOrder方法:

https://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-3

问候

在此处添加此内容以供后人使用。

这里有一个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:

  1. 包id-从SoftLayer_Product_package->getAllObjects获得-它是字段"id">

  2. price id-从SoftLayer_Product_Package->getItemPrices获得-再次是字段id(请注意,有几个地方使用了相同的字段名称)。这列出了可以进入虚拟机的所有可能配置。上面的JSON选择了一些选项。

最后使用JSON模板,可以验证和下订单。

(附言:我只在虚拟机订单中测试过这一点。SSH密钥ID就是一个例子,应该用有效的ID替换。)

最新更新