2024-03-28 10:30:50 发布
网友
对于新创建的VSI,我们可以在“周年日”取消它。API账单_item.cancelItem项目可以帮助完成它。然后在softlayer的网站/设备列表中,取消设备按钮将无法启动。
我的问题是如何检查一个VSI是否在“周年日”创建了一个取消请求?换句话说,我想让api获取VSI的状态是否已提交取消请求。你知道吗
您只需要查看vsi的billing item的“cancelationDate”属性,如果该属性的值为“null”,则表示vsi尚未取消。如果VSI在“周年日”被取消,则属性的值将等于机器将被取消的日期
请参见下面的示例以获取特定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及其计费项目
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)
您只需要查看vsi的billing item的“cancelationDate”属性,如果该属性的值为“null”,则表示vsi尚未取消。如果VSI在“周年日”被取消,则属性的值将等于机器将被取消的日期
请参见下面的示例以获取特定VSI的“cancelationDate”属性:
列出所有VSI及其计费项目
相关问题 更多 >
编程相关推荐