mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
more read-only terremark/vcloud support
This commit is contained in:
parent
32f4af0ecf
commit
aac4131c37
6 changed files with 188 additions and 2 deletions
|
@ -4,12 +4,16 @@ module Fog
|
|||
def self.dependencies
|
||||
[
|
||||
'fog/terremark/parsers/get_catalog.rb',
|
||||
'fog/terremark/parsers/get_catalog_item.rb',
|
||||
'fog/terremark/parsers/get_organization.rb',
|
||||
'fog/terremark/parsers/get_organizations.rb',
|
||||
'fog/terremark/parsers/get_vapp_template.rb',
|
||||
'fog/terremark/parsers/get_vdc.rb',
|
||||
'fog/terremark/requests/get_catalog.rb',
|
||||
'fog/terremark/requests/get_catalog_item.rb',
|
||||
'fog/terremark/requests/get_organization.rb',
|
||||
'fog/terremark/requests/get_organizations.rb',
|
||||
'fog/terremark/requests/get_vapp_template.rb',
|
||||
'fog/terremark/requests/get_vdc.rb'
|
||||
]
|
||||
end
|
||||
|
|
44
lib/fog/terremark/parsers/get_catalog_item.rb
Normal file
44
lib/fog/terremark/parsers/get_catalog_item.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Terremark
|
||||
|
||||
class GetCatalogItem < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@property_key
|
||||
@response = { 'Entity' => {}, 'Properties' => {} }
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
@value = ''
|
||||
case name
|
||||
when 'Entity'
|
||||
until attributes.empty?
|
||||
@response['Entity'][attributes.shift] = attributes.shift
|
||||
end
|
||||
when 'CatalogItem'
|
||||
catalog_item = {}
|
||||
until attributes.empty?
|
||||
if attributes.first.is_a?(Array)
|
||||
catalog_item[attributes.first.first] = attributes.shift.last
|
||||
else
|
||||
catalog_item[attributes.shift] = attributes.shift
|
||||
end
|
||||
end
|
||||
@response['name'] = catalog_item['name']
|
||||
when 'Property'
|
||||
@property_key = attributes.last
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if name == 'Property'
|
||||
@response['Properties'][@property_key] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
class GetOrganization < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'links' => [] }
|
||||
@response = { 'Links' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
|
@ -16,7 +16,7 @@ module Fog
|
|||
until attributes.empty?
|
||||
link[attributes.shift] = attributes.shift
|
||||
end
|
||||
@response['links'] << link
|
||||
@response['Links'] << link
|
||||
when 'Org'
|
||||
org = {}
|
||||
until attributes.empty?
|
||||
|
|
44
lib/fog/terremark/parsers/get_vapp_template.rb
Normal file
44
lib/fog/terremark/parsers/get_vapp_template.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Terremark
|
||||
|
||||
class GetVappTemplate < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@property_key
|
||||
@response = { 'Links' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
@value = ''
|
||||
case name
|
||||
when 'Link'
|
||||
link = {}
|
||||
until attributes.empty?
|
||||
link[attributes.shift] = attributes.shift
|
||||
end
|
||||
@response['Links'] << link
|
||||
when 'VAppTemplate'
|
||||
vapp_template = {}
|
||||
until attributes.empty?
|
||||
if attributes.first.is_a?(Array)
|
||||
vapp_template[attributes.first.first] = attributes.shift.last
|
||||
else
|
||||
vapp_template[attributes.shift] = attributes.shift
|
||||
end
|
||||
end
|
||||
@response['name'] = vapp_template['name']
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if name == 'Description'
|
||||
@response['Description'] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
47
lib/fog/terremark/requests/get_catalog_item.rb
Normal file
47
lib/fog/terremark/requests/get_catalog_item.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
unless Fog.mocking?
|
||||
|
||||
module Fog
|
||||
class Terremark
|
||||
|
||||
# Get details of a catalog item
|
||||
#
|
||||
# ==== Parameters
|
||||
# * catalog_item_id<~Integer> - Id of catalog item to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
|
||||
# FIXME
|
||||
|
||||
# * 'CatalogItems'<~Array>
|
||||
# * 'href'<~String> - linke to item
|
||||
# * 'name'<~String> - name of item
|
||||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
def get_catalog_item(catalog_item_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Terremark::GetCatalogItem.new,
|
||||
:path => "catalogItem/#{catalog_item_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
module Fog
|
||||
class Terremark
|
||||
|
||||
def get_catalog_item(catalog_item_id)
|
||||
raise MockNotImplemented.new("Contributions welcome!")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
47
lib/fog/terremark/requests/get_vapp_template.rb
Normal file
47
lib/fog/terremark/requests/get_vapp_template.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
unless Fog.mocking?
|
||||
|
||||
module Fog
|
||||
class Terremark
|
||||
|
||||
# Get details of a vapp template
|
||||
#
|
||||
# ==== Parameters
|
||||
# * vapp_template_id<~Integer> - Id of vapp template to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
|
||||
# FIXME
|
||||
|
||||
# * 'CatalogItems'<~Array>
|
||||
# * 'href'<~String> - linke to item
|
||||
# * 'name'<~String> - name of item
|
||||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
def get_vapp_template(vapp_template_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Terremark::GetVappTemplate.new,
|
||||
:path => "vAppTemplate/#{vapp_template_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
module Fog
|
||||
class Terremark
|
||||
|
||||
def get_vapp_template(vapp_template_id)
|
||||
raise MockNotImplemented.new("Contributions welcome!")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue