def stop_instance_by_id(instanceid, DryRun=False): request_stop_instance = StopInstanceRequest() request_stop_instance.set_InstanceId(instanceid) request_stop_instance.set_StoppedMode('StopCharging') request_stop_instance.set_ConfirmStop(False) request_stop_instance.set_ForceStop(False) request_stop_instance.set_DryRun(DryRun) return sendrequest(request_stop_instance)
def stop_instance(client, instance_id): request = StopInstanceRequest() request.set_accept_format('json') request.set_InstanceId(instance_id) request.set_StoppedMode("StopCharging") try: response = client.do_action_with_exception(request) except (ServerException, ClientException) as e: print(e.error_code) print("关机失败") raise e print("关机成功!") pass