我遇到500错误,返回了SoftLayer_Exception_NotImplemented。
SoftLayer_Exception_NotImplemented: SoftLayer_Virtual_Guest_Strategy_Behavior_Standard::setUserMetadata is not implemented. (HTTP 500)
在调用createObject之后设置用户元数据时发生。此虚拟机在“设置设置配置”中保持“已暂停”状态。我只等了大约30秒钟重试。所以我编程了60秒暂停。这个值可以吗?
答案 0 :(得分:0)
这里报告了相同的错误IBM Cloud infrastructure cli error - setUserMetadata is not implemented
下面是一个如何使用REST调用setUserMetadata的示例:
POST: https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[vmID]/setUserMetadata
BODY:
{
"parameters":[
[
"value1"
]
]
}
我无法重现该错误,我等待了50秒才能运行以下softlayer-go示例,并且元数据设置成功:
virtualService := services.GetVirtualGuestService(sess)
metadata := []string{"value1"}
result, err := virtualService.Id(11122233).SetUserMetadata(metadata)
if err != nil {
fmt.Printf("\n Unable to set user metadata:\n - %s\n", err)
return
}
// If true prints the user data
if result == true {
udata, err := virtualService.Id(11122233).GetUserData()
if err != nil {
fmt.Printf("\n Unable retrieve user data:\n - %s\n", err)
return
}
jsonFormat, jsonErr := json.MarshalIndent(udata, "", " ")
if jsonErr != nil {
fmt.Println(jsonErr)
return
}
fmt.Println(string(jsonFormat))
输出:
[
{
"type": {
"keyname": "USER_DATA",
"name": "User Data"
},
"value": "value1"
}
]
以下是我致电/rest/v3.1/SoftLayer_Resource_Metadata/getUserMetadata
root@example:~# curl -i https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata/getUserMetadata
HTTP/1.1 200 OK
Date: Wed, 25 Jul 2018 15:12:21 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Content-Length: 8
Vary: Accept-Encoding
Connection: close
Content-Type: application/json
Strict-Transport-Security: max-age=31536000
"value1"
我关闭了VM(已停止),也能够设置一个新的元数据,我不确定您是怎么得到这个错误的。
我建议您在创建VM时设置元数据,因为它将在配置VM时设置元数据,以下是REST中使用createObject方法的示例:
POST: https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject
{
"parameters": [{
"hostname": "hostname01",
"domain": "softlayer.local",
"datacenter": { "name": "dal10" },
"startCpus": 1,
"maxMemory": 1024,
"localDiskFlag": false,
"blockDevices": [{
"device": "0",
"diskImage": { "capacity": 25 }
}],
"networkComponents": [{ "maxSpeed": 10 }],
"hourlyBillingFlag": true,
"operatingSystemReferenceCode": "DEBIAN_LATEST",
"userData": [ { "value": "someUserMetadataValue" } ]
}]
}