Skip to content

Commit

Permalink
Merge pull request #203 from pearkes/fix_no_ip_error
Browse files Browse the repository at this point in the history
Fixes issue with new machines having no network
  • Loading branch information
petems committed Nov 3, 2015
2 parents cea60e5 + e3a69d2 commit 6ee5e17
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/tugboat/middleware/find_droplet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ def call(env)

env["droplet_id"] = droplet_return.id
env["droplet_name"] = "(#{droplet_return.name})"
env["droplet_ip"] = droplet_return.networks.v4.detect { |address| address.type == 'public' }.ip_address
check_private_ip = droplet_return.networks.v4.detect { |address| address.type == 'private' }
env["droplet_ip_private"] = check_private_ip.ip_address if check_private_ip
if droplet_return.networks.v4.empty?
env["droplet_ip"] = '' # No Network Yet
env["droplet_ip_private"] = '' # No Network Yet
else
env["droplet_ip"] = droplet_return.networks.v4.detect { |address| address.type == 'public' }.ip_address
check_private_ip = droplet_return.networks.v4.detect { |address| address.type == 'private' }
env["droplet_ip_private"] = check_private_ip.ip_address if check_private_ip
end
env["droplet_status"] = droplet_return.status
elsif found_droplets.length > 1
# Did we run the multiple questionairre?
Expand Down
103 changes: 103 additions & 0 deletions spec/fixtures/droplet_no_network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"droplet": {
"id": 6918990,
"name": "example.com",
"memory": 512,
"vcpus": 1,
"disk": 20,
"locked": true,
"status": "active",
"kernel": {
"id": 5175,
"name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-57-generic",
"version": "3.13.0-57-generic"
},
"created_at": "2015-11-03T14:13:53Z",
"features": [
"virtio"
],
"backup_ids": [

],
"next_backup_window": null,
"snapshot_ids": [

],
"image": {
"id": 13089493,
"name": "14.04 x64",
"distribution": "Ubuntu",
"slug": "ubuntu-14-04-x64",
"public": true,
"regions": [
"nyc1",
"ams1",
"sfo1",
"nyc2",
"ams2",
"sgp1",
"lon1",
"nyc3",
"ams3",
"fra1",
"tor1"
],
"created_at": "2015-08-10T21:30:19Z",
"min_disk_size": 20,
"type": "snapshot"
},
"size": {
"slug": "512mb",
"memory": 512,
"vcpus": 1,
"disk": 20,
"transfer": 1,
"price_monthly": 5,
"price_hourly": 0.00744,
"regions": [
"nyc1",
"sgp1",
"sfo1",
"nyc2",
"lon1",
"nyc3",
"ams3",
"ams2",
"fra1",
"tor1"
],
"available": true
},
"size_slug": "512mb",
"networks": {
"v4": [

],
"v6": [

]
},
"region": {
"name": "London 1",
"slug": "lon1",
"sizes": [
"512mb",
"1gb",
"2gb",
"4gb",
"8gb",
"32gb",
"48gb",
"64gb",
"16gb"
],
"features": [
"private_networking",
"backups",
"ipv6",
"metadata"
],
"available": true
}
}
}

0 comments on commit 6ee5e17

Please sign in to comment.