如何阻止直到使用Python Boto3通过EC2状态检查? [英] How to block until EC2 status check is passed using Python Boto3?

查看:164
本文介绍了如何阻止直到使用Python Boto3通过EC2状态检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下python代码来检测EC2是否真正启动.但是,当实例状态"显示为正在运行时,它完成. 我应该使用哪个API函数来阻止,直到EC2状态检查"显示已通过2/2检查"

I have the following python code to detect whether an EC2 is really started. But it completes when "instance state" shows running. which API function should I use to block until EC2 "status check" show "2/2 checks passed"

ec2 = boto3.resource('ec2')
instance = ec2.Instance(instanceid)
instance.wait_until_running()

推荐答案

很少需要等待状态检查通过.

It is rare that you would need to wait for the status check to pass.

当实例进入运行状态时,计算机将启动,加载操作系统并通常运行".

When an instance enters the running state, the machine boots, loads the operating system and generally "runs".

EC2状态检查是检查虚拟机属性的独立进程.但是,您的计算机可以正常运行,并且可以在状态检查显示肯定的响应之前登录到计算机.

The EC2 Status Checks are an independent process that check attributes of the virtual machine. However, your machine is normally running, and you can login to it, well before the status checks show a positive response.

如果您要做希望等待状态检查,则可能有两名服务员可能执行此操作,但是文档尚不清楚:

If you do wish to wait for the Status Check, there are two waiters that might do this, but the documentation is unclear:

  • InstanceStatusOk
  • SystemStatusOk

这篇关于如何阻止直到使用Python Boto3通过EC2状态检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆