From 8015dec8902b30f3ab2c019dd0b88a3bd7edc25f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 May 2013 17:35:57 +0800 Subject: [PATCH] Add Config attributes, and the "get" method for Configs to get detail of a specific config object --- lib/fog/storm_on_demand/compute.rb | 6 ++++-- .../storm_on_demand/models/compute/config.rb | 20 +++++++++++++++---- .../storm_on_demand/models/compute/configs.rb | 8 ++++++-- .../requests/compute/get_config_details.rb | 16 +++++++++++++++ .../requests/compute/list_configs.rb | 2 +- 5 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 lib/fog/storm_on_demand/requests/compute/get_config_details.rb diff --git a/lib/fog/storm_on_demand/compute.rb b/lib/fog/storm_on_demand/compute.rb index e72f0630c..255f2c68c 100644 --- a/lib/fog/storm_on_demand/compute.rb +++ b/lib/fog/storm_on_demand/compute.rb @@ -5,7 +5,8 @@ module Fog module Compute class StormOnDemand < Fog::Service - API_URL = 'https://api.stormondemand.com/v1' + API_URL = 'https://api.stormondemand.com' + API_VERSION = 'v1' requires :storm_on_demand_username, :storm_on_demand_password recognizes :storm_on_demand_auth_url @@ -38,6 +39,7 @@ module Fog request :add_balancer_node request :list_balancers request :list_configs + request :get_config_details request :list_templates request :list_images request :get_stats @@ -109,7 +111,7 @@ module Fog 'Authorization' => 'Basic ' << Base64.encode64("#{@storm_on_demand_username}:#{@storm_on_demand_password}").chomp }.merge!(params[:headers] || {}), :host => @host, - :path => "#{@path}/#{params[:path]}", + :path => "#{@path}/#{API_VERSION}#{params[:path]}", :expects => 200, :method => :post })) diff --git a/lib/fog/storm_on_demand/models/compute/config.rb b/lib/fog/storm_on_demand/models/compute/config.rb index 0968cbe5a..cf0d34db3 100644 --- a/lib/fog/storm_on_demand/models/compute/config.rb +++ b/lib/fog/storm_on_demand/models/compute/config.rb @@ -10,18 +10,30 @@ module Fog attribute :active attribute :available attribute :category + attribute :cpu_cores + attribute :cpu_count + attribute :cpu_hyperthreading + attribute :cpu_model + attribute :cpu_speed attribute :description attribute :disk + attribute :disk_count + attribute :disk_total + attribute :disk_type attribute :featured attribute :memory + attribute :raid_level + attribute :ram_available + attribute :ram_total attribute :price attribute :vcpu - end + attribute :zone_availability + + def initialize(attributes={}) + super + end - def initialize(attributes={}) - super end - end end end diff --git a/lib/fog/storm_on_demand/models/compute/configs.rb b/lib/fog/storm_on_demand/models/compute/configs.rb index 8932a7e59..eb0768e3c 100644 --- a/lib/fog/storm_on_demand/models/compute/configs.rb +++ b/lib/fog/storm_on_demand/models/compute/configs.rb @@ -9,11 +9,15 @@ module Fog model Fog::Compute::StormOnDemand::Config - def all - data = service.list_configs.body['items'] + def all(options={}) + data = service.list_configs(options).body['items'] load(data) end + def get(config_id) + data = service.get_config_details(:id => config_id).body + new(data) + end end diff --git a/lib/fog/storm_on_demand/requests/compute/get_config_details.rb b/lib/fog/storm_on_demand/requests/compute/get_config_details.rb new file mode 100644 index 000000000..602f23ac5 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_config_details.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_config_details(options={}) + request( + :path => '/Storm/Config/details', + :body => Fog::JSON.encode({ :params => options }) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/list_configs.rb b/lib/fog/storm_on_demand/requests/compute/list_configs.rb index 8744d805d..bd47803f9 100644 --- a/lib/fog/storm_on_demand/requests/compute/list_configs.rb +++ b/lib/fog/storm_on_demand/requests/compute/list_configs.rb @@ -6,7 +6,7 @@ module Fog def list_configs(options = {}) request( :path => "/storm/config/list", - :body => Fog::JSON.encode(options) + :body => Fog::JSON.encode(:params => options) ) end