VSManager中的「wait_for_transaction」函數僅檢查事務狀態是否未掛起,這就是爲什麼儘管事務失敗,結果仍然成功。 要驗證升級是否有效,需要查看上次事務的狀態。
你可以使用Python客戶端查看下一個示例腳本:
"""
Retrieve a computing instance's associated upgrade request object if any.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getUpgradeRequest
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Upgrade_Request
https://sldn.softlayer.com/article/object-masks
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
from pprint import pprint as pp
virtualGuestId = 12345678
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.Client(username=USERNAME,
api_key=API_KEY)
virtualGuestService = client['SoftLayer_Virtual_Guest']
objectMask = 'mask[completedFlag,order,status,ticket[title,id],virtualGuest[id,fullyQualifiedDomainName,lastTransaction[transactionGroup]]]'
try:
upgradeRequest = virtualGuestService.getUpgradeRequest(mask=objectMask, id=virtualGuestId)
# The result should display the upgrade request status, order status, ticket associated
# and the last transaction and transaction status of the current Virtual Guest.
# Note: The upgrade request status could be the next:
# APPROVED
# PENDING
# PENDING_CUSTOMER_APPROVAL
# COMPLETE
# CANCELLED
# MAINTENANCE_UPDATE_REQUIRED
# IN_TRANSACTION
# PENDING_PAYMENT_PROCESS
# PENDING_AUTOMATED_FINALIZE
pp(upgradeRequest)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to upgrade the VSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))