Softlayer API:无法创建图像模板。 faultCode = SoftLayer_Exception_Public,faultString =提供的块设备无效

时间:2018-01-31 06:08:39

标签: python api ibm-cloud-infrastructure

我使用以下代码捕获图像。 请确保不包括交换磁盘的块设备。

blockDevices = [
    {
        "id": 52xx5821,
        "complexType": "SoftLayer_Virtual_Guest_Block_Device"
    },
    #{
    #    "id": 52yy5827,
    #    "complexType": "SoftLayer_Virtual_Guest_Block_Device"
    #},
    {
        "id": 5zzz5845,
        "complexType": "SoftLayer_Virtual_Guest_Block_Device"
    }
]

try:
    # Creating the transaction for the image template
    response = client['SoftLayer_Virtual_Guest'].createArchiveTransaction(groupName, blockDevices, note, id=virtualGuestId)
    print(response)

并且在执行代码时,我收到此错误

Unable to create the image template. faultCode=SoftLayer_Exception_Public, faultString=Invalid block device supplied. Please be sure to not include the block device for a swap disk.

我以这种方式获得了磁盘详细信息

 image = client['SoftLayer_Virtual_Disk_Image'].getObject(mask=mask,id=imageId)
pp(image)

对于两个磁盘,我将描述视为

 'type': {'description': 'a disk that may be replaced on upgrade',

和第三个

'type': {'description': 'a disk that is used for swap space',

我想捕获具有第一个描述的磁盘的图像。 [不是交换一个]。它有25GB和100GB。

我尝试了以上3个id的所有组合。但我总是得到这个错误。

1 个答案:

答案 0 :(得分:1)

我建议你看这个论坛是同一个问题:

Softlayer API: How to do image capture with specify certain data disk?

似乎您获得的ID是错误的,根据您使用SoftLayer_Virtual_Disk_Image :: getObject方法的问题,使用该方法您需要知道ID并且在您的问题中不明确你是如何获得这个ID的。

要获得正确的ID,您需要使用http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getBlockDevices方法

e.g。

blockDevices = client [' SoftLayer_Virtual_Guest']。getBlockDevices(id = virtualGuestId)

你需要拿起你想要的块设备,以防blockDevice属性device = 1是交换盘。

它也可以帮到你:

https://programtalk.com/python-examples/SoftLayer.fixtures.SoftLayer_Virtual_Guest.createArchiveTransaction/

此致