2016-09-19 64 views
0

enter image description hereSoftLayer API:如何从图像模板获取blockDevice信息?

我有一个图片模板,如图所示。我想获得如图中标记的磁盘空间和虚拟磁盘列表。我用过:

http://sldn.softlayer.com/zh/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getObject to get the image template with mask as ('mask[id,accountId,name,globalIdentifier,blockDevices[device,diskImageId,diskSpace,groupId,id,units],parentId,createDate,datacenter,imageType,storageRepository,datacenters]')

掩码blockDevices被设置。但结果如下:

{'accountId': xxxxxxx, 
'blockDevices': [], 
'createDate': '2016-09-18T07:16:57-05:00', 
'datacenters': [{'id': xx4092, 
        'longName': 'Singapore 1', 
        'name': 'sng01', 
        'statusId': 2}], 
'globalIdentifier': 'xxxxxxxx-b068-40b1-8377-9ab66df80131', 
'id': 1331697, 
'imageType': {'description': 'a disk that may be replaced on upgrade', 
       'keyName': 'SYSTEM', 
       'name': 'System'}, 
'name': 'xxx-test-all-disk', 
'parentId': ''} 

blockDevices项目是一个空数组。为什么?

任何API可以帮助我获得图像磁盘空间和虚拟磁盘信息?

回答

0

请尝试以下mask(这是一个休息的例子):

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/[imageId]/getObject?objectMask=mask[id,name,children[id,name,blockDevices[diskSpace,units,diskImage[localDiskFlag]]]] 

Method:GET 

children项目包含您想要的信息。目前,您正试图获得parent项目。

我希望它能帮助你。

+0

非常感谢你的完美答案。使用你的面具,我已经得到了结果(children:[{blockDevice:[{device:0,...}]}]),但是我怎样才能获得设备类型(san或local?)。其他面具是否可以提供帮助? – lippman

+0

您可以将'localDiskFlag'添加到您的掩码(children> blockDevices> diskImage> localDiskFlag)。请尝试一下,看看它是否适合你:)。我使用此属性更新了上述请求。 – mcruz

+0

那么,它是一个多么复杂的API。 api文档不是每个掩码项目的详细信息。有太多的东西从一个项目引到另一个项目,这让我感到困惑不已。无论如何,你是如此善良,再次感谢你的帮助。 – lippman