0

使用下面的命令时,我们会得到一个 145MB json 有效负载的响应:

curl -uuser:api-key https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests?objectMask=powerState%3BoperatingSystem.passwords%3Bdatacenter%3BbillingItem%3BblockDevices.diskImage%3BtagReferences
% Total % Received % Xferd Average Speed Time Time Time Current
                           Dload Upload Total Spent Left Speed
12 145M 12 18.0M 0 0 321k 0 0:07:44 0:00:57 0:06:47 401k

查看我们几周前的日志,同一个电话给了我们大约 300KB 的响应。因此,我们认为这是 Softlayer API 实现中最近的一个错误。


查看json响应,有大量的重复。每个 VM 的详细信息重复 394 次。


我们已经尝试了不同的 API 调用,并确定了一种解决方法:使用tagReferences.tag.name而不是tagReferences

curl -uuser:api-key https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests?objectMask=powerState%3BoperatingSystem.passwords%3Bdatacenter%3BbillingItem%3BblockDevices.diskImage%3BtagReferences.tag.name
% Total % Received % Xferd Average Speed Time Time Time Current
                           Dload Upload Total Spent Left Speed
100 277k 100 277k 0 0 77421 0 0:00:03 0:00:03 --:--:-- 77426

我们在Apache Brooklyn中使用jclouds解决了这个问题(请参阅Brooklyn 问题,以及在https://github.com/jclouds/jclouds/pull/1020中添加到 jclouds 的解决方法)。使用现有 jclouds GA 版本的用户将继续受到此影响。

SoftLayer 能否确认这是否是他们方面的错误,是否以及何时修复,以及是否有更好的解决方法?

4

2 回答 2

0

这不是错误,因为您正在使用 objectMask 来检索其他数据。在这种情况下,tagReferences 显示“对象关系信息”。这就是 VM 详细信息重复多次的原因。不过,您可以像在第二个请求中那样控制此信息:tagReferences.tag.name。此外,可以获得多个对象属性或嵌套属性,例如在此掩码示例中:

objectMask=mask[tagReferences[id,tagTypeId,customer[address1,city]]]

作为旁注,如果您确定数据是重复的,并且它与关系属性数据无关,那么我建议向 SoftLayer 支持提交一张票。

于 2016-10-14T22:21:48.427 回答
0

刚刚偶然发现这个问题,不完全确定它是否是一个错误,但至少它并不明显:当你通过tagReferences.tag.nameAPI 屏蔽时,将过滤子对象tagReferences.tag,但它会留下整个的其余部分tagReferences,其中包括一个巨大的customer对象很多不必要的信息(包括 child hardware)。

我发现的解决方案是按除 之外的任何其他属性进行过滤tag,即使您不使用它:

  • tagReferences[tag[name]]将仅返回 in 中的name属性,tag但也会返回 tagReferences 中的所有属性
  • tagReferences[id,tag[name]]将只返回idtag.nametagReferences
于 2018-11-14T12:06:39.050 回答