how long does it take for ip_address field to show up upon droplet creation?

May 9, 2014 2k views
when I create a droplet, it doesn't return the ip_address. I look at my dashboard and it seems that ip address becomes initially available early on during the progress. On average how long does it take until ip address is returned by a droplet still being provisioned? I also noticed that event_id is not available as well. So my hope is that if I can get ip_address as soon as possible, I can immediately start creating dns records for it to point my subdomains to, instead of waiting until the whole provision is complete.
3 Answers
The ip_address should be assigned quickly, but as you've noticed it is not instantaneous. The same goes for the event_id. Unfortunately, you just need to workaround this. Here's some (pseudo) Python code:

info = droplet.get_info()
loading = True
while loading:
ip_address = info["ip_address"]
loading = False
except TypeError: # Not yet reporting an ip yet
# Now do something

This is similar to something I really use in a project. It generally will get the IP the second time through the loop, but you might want to add a small sleep in case you're worried about the number of network requests.
thank you. I guess do the same thing to check for event_id, and get progress data as well?
Right. Again, it should be available quickly. It's just not there if you hit the endpoint immediately after creation.
Have another answer? Share your knowledge.