2024-03-29 13:06:06 发布
网友
我使用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地址?
刷新该值,直到实例进入运行状态。此时,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
刷新该值,直到实例进入运行状态。此时,IP应该存在(不是说在实例处于运行状态之前,您可以对IP做任何事情)。
相关问题 更多 >
编程相关推荐