Softlayer API:如何更新CCI的OS用户名和密码

时间:2016-10-17 20:40:04

标签: ibm-cloud-infrastructure

我正在尝试使用以下API和参数来更新cci的用户名和密码,但不断出现错误的请求错误。任何建议都非常感谢。

https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/12345.json

方法:PUT

{
    "parameters": [
        "operatingSystem": 
        {
            "passwords ": [
                {
                    "username": "root1",
                    "password" : "Test1"
                }
            ]
        }
    ]
}

谢谢!

1 个答案:

答案 0 :(得分:0)

请按以下步骤操作:

从vm

中检索密码的标识符
https://$user:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/$vsiId/getSoftwareComponents?objectMask=mask[passwords]

Method: Get

用您自己的信息替换 $ user $ apiKey $ vsiId

你会得到这样的结果:

hardwareId": null
"id": 345676755
"manufacturerLicenseInstance": "C412F72A-1BB1-4C07-9467-E55729234F8E"
"passwords": [1]
0:  {
"createDate": "2016-06-09T11:10:28-03:00"
"id": 122333
"modifyDate": "2016-09-06T11:19:18-03:00"
"password": "Cochabamba"
"port": null
"softwareId": 11209641
"username": "Ruber"
"software": null
}
}

然后您可以使用以下调用进行更新:

https://$user:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Software_Component_Password/$passwordId/editObject

Method: Post

{  
   "parameters":[  
      {  
         "username":"usernameTest",
         "password":"Password*-"
      }
   ]
}

使用您自己的信息替换: $ user $ apiKey $ passwordId ,在这种情况下为 $ passwordId 是: 122333

注意:请注意,密码仅在跟踪时更改,不会在服务器中生效