1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
This commit is contained in:
Eugene Howe 2012-04-11 19:50:01 -04:00
parent 0492b896da
commit bc87c0c9a9
5 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,19 @@
module Fog
module Compute
class Ecloud
class ComputePool < Fog::Ecloud::Model
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i
attribute :name, :aliases => :Name
attribute :id, :aliases => :Id
attribute :href, :aliases => :Href
attribute :state, :aliases => :State
attribute :is_default, :aliases => :IsDefault
end
end
end
end

View file

@ -0,0 +1,36 @@
require 'fog/ecloud/models/compute/compute_pool'
module Fog
module Compute
class Ecloud
class ComputePools < Fog::Ecloud::Collection
undef_method :create
attribute :href, :aliases => :Href
model Fog::Compute::Ecloud::ComputePool
#get_request :get_compute_pool
#vcloud_type "application/vnd.tmrk.ecloud.publicIp+xml"
#all_request lambda { |compute_pools| public_ips.connection.get_public_ips(public_ips.href) }
def all
check_href!(:message => "the Compute Pool href of the Vdc you want to enumerate")
if data = connection.get_compute_pools(href).body[:ComputePool]
load(data)
end
end
def get(uri)
if data = connection.get_compute_pool(uri)
new(data.body)
end
rescue Fog::Errors::NotFound
nil
end
end
end
end
end

View file

@ -56,6 +56,12 @@ module Fog
@firewall_acls ||= collection_based_on_type("application/vnd.tmrk.ecloud.firewallAclsList+xml")
end
def compute_pools
@compute_pools ||= Fog::Compute::Ecloud::ComputePools.
new( :connection => connection,
:href => href + "/computePools" )
end
private
def collection_based_on_type(type, klass = nil)

View file

@ -0,0 +1,36 @@
module Fog
module Compute
class Ecloud
class Real
basic_request :get_compute_pool
end
class Mock
#
#Based off of:
#http://support.theenterprisecloud.com/kb/default.asp?id=567&Lang=1&SID=
#
def get_compute_pool(compute_pool_uri)
compute_pool_uri = ensure_unparsed(compute_pool_uri)
if compute_pool = mock_data.compute_pool_from_href(compute_pool_uri)
xml = Builder::XmlMarkup.new
mock_it 200,
xml.ComputePool(:xmlns => "urn:tmrk:eCloudExtensions-2.0", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {
xml.Id compute_pool.object_id
xml.Href compute_pool.href
xml.Name compute_pool.name
xml.State compute_pool.state
xml.IsDefault compute_pool.is_default
}, { 'Content-Type' => 'application/vnd.tmrk.ecloud.computePoolsList+xml' }
else
mock_error 200, "401 Unauthorized"
end
end
end
end
end
end

View file

@ -0,0 +1,40 @@
module Fog
module Compute
class Ecloud
class Real
basic_request :get_compute_pools
end
class Mock
#
# Based off of:
# http://support.theenterprisecloud.com/kb/default.asp?id=577&Lang=1&SID=
#
def get_compute_pools(compute_pools_uri)
compute_pools_uri = ensure_unparsed(compute_pools_uri)
if compute_pool_collection = mock_data.compute_pool_collection_from_href(compute_pools_uri)
xml = Builder::XmlMarkup.new
mock_it 200,
xml.ComputePools {
compute_pool_collection.items.each do |cp|
xml.ComputePool {
xml.Id cp.object_id
xml.Href cp.href
xml.Name cp.name
xml.State cp.state
xml.IsDefault cp.is_default
}
end
}, { 'Content-Type' => 'application/vnd.tmrk.ecloud.computePoolsList+xml'}
else
mock_error 200, "401 Unauthorized"
end
end
end
end
end
end