whitfiea
whitfiea

Reputation: 1943

Using Softlayer Object Filters for activeTransaction

I am trying to use the Python SoftLayer API to return a list of virtual servers that are do not have an active transaction in "RECLAIM_WAIT" status (which is the state you have when you delete a virtual server in Softlayer). I am expecting to get back all virtual servers that have no activeTransaction at all, and also ones that have an activeTransaction but is in a status other than "RECLAIM_WAIT".

I call the vs manager with a filter that I think should work:

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

but it returns only instances that have an activeTransaction (including the ones that have a RECLAIM_WAIT status).

Here is an example of a returned instance from that call:

[{'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'}]

What am I doing wrong with the filter?

Upvotes: 0

Views: 206

Answers (1)

Ruber Cuellar Valenzuela
Ruber Cuellar Valenzuela

Reputation: 2757

There is nothing wrong in your request, unfortunately, it's not possible to filter transactions for its transactionStatus, because the transaction doesn't have access to "transactionStatusId" key, you can check in the transaction datatype, there not exist the "transactionStatusId" in the local properties.

So, the best way would be to filter directly in your code.

Upvotes: 1

Related Questions