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-12-22 18:22:50 -05:00
|
|
|
service.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
|
2012-12-22 18:22:50 -05:00
|
|
|
data = service.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(
|
2012-12-22 18:22:50 -05:00
|
|
|
:service => service,
|
2011-10-05 05:58:50 -04:00
|
|
|
:href => self.href,
|
2012-12-22 18:22:50 -05:00
|
|
|
:collection => Fog::Vcloud::Compute::Vapps.new(:service => service)
|
2011-10-05 05:58:50 -04:00
|
|
|
)
|
2011-05-23 21:17:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|