【问题标题】:SoftLayer how can detach a Local Storage from VirtualMachine RESTSoftLayer 如何从 VirtualMachine REST 中分离本地存储
【发布时间】:2016-09-16 21:28:09
【问题描述】:

我正在尝试从虚拟机中分离本地存储,但我从 API 收到错误。

这是我想做的:

首先,我得到存储的 ID

.../rest/v3.1/SoftLayer_Account/getVirtualDiskImages.json

0:  {
"capacity": 25
"createDate": "2016-09-15T05:28:16-05:00"
"description": "Disk 2"
"id": 21757115
"modifyDate": null
"name": "Disk 2"
"parentId": null
"storageRepositoryId": 2257588
"typeId": 241
"units": "GB"
"uuid": "0c7f6050-b8ff-431f-a500-f1e896e02c92"
} ...

其次,我尝试从虚拟机中分离本地存储

方法:[DELETE] / [POST] / [PUT]

rest/v3.1/SoftLayer_Virtual_Guest/[vm-id]/detachDiskImage.json

我尝试了以下请求参数:

1 -

   {
        "parameters": [
            {
                "imageId": "21757115"
            }
    }

2 -

   {
        "parameters": [
            {
                "id": "21757115"
            }
    }

3 -

   {
      21757115
   }

但我总是得到

{
"error": "You must provide a valid portable storage volume id."
"code": "SoftLayer_Exception_Public"
}

任何想法都会受到赞赏。

【问题讨论】:

    标签: rest ibm-cloud-infrastructure


    【解决方案1】:

    您可以使用下一个 REST 请求来查找所有可以附加/分离的磁盘映像:

    http://[$username]:[$apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getPortableStorageVolumes.json
    

    方法:获取

    然后你可以使用下一个分离它:

    http://[$username]:[$apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/[$virtualGuestId]/detachDiskImage.json
    

    方法:POST

    正文:

    {
        "parameters": [
            1234567                
        ]
    }
    

    virtualGuestId 是要从中分离磁盘映像的虚拟客户 ID

    1234567是使用getPortableStorageVolumes方法检索到的图片id

    注意:getVirtualDiskImages 会检索所有磁盘映像,包括那些无法分离的磁盘映像,因此,在这种情况下最好使用 getPortableStorageVolumes

    【讨论】:

    • 感谢您的回复。我尝试了 [/rest/v3.1/SoftLayer_Account/getPortableStorageVolumes.json] 并获得了具有以下属性的设备信息 [id=21757115, name=..., capacity=..., uuid=, ...]然后我使用请求 [/rest/v3.1/SoftLayer_Virtual_Guest/[$portableStorageVolumeId]/detachDiskImage.json] 作为 POST 并将 [$portableStorageVolumeId] 更改为 [id] 值,此外,正文发送相同的 [Id ] 作为参数,为什么两次,不知道。现在我得到 "error": "Unable to find object with id of '21757115'。"
    • 我更新了我的答案,请查看并确保您使用的是正确的 ID。
    猜你喜欢
    • 2015-04-17
    • 1970-01-01
    • 1970-01-01
    • 2018-02-16
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    • 1970-01-01
    相关资源
    最近更新 更多