按照答案 How to set 10G and 20G network interface speeds on SoftLayer How to set 10G and 20G network interface speeds on SoftLayer 使用以下代码设置裸机服务器的最大速度:
var sess = session.New(userName, apiKey, endpoint)
order := datatypes.Container_Product_Order{
ComplexType: sl.String("SoftLayer_Container_Product_Order_Hardware_Server_Upgrade"),
Hardware: []datatypes.Hardware{
{
Id : sl.Int(SERVER_ID),
},
},
Prices: []datatypes.Product_Item_Price{
{Id : sl.Int(35666)}, // Port maximum speed to "1 Gbps Dual Public & Private Network Uplinks (Unbonded)""
},
Properties: []datatypes.Container_Product_Order_Property {
{
Name: sl.String("MAINTENANCE_WINDOW"),
Value: sl.String("2018-08-21T14:00:00+08:00"),
},
{
Name: sl.String("orderOrigin"),
Value: sl.String("control"),
},
{
Name: sl.String("MAINTENANCE_WINDOW_ID"),
Value: sl.String("189467"),
},
},
}
service := services.GetProductOrderService(sess)
resp, err := service.VerifyOrder(&order)
if err != nil{
fmt.Println(err)
}else{
fmt.Printf("Set speed status: %v \n",resp)
}
价格ID是从HardwareServerService.GetUpgradeItemPrices()获得的。 VerifyOrder函数返回错误:
SoftLayer_Exception_Order_InvalidContainer:指定了无效的容器:SoftLayer_Container_Product_Order。订购服务器或服务需要特定的容器类型,而不是常规的基本订购容器。 (HTTP 500)
Container_Product_Order对象出了什么问题?
答案 0 :(得分:0)
如果您在创建会话后添加sess.Debug := true
,则可以从go-client检索日志,在这种情况下,客户端将发送SoftLayer_Container_Product_Order
而不是SoftLayer_Container_Product_Order_Hardware_Server_Upgrade
:>
2018/08/21 18:44:50 [DEBUG] Request URL: POST https://api.service.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json
2018/08/21 18:44:50 [DEBUG] Parameters: {"parameters":[{"complexType":"SoftLayer_Container_Product_Order","hardware":[{"id":11112222333}],"prices":[{"id":35666}],"properties":[{"name":"MAINTENANCE_WINDOW","value":"2018-08-21T14:00:00+08:00"},{"name":"orderOrigin","value":"control"},{"name":"MAINTENANCE_WINDOW_ID","value":"189467"}]}]}
因此,我建议修改订单框架以升级裸机,请尝试以下操作:
order := datatypes.Container_Product_Order_Hardware_Server_Upgrade{
Container_Product_Order_Hardware_Server: datatypes.Container_Product_Order_Hardware_Server{
Container_Product_Order: datatypes.Container_Product_Order{
Hardware: []datatypes.Hardware{
{
Id: sl.Int(SERVER_ID),
},
},
Prices: []datatypes.Product_Item_Price{
{Id: sl.Int(35666)}, // Port maximum speed to "1 Gbps Dual Public & Private Network Uplinks (Unbonded)""
},
Properties: []datatypes.Container_Product_Order_Property{
{
Name: sl.String("MAINTENANCE_WINDOW"),
Value: sl.String("2018-08-21T14:00:00+08:00"),
},
{
Name: sl.String("orderOrigin"),
Value: sl.String("control"),
},
{
Name: sl.String("MAINTENANCE_WINDOW_ID"),
Value: sl.String("189467"),
},
},
},
},
}