Mal*_*tha 6 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]
Run Code Online (Sandbox Code Playgroud)
newMachine具有与已启动实例相关的信息.我试过了
vars(newmachine)
Run Code Online (Sandbox Code Playgroud)
并且变量的ip_address和private_ip_address为空.如何获取已启动实例的ip_address?
Tho*_*zco 11
刷新值,直到实例进入运行状态.此时,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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8199 次 |
| 最近记录: |