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

Merge branch 'google-zones' of https://github.com/maestrodev/fog into maestrodev-google-zones

Conflicts:
	lib/fog/google/compute.rb
This commit is contained in:
Nat Welch 2013-10-01 16:14:38 -07:00
commit 233166467a
4 changed files with 56 additions and 14 deletions

View file

@ -61,6 +61,9 @@ module Fog
model :snapshot
collection :snapshots
model :zone
collection :zones
module Shared
attr_reader :project
@ -795,19 +798,6 @@ module Fog
@default_network = 'default'
end
# TODO: Total hack, create zone and zones model.
def zones
zones = []
self.list_zones.data[:body]["items"].each do |z|
if z["status"] == "UP"
zones.push z["name"]
end
end
return zones
end
# returns Google::APIClient::Result
def build_result(api_method, parameters, body_object=nil)
if body_object
result = @client.execute(

View file

@ -94,7 +94,7 @@ module Fog
requires :machine_type
requires :zone_name
if not service.zones.include? self.zone_name
if not service.zones.find{ |zone| zone.name == self.zone_name }
raise ArgumentError.new "#{self.zone_name.inspect} is either down or you don't have permission to use it."
end

View file

@ -0,0 +1,25 @@
require 'fog/core/model'
module Fog
module Compute
class Google
class Zone < Fog::Model
identity :name
attribute :description
attribute :status
attribute :maintenance_windows, :aliases => 'maintenanceWindows'
attribute :begin_time, :aliases => 'beginTime'
attribute :end_time, :aliases => 'endTime'
attribute :quotas
attribute :region
def up?
self.status == "UP"
end
end
end
end
end

View file

@ -0,0 +1,27 @@
require 'fog/core/collection'
require 'fog/google/models/compute/zone'
module Fog
module Compute
class Google
class Zones < Fog::Collection
model Fog::Compute::Google::Zone
def all
data = service.list_zones.body["items"] || []
load(data)
end
def get(identity)
data = connection.get_zone(identity).body
new(data)
rescue Excon::Errors::NotFound
nil
end
end
end
end
end