lib/fog/google/models/compute/servers.rb in fog-1.12.1 vs lib/fog/google/models/compute/servers.rb in fog-1.13.0
- old
+ new
@@ -20,40 +20,47 @@
end
load(data)
end
def get(identity, zone=nil)
- data = nil
+ response = nil
if zone.nil?
service.list_zones.body['items'].each do |zone|
- data = service.get_server(identity, zone['name']).body
- break if data["code"] == 200
+ response = service.get_server(identity, zone['name'])
+ break if response.status == 200
end
else
- data = service.get_server(identity, zone).body
+ response = service.get_server(identity, zone)
end
- if data["code"] != 200
+ if response.nil? or response.status != 200
nil
else
- new(data)
+ new(response.body)
end
rescue Excon::Errors::NotFound
nil
end
def bootstrap(new_attributes = {})
defaults = {
:name => "fog-#{Time.now.to_i}",
- :image_name => "gcel-12-04-v20130225",
+ :image_name => "debian-7-wheezy-v20130617",
:machine_type => "n1-standard-1",
:zone_name => "us-central1-a",
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
+ :username => ENV['USER'],
}
+ if new_attributes[:disks]
+ new_attributes[:disks].each do |disk|
+ defaults.delete :image_name if disk['boot']
+ end
+ end
server = create(defaults.merge(new_attributes))
- server.wait_for(Fog.timeout, 30) { ready? }
+ server.wait_for { sshable? }
+
server
end
end
end
end