2011-08-24 21:11:42 -04:00
|
|
|
require 'fog/vcloud/models/compute/server'
|
2011-05-23 21:17:16 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Vcloud
|
|
|
|
class Compute
|
|
|
|
|
|
|
|
class Servers < Fog::Vcloud::Collection
|
|
|
|
|
|
|
|
undef_method :create
|
|
|
|
|
|
|
|
model Fog::Vcloud::Compute::Server
|
|
|
|
|
|
|
|
attribute :href, :aliases => :Href
|
|
|
|
|
|
|
|
def all
|
2011-10-05 05:58:50 -04:00
|
|
|
check_href!("Vapp")
|
|
|
|
vapp.load_unless_loaded!
|
|
|
|
load(vapp.children||[])
|
2011-05-23 21:17:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-01-30 09:24:14 -05:00
|
|
|
connection.get_vapp(uri)
|
2011-05-23 21:17:16 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2011-06-09 00:53:41 -04:00
|
|
|
def create options
|
2011-05-30 01:17:53 -04:00
|
|
|
check_href!
|
2011-05-23 21:17:16 -04:00
|
|
|
options[:vdc_uri] = href
|
2011-06-09 00:53:41 -04:00
|
|
|
data = connection.instantiate_vapp_template(options).body
|
2011-05-23 21:17:16 -04:00
|
|
|
object = new(data)
|
|
|
|
object
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2011-10-05 05:58:50 -04:00
|
|
|
def vapp
|
|
|
|
@vapp ||= (attributes[:vapp] || init_vapp)
|
2011-05-23 21:17:16 -04:00
|
|
|
end
|
|
|
|
|
2011-10-05 05:58:50 -04:00
|
|
|
def init_vapp
|
|
|
|
Fog::Vcloud::Compute::Vapp.new(
|
|
|
|
:connection => connection,
|
|
|
|
:href => self.href,
|
|
|
|
:collection => Fog::Vcloud::Compute::Vapps.new(:connection => connection)
|
|
|
|
)
|
2011-05-23 21:17:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|