0
votes

When I did some operations, such as reloading a new system, to the virtual server, the server would enter into a pending status, from the portal, it showed "pending transaction". In this status, the server is forbidden to receive any other operation, otherwise it will throw out an exception. So I needed to check the status of the transaction, and what I used is "wait_for_transaction" which belongs to SoftLayer.managers.vs.VSManager(softlayer python package). Unfortunately, I met something strange.

For example, I called "upgrade"(SoftLayer.managers.vs.VSManager) to upgrade a server's nic_speed, and called "wait_for_transaction" instantly. The "wait_for_transaction" returned "True". Actually it should return "False" rather than “True” as the server should begin "upgrading". And after a few seconds later, I called "wait_for_transaction" again, this time it returned "False".

It looks like softlayer system has a delay to execute "upgrade" transaction after I called the API "upgrade". So how to check this transaction's status. If the apis which will trigger "pending transaction" indeed have a delay, what is the time gap between I call them and the transaction are "really" executed.

1
The answer of this questio may help you: stackoverflow.com/questions/36164444/… - mcruz

1 Answers

0
votes

The delay is due to when you perform an upgrade an order is created and this order have to be approved, once the order is approved the transaction is kicked off.

When you request an upgrade this request is immediately stored in the DB, you can get this data using the http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getUpgradeRequest So you can add in your code a verification which will review if there is an upgrade request which has not been completed yet, in case that there is a request not completed and it should have been started, so you know that the transaction will be started any time and you have to wait for it.

Check out this code

import SoftLayer
from pprint import pprint as pp
from datetime import datetime

client = SoftLayer.Client()
vsiId = 15003381
objectMask= "mask[completedFlag,maintenanceStartTimeUtc]"
upgrade = client['SoftLayer_Virtual_Guest'].getUpgradeRequest(id=vsiId, mask=objectMask)
if upgrade:
    if not upgrade['completedFlag']:
        # so there is upgrade request which has not been completed
        # you can see the maintenance Start Time of the upgrade request
        # like this:  print (upgrade['maintenanceStartTimeUtc'])
        # in case the upgrade request is not inmediatly you can perform
        # a verification in order to see if the request should have been started or not
        print ("there is a pending upgrade")
        activeTraqnsaction = []
        while (len(activeTraqnsaction) == 0):
            activeTraqnsaction = client['SoftLayer_Virtual_Guest'].getActiveTransactions(id=vsiId)
        print ('There is a transaction running')
        # here you can add your code to wait until the transaction is completed.
    else:
        print ("there is no pending upgrades")

Regards