diff --git a/lib/fog/core/credentials.rb b/lib/fog/core/credentials.rb index 1addbb13f..214384a35 100644 --- a/lib/fog/core/credentials.rb +++ b/lib/fog/core/credentials.rb @@ -34,6 +34,8 @@ module Fog :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK :bluebox_api_key: INTENTIONALLY_LEFT_BLANK :bluebox_customer_id: INTENTIONALLY_LEFT_BLANK + :go_grid_api_key: INTENTIONALLY_LEFT_BLANK + :go_grid_shared_secret: INTENTIONALLY_LEFT_BLANK :local_root: INTENTIONALLY_LEFT_BLANK :new_servers_password: INTENTIONALLY_LEFT_BLANK :new_servers_username: INTENTIONALLY_LEFT_BLANK diff --git a/lib/fog/go_grid/compute.rb b/lib/fog/go_grid/compute.rb index 2217d6d44..c93d8bb1f 100644 --- a/lib/fog/go_grid/compute.rb +++ b/lib/fog/go_grid/compute.rb @@ -6,9 +6,14 @@ module Fog requires :go_grid_shared_secret model_path 'fog/go_grid/models/compute' + model :image + collection :images + model :server + collection :servers request_path 'fog/go_grid/requests/compute' request :common_lookup_list + request :grid_image_get request :grid_image_list request :grid_ip_list request :grid_loadbalancer_list diff --git a/lib/fog/go_grid/models/compute/image.rb b/lib/fog/go_grid/models/compute/image.rb index c03933834..e74af9a62 100644 --- a/lib/fog/go_grid/models/compute/image.rb +++ b/lib/fog/go_grid/models/compute/image.rb @@ -9,10 +9,23 @@ module Fog identity :id attribute :name + attribute :description attribute :friendly_name, :aliases => 'friendlyName' attribute :created_at, :aliases => 'createdTime' attribute :updated_at, :aliases => 'updatedTime' attribute :server_id, :aliases => 'id' + attribute :state + attribute :price + attribute :location + attribute :billingtokens + attribute :os + attribute :architecture + attribute :type + attribute :active, :aliases => 'isActive' + attribute :public, :aliases => 'isPublic' + attribute :object_type, :aliases => 'object' + attribute :owner + def server=(new_server) requires :id diff --git a/lib/fog/go_grid/models/compute/images.rb b/lib/fog/go_grid/models/compute/images.rb index 6bf2cc24a..66933867b 100644 --- a/lib/fog/go_grid/models/compute/images.rb +++ b/lib/fog/go_grid/models/compute/images.rb @@ -14,10 +14,14 @@ module Fog def all data = connection.grid_image_list.body['list'] load(data) + if server + self.replace(self.select {|image| image.server_id == server.id}) + end end def get(image_id) response = connection.grid_image_get.body['list'][image_id] + new(data) rescue Fog::GoGrid::Compute::NotFound nil end diff --git a/lib/fog/go_grid/models/compute/server.rb b/lib/fog/go_grid/models/compute/server.rb index e25553363..fd9f72e89 100644 --- a/lib/fog/go_grid/models/compute/server.rb +++ b/lib/fog/go_grid/models/compute/server.rb @@ -6,48 +6,51 @@ module Fog class BlockInstantiationError < StandardError; end - class Server < Fog::Model + class Server < Fog::Model - identity :id + identity :id - attribute :name - attribute :image_id # id or name - attribute :ip - attribute :memory # server.ram - attribute :state - attribute :description # Optional - attribute :sandbox # Optional. Default: False + attribute :name + attribute :image_id # id or name + attribute :ip + attribute :memory # server.ram + attribute :state + attribute :description # Optional + attribute :sandbox # Optional. Default: False - def initialize(attributes={}) - super - end + def initialize(attributes={}) + super + end - def destroy - requires :id - connection.grid_server_destroy(@id) - true - end + def destroy + requires :id + connection.grid_server_destroy(@id) + true + end - def image - requires :image_id - connection.grid_image_get(@image_id) - end + def image + requires :image_id + connection.grid_image_get(@image_id) + end - def ready? - @state == 'On' - end + def ready? + @state == 'On' + end + + def save + raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity + requires :name, :image_id, :ip, :memory + options['isSandbox'] = sandbox if sandbox + options['server.ram'] = memory + options['image'] = image_id + data = connection.grid_server_add(name, image, ip, options) + merge_attributes(data.body) + true + end - def save - raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity - requires :name, :image_id, :ip, :memory - options['isSandbox'] = sandbox if sandbox - options['server.ram'] = memory - options['image'] = image_id - data = connection.grid_server_add(name, image, ip, options) - merge_attributes(data.body) - true end end - end + end +end