1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

more attempts to get server creation working.

This commit is contained in:
Nat Welch 2013-03-12 15:06:19 -07:00
parent a17ccf2dc0
commit cf01cbfe45
3 changed files with 24 additions and 7 deletions

View file

@ -66,8 +66,11 @@ module Fog
class Real
include Collections
attr_reader :project
def initialize(options)
base_url = 'https://www.googleapis.com/compute/'
# TODO(icco): v1beta13 will probably be deprecated in April.
api_version = 'v1beta13'
api_scope_url = 'https://www.googleapis.com/auth/compute'

View file

@ -6,7 +6,7 @@ module Fog
class Server < Fog::Model
attribute :name
attribute :name, :aliases => 'identity'
attribute :image_name, :aliases => 'image'
attribute :network_interfaces, :aliases => 'networkInterfaces'
attribute :state, :aliases => 'status'
@ -15,11 +15,11 @@ module Fog
def destroy
requires :name
connection.delete_server(name)
service.delete_server(name)
end
def image
connection.get_image(self.image_name.split('/')[-1])
service.get_image(self.image_name.split('/')[-1])
end
def public_ip_address
@ -31,7 +31,7 @@ module Fog
end
def zone
connection.get_zone(self.zone_name.split('/')[-1])
service.get_zone(self.zone_name.split('/')[-1])
end
def save
@ -40,9 +40,9 @@ module Fog
requires :machine_type
requires :zone_name
data = connection.insert_server(name, image_name, zone_name,
data = service.insert_server(name, image_name, zone_name,
machine_type)
connection.servers.merge_attributes()
service.servers.merge_attributes()
end
end

View file

@ -10,7 +10,7 @@ module Fog
model Fog::Compute::Google::Server
def all
data = service.list_servers.body["items"]
data = service.list_servers.body["items"] || []
load(data)
end
@ -21,6 +21,20 @@ module Fog
nil
end
def bootstrap(new_attributes = {})
defaults = {
:name => "fog_#{Time.now.to_i}",
:image_name => "",
:machine_type => "",
:zone_name => "",
}
server = create(defaults.merge(new_attributes))
server.wait_for { ready? }
server
end
end
end