I am launching instance in openstack using boto
myinstance = conn.run_instances('ami-0000007d',min_count=1,max_count=1, instance_type = 'm1.small')
newmachine=myinstance.instances[0]
newMachine has the info related to the launched instance. I have tried
vars(newmachine)
and the ip_address and private_ip_address of variables are empty. How can I obtain the ip_address of the launched instance ?
You view the internal and external IP addresses for your instance through either the Google Cloud console, the Google Cloud CLI, or the Compute Engine API. In the Google Cloud console, go to the VM instances page. If the VM instance has an external IP address, it appears under the External IP column.
When you launch an EC2 instance into a default VPC without specifying a specific subnet, it's automatically launched in one of the default subnets. Every instance in a default subnet receives a private IP address from the pool of addresses associated with that subnet and also a private DNS hostname.
Refresh the value until the instance enters Running state. At that point, the IP should be present (not that there's anything you could do with the IP before the instance is in running state).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With