mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud|compute] introduce vapps
This commit is contained in:
parent
3024678e2a
commit
f2c90dcc7f
5 changed files with 79 additions and 3 deletions
|
@ -83,6 +83,8 @@ module Fog
|
|||
collection :servers
|
||||
model :task
|
||||
collection :tasks
|
||||
model :vapp
|
||||
collection :vapps
|
||||
model :vdc
|
||||
collection :vdcs
|
||||
model :organization
|
||||
|
@ -300,7 +302,6 @@ module Fog
|
|||
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
||||
parser << response.body
|
||||
parser.finish
|
||||
|
||||
response.body = document.body
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,14 @@ module Fog
|
|||
attribute :href, :aliases => :Href
|
||||
|
||||
def all
|
||||
check_href!(:parent => "Vdc")
|
||||
load(_vapps)
|
||||
if self.href =~ /\/vdc\//
|
||||
check_href!("Vdc")
|
||||
load(_vapps)
|
||||
else
|
||||
check_href!("Vapp")
|
||||
attributes[:vapp].load_unless_loaded!
|
||||
load(attributes[:vapp].children)
|
||||
end
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
|
|
29
lib/fog/vcloud/models/compute/vapp.rb
Normal file
29
lib/fog/vcloud/models/compute/vapp.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
class Vapp < Fog::Vcloud::Model
|
||||
|
||||
identity :href
|
||||
|
||||
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
|
||||
|
||||
attribute :name
|
||||
attribute :type
|
||||
attribute :status
|
||||
attribute :description
|
||||
attribute :deployed, :type => :boolean
|
||||
attribute :children, :aliases => :Children, :squash => :Vm
|
||||
attribute :lease_settings, :aliases => :LeaseSettingsSection
|
||||
attribute :other_links, :aliases => :Link
|
||||
|
||||
def servers
|
||||
@servers ||= Fog::Vcloud::Compute::Servers.
|
||||
new( :connection => connection,
|
||||
:href => href,
|
||||
:vapp => self
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/vcloud/models/compute/vapps.rb
Normal file
31
lib/fog/vcloud/models/compute/vapps.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'fog/vcloud/models/compute/vapp'
|
||||
|
||||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
|
||||
class Vapps < Collection
|
||||
|
||||
model Fog::Vcloud::Compute::Vapp
|
||||
|
||||
undef_method :create
|
||||
|
||||
attribute :href
|
||||
|
||||
def all
|
||||
data = connection.get_vdc(self.href).body[:ResourceEntities][:ResourceEntity].select { |re| re[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(uri)
|
||||
if data = connection.get_vapp(uri)
|
||||
new(data.body)
|
||||
end
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -30,6 +30,13 @@ module Fog
|
|||
:href => href )
|
||||
end
|
||||
|
||||
def vapps
|
||||
@vapps ||= Fog::Vcloud::Compute::Vapps.
|
||||
new( :connection => connection,
|
||||
:href => href
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def collection_based_on_type(type, klass = nil)
|
||||
|
@ -39,6 +46,8 @@ module Fog
|
|||
case type
|
||||
when "application/vnd.vmware.vcloud.catalog+xml"
|
||||
Fog::Vcloud::Compute::Catalog
|
||||
when "application/vnd.vmware.vcloud.vApp+xml"
|
||||
Fog::Vcloud::Compute::Vapp
|
||||
end.new( :connection => connection, :href => link[:href] )
|
||||
else
|
||||
[ ]
|
||||
|
|
Loading…
Reference in a new issue