GoGrid collections working. What weird JSON.
This commit is contained in:
parent
26a3172222
commit
56b114d5c7
|
@ -34,6 +34,8 @@ module Fog
|
||||||
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
|
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
|
||||||
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
|
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
|
||||||
:bluebox_customer_id: 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
|
:local_root: INTENTIONALLY_LEFT_BLANK
|
||||||
:new_servers_password: INTENTIONALLY_LEFT_BLANK
|
:new_servers_password: INTENTIONALLY_LEFT_BLANK
|
||||||
:new_servers_username: INTENTIONALLY_LEFT_BLANK
|
:new_servers_username: INTENTIONALLY_LEFT_BLANK
|
||||||
|
|
|
@ -6,9 +6,14 @@ module Fog
|
||||||
requires :go_grid_shared_secret
|
requires :go_grid_shared_secret
|
||||||
|
|
||||||
model_path 'fog/go_grid/models/compute'
|
model_path 'fog/go_grid/models/compute'
|
||||||
|
model :image
|
||||||
|
collection :images
|
||||||
|
model :server
|
||||||
|
collection :servers
|
||||||
|
|
||||||
request_path 'fog/go_grid/requests/compute'
|
request_path 'fog/go_grid/requests/compute'
|
||||||
request :common_lookup_list
|
request :common_lookup_list
|
||||||
|
request :grid_image_get
|
||||||
request :grid_image_list
|
request :grid_image_list
|
||||||
request :grid_ip_list
|
request :grid_ip_list
|
||||||
request :grid_loadbalancer_list
|
request :grid_loadbalancer_list
|
||||||
|
|
|
@ -9,10 +9,23 @@ module Fog
|
||||||
identity :id
|
identity :id
|
||||||
|
|
||||||
attribute :name
|
attribute :name
|
||||||
|
attribute :description
|
||||||
attribute :friendly_name, :aliases => 'friendlyName'
|
attribute :friendly_name, :aliases => 'friendlyName'
|
||||||
attribute :created_at, :aliases => 'createdTime'
|
attribute :created_at, :aliases => 'createdTime'
|
||||||
attribute :updated_at, :aliases => 'updatedTime'
|
attribute :updated_at, :aliases => 'updatedTime'
|
||||||
attribute :server_id, :aliases => 'id'
|
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)
|
def server=(new_server)
|
||||||
requires :id
|
requires :id
|
||||||
|
|
|
@ -14,10 +14,14 @@ module Fog
|
||||||
def all
|
def all
|
||||||
data = connection.grid_image_list.body['list']
|
data = connection.grid_image_list.body['list']
|
||||||
load(data)
|
load(data)
|
||||||
|
if server
|
||||||
|
self.replace(self.select {|image| image.server_id == server.id})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(image_id)
|
def get(image_id)
|
||||||
response = connection.grid_image_get.body['list'][image_id]
|
response = connection.grid_image_get.body['list'][image_id]
|
||||||
|
new(data)
|
||||||
rescue Fog::GoGrid::Compute::NotFound
|
rescue Fog::GoGrid::Compute::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,48 +6,51 @@ module Fog
|
||||||
|
|
||||||
class BlockInstantiationError < StandardError; end
|
class BlockInstantiationError < StandardError; end
|
||||||
|
|
||||||
class Server < Fog::Model
|
class Server < Fog::Model
|
||||||
|
|
||||||
identity :id
|
identity :id
|
||||||
|
|
||||||
attribute :name
|
attribute :name
|
||||||
attribute :image_id # id or name
|
attribute :image_id # id or name
|
||||||
attribute :ip
|
attribute :ip
|
||||||
attribute :memory # server.ram
|
attribute :memory # server.ram
|
||||||
attribute :state
|
attribute :state
|
||||||
attribute :description # Optional
|
attribute :description # Optional
|
||||||
attribute :sandbox # Optional. Default: False
|
attribute :sandbox # Optional. Default: False
|
||||||
|
|
||||||
def initialize(attributes={})
|
def initialize(attributes={})
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.grid_server_destroy(@id)
|
connection.grid_server_destroy(@id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def image
|
def image
|
||||||
requires :image_id
|
requires :image_id
|
||||||
connection.grid_image_get(@image_id)
|
connection.grid_image_get(@image_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ready?
|
def ready?
|
||||||
@state == 'On'
|
@state == 'On'
|
||||||
end
|
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
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue