Class: VCloud::VApp

Inherits:
BaseVCloudEntity show all
Includes:
ParsesXml
Defined in:
lib/vcloud/user/vapp.rb

Overview

A vApp is a collection of VMs, network config, etc.

Defined Under Namespace

Modules: UndeployPowerAction

Instance Method Summary collapse

Methods included from ParsesXml

included

Methods inherited from BaseVCloudEntity

attr_accessor, attr_reader, attr_writer, from_reference, inherited, #initialize, type

Methods included from RestApi

#build_generic_http_opts, #create, #delete, #http_request, #parse_response, #post, #refresh, #update

Constructor Details

This class inherits a constructor from VCloud::BaseVCloudEntity

Instance Method Details

#parse_xml(xml) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/vcloud/user/vapp.rb', line 63

def parse_xml(xml)
  super xml
  if self.session
    self.tasks.each do |task|
      task.session = self.session
    end
  end
end

#post_task(link) ⇒ Object



72
73
74
75
76
77
# File 'lib/vcloud/user/vapp.rb', line 72

def post_task(link)
  result = post(link.href, nil, VCloud::Constants::ACCEPT_HEADER)
  task = VCloud::Task.from_xml(result)
  task.session = self.session       
  task  
end

#power_onVCloud::Task

Power on all VMs iin the vApp. This operation is available only for a vApp that is powered off.

Returns:

  • (VCloud::Task)

    Task used to monitor the power on event



15
16
17
18
# File 'lib/vcloud/user/vapp.rb', line 15

def power_on
  link = links.select{ |l| l.rel == "power:powerOn" }.first
  post_task(link) 
end

#removeVCloud::Task

Delete the vApp

Returns:

  • (VCloud::Task)

    Task used to monitor the delete vApp event



33
34
35
36
37
38
39
# File 'lib/vcloud/user/vapp.rb', line 33

def remove
  link = links.select{ |l| l.rel == "remove" }.first
  result = delete(link.href, nil, VCloud::Constants::ACCEPT_HEADER)
  task = VCloud::Task.from_xml(result)
  task.session = session
  task
end

#undeploy(power_action) ⇒ VCloud::Task

Undeployment deallocates all resources used by the vApp and the VMs it contains

Parameters:

Returns:

  • (VCloud::Task)

    Task used to monitor the undeploy vApp event



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vcloud/user/vapp.rb', line 50

def undeploy(power_action)             
  undeploy_params = UndeployVAppParams.new
  undeploy_params.undeploy_power_action = power_action

  link = links.select{ |l| l.rel == "undeploy" }.first

  result = post(link.href, undeploy_params.to_xml, VCloud::Constants::ContentType::UNDEPLOY_VAPP_PARAMS) 
  
  task = VCloud::Task.from_xml(result)
  task.session = self.session
  task
end