Wiredcraft / dopy

Digital Ocean Python
MIT License
95 stars 62 forks source link

after new_droplet 'network' sometimes still empty #18

Closed kontrafiktion closed 9 years ago

kontrafiktion commented 9 years ago

(using API V2):

when creating a new droplet I sometimes get the following error:

Traceback (most recent call last):
  File "create_droplets.py", line 20, in <module>
    create_droplet(a_group + '1')
  File "create_droplets.py", line 13, in create_droplet
    a_droplet = do.new_droplet( name, '512mb', 'ubuntu-14-04-x64', 'ams3', ssh_key_ids=['do-senacor'])
  File "/Users/vvolle/workspaces/net/dopy/dopy/manager.py", line 54, in new_droplet
    json = self.show_droplet(created_id)
  File "/Users/vvolle/workspaces/net/dopy/dopy/manager.py", line 75, in show_droplet
    json['droplet'][u'ip_address'] = json['droplet']['networks']['v4'][0]['ip_address']
IndexError: list index out of range

after creating the droplet, you seem to query the droplet immediately, but the networks might not yet have been set:

{
    "droplet": {
        "id": 3576875,
        "name": "a1",
        "memory": 512,
        "vcpus": 1,
        "disk": 20,
        "locked": true,
        "status": "new",
        "kernel": {
            "id": 2233,
            "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic",
            "version": "3.13.0-37-generic"
        },
        "created_at": "2014-12-25T17:13:36Z",
        "features": ["virtio"],
        "backup_ids": [],
        "snapshot_ids": [],
        "image": {
            "id": 6918990,
            "name": "14.04 x64",
            "distribution": "Ubuntu",
            "slug": "ubuntu-14-04-x64",
            "public": true,
            "regions": ["nyc1", "ams1", "sfo1", "nyc2", "ams2", "sgp1", "lon1", "nyc3", "ams3", "nyc3"],
            "created_at": "2014-10-17T20:24:33Z",
            "min_disk_size": 20
        },
        "size_slug": "512mb",
        "networks": {
            "v4": [],
            "v6": []
        },
        "region": {
            "name": "Amsterdam 3",
            "slug": "ams3",
            "sizes": ["32gb", "16gb", "2gb", "1gb", "4gb", "8gb", "512mb", "64gb", "48gb"],
            "features": ["virtio", "private_networking", "backups", "ipv6", "metadata"],
            "available": true
        }
    }
}
zbal commented 9 years ago

All merged. Thanks.