对于新创建的VSI,我们可以在"Anniversary Date"上取消它 . API billing_item.cancelItem可以帮助您完成它 . 然后在softlayer的网站/设备列表中,CancelDevice按钮将无法使用 .
我的问题是如何通过api检查VSI是否已在“周年纪念日”创建取消请求?哦,我希望api获得VSI的状态已经提交了取消请求 .
如果属性的值为“null”,则只需要查看vsi的计费项目的“cancelationDate”属性,这意味着VSI尚未被取消 . 如果VSI已在“周年纪念日”取消,则该 properties 的 Value 将等于机器取消的日期
请参阅下面的示例以获取特定VSI的“cancelationDate”属性:
import SoftLayer USERNAME = 'set me' API_KEY = 'set me' vsiId = 123 client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) vsiService = client['SoftLayer_Virtual_Guest'] objectMask = "mask[id, cancellationDate]" try: result = vsiService.getBillingItem(mask=objectMask, id=vsiId) print(result) except SoftLayer.SoftLayerAPIError as e: print("Unable to retrieve the VSI's billing item. " % (e.faultCode, e.faultString)) exit(1)
列出所有VSI及其billingItems
import SoftLayer USERNAME = 'set me' API_KEY = 'set me' client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) vsiService = client['SoftLayer_Account'] objectMask = "mask[id,hostname, billingItem[cancellationDate]]" try: result = vsiService.getVirtualGuests(mask=objectMask) print(result) except SoftLayer.SoftLayerAPIError as e: print("Unable to retrieve the VSI's billing item. " % (e.faultCode, e.faultString)) exit(1)
1 回答
如果属性的值为“null”,则只需要查看vsi的计费项目的“cancelationDate”属性,这意味着VSI尚未被取消 . 如果VSI已在“周年纪念日”取消,则该 properties 的 Value 将等于机器取消的日期
请参阅下面的示例以获取特定VSI的“cancelationDate”属性:
列出所有VSI及其billingItems