如何从 Python API 获取 Softlayer 机器上的当前活动事务?

How to get the current active transaction on a Softlayer machine from the Python API?

slcli 可以选择使用 slcli vs detail machine_name | grep active_transaction 获取机器上的当前活动事务。 Python API for Softlayer 的等效函数是什么?

更具体地说,我想知道救援交易何时完成。 slcli 与细节 *** | grep active_transaction active_transactionRESCUE_BOOT<br> slcli 与细节 *** | grep active_transaction active_transactionCLOUD_ISO_BOOT_TEAR_DOWN<br> slcli 与细节 *** | grep active_transaction active_transactionCONFIGURE_CLOUD_NETWORK<br> slcli 与细节 *** | grep active_transaction active_transaction 空

是否可以通过pythonAPI获取以上信息?

尝试以下示例,

import SoftLayer

USERNAME = 'set me'
API_KEY = 'set me'

vsiId = 111222333

client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)

try:
    active_transaction = client['Virtual_Guest'].getActiveTransaction(id=vsiId)    
    print(active_transaction)
except SoftLayer.SoftLayerAPIError as e:
    pp("Unable to retrieve active transaction: %s, %s " % (e.faultCode, e.faultString))

getActiveTransaction returns null when there aren't transactions so it means that it was completed, if you want to check the last transaction use the method getLastTransaction代替