为 activeTransaction 使用软层对象过滤器

Using Softlayer Object Filters for activeTransaction

我正在尝试使用 Python SoftLayer API 来 return 虚拟服务器列表 没有活动"RECLAIM_WAIT" 状态下的事务(这是您在 Softlayer 中删除虚拟服务器时的状态)。我希望取回所有根本没有 activeTransaction 的虚拟服务器,以及那些有 activeTransaction 但处于 "RECLAIM_WAIT".

以外状态的虚拟服务器

我用我认为应该起作用的过滤器调用 vs 管理器:

f={'virtualGuests': {'activeTransaction': {'transactionStatus': {'name': {'operation': '!= RECLAIM_WAIT'}}}}}
instance = vs.list_instances(hostname="node5-0",filter=f)

但它 return 只有具有 activeTransaction 的实例(包括具有 RECLAIM_WAIT 状态的实例)。

这是该调用的 returned 实例示例:

[{'status': {'keyName': 'DISCONNECTED', 'name': 'Disconnected'}, 'datacenter': {'statusId': 2, 'id': 265592, 'name': 'xxxx', 'longName': 'xxx'}, 'domain': 'xxxx', 'powerState': {'keyName': 'HALTED', 'name': 'Halted'}, 'maxCpu': 2, 'maxMemory': 8192, 'hostname': 'node5-0', 'primaryIpAddress': 'xxxx', 'activeTransaction': {'modifyDate': '2017-01-16T05:20:01-06:00', 'statusChangeDate': '2017-01-16T05:20:01-06:00', 'elapsedSeconds': 22261, 'createDate': '2017-01-16T05:19:05-06:00', 'hardwareId': '', 'guestId': 27490599, 'id': 46204349, 'transactionStatus': {'friendlyName': 'This is a buffer time in which the customer may cancel the server', 'name': 'RECLAIM_WAIT'}}, 'globalIdentifier': 'xx', 'primaryBackendIpAddress': 'xxx', 'id': xxx, 'fullyQualifiedDomainName': 'xxx'}]

我的过滤器做错了什么?

您的请求没有任何问题,遗憾的是,无法过滤其 transactionStatus 的交易,因为 transaction 无法访问 "transactionStatusId" key,可以在transaction datatype中查看,本地属性中不存在"transactionStatusId"。

因此,最好的方法是直接在您的代码中进行过滤。