一直在引用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
}
]
}]
}
但是,我还希望设置有限的公共带宽,类似于Web界面上显示的选项。阅读network component structure以及上面引用的创建对象调用,我无法解密选择特定带宽的字段。
我也没有提到getCreateObjectOptions中的带宽选项。任何帮助都会很棒。
答案 0 :(得分:0)
使用此方法显示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 Public&私人网络上行链路"如果您想在订单中配置该项目,则需要遵循"模板"在这种情况下,它表示您需要添加以下配置:
"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false
它就是这样,但是createObject方法有一个缺点,你只能配置getCreateObjectOptions方法显示的选项,但是portal提供了许多其他使用createObject方法不可用的选项。如果您需要高级选项来订购,您需要使用placeOrder方法,本文可以帮助您进行placeOrder方法:
https://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-3
此致
答案 1 :(得分:0)
此处为后代添加此内容。
这是一个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:
包ID - 从SoftLayer_Product_Package->getAllObjects获取 - 它是字段“id”
价格ID - 从SoftLayer_Product_Package->getItemPrices获得 - 再一次是字段ID(注意有几个地方使用相同的字段名称)。这列出了可以进入虚拟机的所有可能配置。上面的JSON选择了一些选项。
最后使用JSON模板,可以验证并放置订单。
(PS:仅使用虚拟机命令对此进行了测试.SSH密钥ID是一个示例,应替换为有效ID。)