mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud|compute] update catalog models for 1.0
This commit is contained in:
parent
7e351ff91d
commit
62ede3ea37
4 changed files with 73 additions and 16 deletions
|
@ -1,25 +1,19 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Vcloud
|
module Vcloud
|
||||||
class Compute
|
class Compute
|
||||||
class Catalog < Fog::Vcloud::Collection
|
class Catalog < Fog::Vcloud::Model
|
||||||
|
|
||||||
model Fog::Vcloud::Compute::CatalogItem
|
identity :href, :aliases => :Href
|
||||||
|
|
||||||
attribute :href, :aliases => :Href
|
ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
|
||||||
|
|
||||||
def all
|
attribute :type
|
||||||
check_href!
|
attribute :name
|
||||||
if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem]
|
|
||||||
load(data)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def get(uri)
|
def catalog_items
|
||||||
if data = connection.get_catalog_item(uri)
|
@catalog_items ||= Fog::Vcloud::Compute::CatalogItems.
|
||||||
new(data.body)
|
new( :connection => connection,
|
||||||
end
|
:href => href )
|
||||||
rescue Fog::Errors::NotFound
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
32
lib/fog/compute/models/vcloud/catalog_items.rb
Normal file
32
lib/fog/compute/models/vcloud/catalog_items.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
module Fog
|
||||||
|
module Vcloud
|
||||||
|
class Compute
|
||||||
|
class CatalogItems < Fog::Vcloud::Collection
|
||||||
|
|
||||||
|
undef_method :create
|
||||||
|
|
||||||
|
model Fog::Vcloud::Compute::CatalogItem
|
||||||
|
|
||||||
|
attribute :href, :aliases => :Href
|
||||||
|
|
||||||
|
def all
|
||||||
|
data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem]
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(uri)
|
||||||
|
if data = connection.get_catalog_item(uri)
|
||||||
|
new(data.body)
|
||||||
|
end
|
||||||
|
rescue Fog::Errors::NotFound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def organization_uri
|
||||||
|
@organization_uri ||= connection.default_organization_uri
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
28
lib/fog/compute/models/vcloud/catalogs.rb
Normal file
28
lib/fog/compute/models/vcloud/catalogs.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
module Fog
|
||||||
|
module Vcloud
|
||||||
|
class Compute
|
||||||
|
class Catalogs < Fog::Vcloud::Collection
|
||||||
|
|
||||||
|
model Fog::Vcloud::Compute::Catalog
|
||||||
|
|
||||||
|
def all
|
||||||
|
data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(uri)
|
||||||
|
if data = connection.get_catalog(uri)
|
||||||
|
new(data.body)
|
||||||
|
end
|
||||||
|
rescue Fog::Errors::NotFound
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def organization_uri
|
||||||
|
@organization_uri ||= connection.default_organization_uri
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -538,8 +538,11 @@ module Fog
|
||||||
recognizes :provider # remove post deprecation
|
recognizes :provider # remove post deprecation
|
||||||
|
|
||||||
model_path 'fog/compute/models/vcloud'
|
model_path 'fog/compute/models/vcloud'
|
||||||
model :catalog_item
|
|
||||||
model :catalog
|
model :catalog
|
||||||
|
require 'fog/compute/models/vcloud/catalog' # why do I need to do this?
|
||||||
|
collection :catalogs
|
||||||
|
model :catalog_item
|
||||||
|
model :catalog_items
|
||||||
model :ip
|
model :ip
|
||||||
collection :ips
|
collection :ips
|
||||||
model :network
|
model :network
|
||||||
|
|
Loading…
Reference in a new issue