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
|
collection :servers
|
||||||
model :task
|
model :task
|
||||||
collection :tasks
|
collection :tasks
|
||||||
|
model :vapp
|
||||||
|
collection :vapps
|
||||||
model :vdc
|
model :vdc
|
||||||
collection :vdcs
|
collection :vdcs
|
||||||
model :organization
|
model :organization
|
||||||
|
@ -300,7 +302,6 @@ module Fog
|
||||||
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
||||||
parser << response.body
|
parser << response.body
|
||||||
parser.finish
|
parser.finish
|
||||||
|
|
||||||
response.body = document.body
|
response.body = document.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,14 @@ module Fog
|
||||||
attribute :href, :aliases => :Href
|
attribute :href, :aliases => :Href
|
||||||
|
|
||||||
def all
|
def all
|
||||||
check_href!(:parent => "Vdc")
|
if self.href =~ /\/vdc\//
|
||||||
load(_vapps)
|
check_href!("Vdc")
|
||||||
|
load(_vapps)
|
||||||
|
else
|
||||||
|
check_href!("Vapp")
|
||||||
|
attributes[:vapp].load_unless_loaded!
|
||||||
|
load(attributes[:vapp].children)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(uri)
|
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 )
|
:href => href )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def vapps
|
||||||
|
@vapps ||= Fog::Vcloud::Compute::Vapps.
|
||||||
|
new( :connection => connection,
|
||||||
|
:href => href
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def collection_based_on_type(type, klass = nil)
|
def collection_based_on_type(type, klass = nil)
|
||||||
|
@ -39,6 +46,8 @@ module Fog
|
||||||
case type
|
case type
|
||||||
when "application/vnd.vmware.vcloud.catalog+xml"
|
when "application/vnd.vmware.vcloud.catalog+xml"
|
||||||
Fog::Vcloud::Compute::Catalog
|
Fog::Vcloud::Compute::Catalog
|
||||||
|
when "application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
Fog::Vcloud::Compute::Vapp
|
||||||
end.new( :connection => connection, :href => link[:href] )
|
end.new( :connection => connection, :href => link[:href] )
|
||||||
else
|
else
|
||||||
[ ]
|
[ ]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue