我正在使用 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_address和private_ip_address为空。如何获取启动实例的ip_address?
最佳答案
刷新该值,直到实例进入运行状态。此时,IP 应该存在(并不是说在实例处于运行状态之前您可以对 IP 执行任何操作)。
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
关于python - 如何使用 Boto 获取已启动实例的 IP 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24547010/