Python 如何使用Boto获取已启动实例的IP地址
我正在使用boto在openstack中启动实例Python 如何使用Boto获取已启动实例的IP地址,python,amazon-ec2,boto,openstack,Python,Amazon Ec2,Boto,Openstack,我正在使用boto在openstack中启动实例 myinstance = conn.run_instances('ami-0000007d',min_count=1,max_count=1, instance_type = 'm1.small') newmachine=myinstance.instances[0] newMachine具有与已启动实例相关的信息。我试过了 vars(newmachine) 变量的ip_地址和私有ip_地址为空。如何获取已启动实例的ip_地址?刷新该值,直
myinstance = conn.run_instances('ami-0000007d',min_count=1,max_count=1, instance_type = 'm1.small')
newmachine=myinstance.instances[0]
newMachine具有与已启动实例相关的信息。我试过了
vars(newmachine)
变量的ip_地址和私有ip_地址为空。如何获取已启动实例的ip_地址?刷新该值,直到实例进入运行状态。此时,IP应该存在(而不是在实例处于运行状态之前,您可以对IP执行任何操作)
我遇到了一个问题,在进入“运行”状态5秒后再次调用
instance.update()
解决了这个问题。一个实例不能有多个ip地址吗?如果您想要私有ip地址,可以使用instance.private\u ip\u地址
reservation = conn.run_instances(...)
instance = reservation.instances[0]
while instance.update() != "running":
time.sleep(5) # Run this in a green thread, ideally
print instance.ip_address