koalalorenzo/python-digitalocean

Newly created droplet IP address

Bekmezcii opened this issue · 1 comments

I am creating a new droplet and then I want to get IP address of the newly created droplet. I have tried several different techniques but I failed.

After droplet.create(), I tried
d = droplet.load()
print(d.ip_address)

But it was none.

I tried to get all droplets list again. But it didn't work again. The weird thing is that if I want to get all the droplets in a seperate program, it can get the IP address. However, after the creation, I cannot get IP address in the same program.

Can you help me?

droplet.create() is not synchronous, you can loop until the droplet is created and you get your IP address... Or you can get ID of the action from droplet.action_ids, get the action object via Manager and call wait().

...
droplet.create()
while droplet.load().ip_address is None:
    time.sleep(DELAY)