| 1 | package VMware::vCloud::vApp; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | $VMware::vCloud::vApp::VERSION = '2.404'; | |||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | VMware::vCloud::vApp | ||||||||||
| 13 | |||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||
| 15 | |||||||||||
| 16 | This module is instanciated to represent a vApp on vCloud Director. As such, | ||||||||||
| 17 | it contains methods that interact with the specific vApp this object represents. | ||||||||||
| 18 | |||||||||||
| 19 | This is an internal module to VMware::vCloud and is not designed to be used | ||||||||||
| 20 | independantly. You obtain a vApp object by using the get_vapp() method availble | ||||||||||
| 21 | in VMware::vCloud. | ||||||||||
| 22 | |||||||||||
| 23 | =head1 METHODS | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 28 | 0 | my $class = shift @_; | |||||||||
| 29 | 0 | our $api = shift @_; | |||||||||
| 30 | 0 | our $href = shift @_; | |||||||||
| 31 | |||||||||||
| 32 | 0 | my $self = {}; | |||||||||
| 33 | 0 | bless($self,$class); | |||||||||
| 34 | |||||||||||
| 35 | 0 | our $data = $api->vapp_get($href); | |||||||||
| 36 | |||||||||||
| 37 | 0 | return $self; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | =head2 available_actions() | ||||||||||
| 41 | |||||||||||
| 42 | This method returns a hash or hashref of available actions that can be performed | ||||||||||
| 43 | on the VM. (Eg: Powering on, deploying, etc.) | ||||||||||
| 44 | |||||||||||
| 45 | Each key represents and action and each value is the corresponding href for | ||||||||||
| 46 | said action to be executed. | ||||||||||
| 47 | |||||||||||
| 48 | =cut | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub available_actions { | ||||||||
|
Subroutine
available_actions: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 51 | 0 | my %actions; | |||||||||
| 52 | 0 | for my $action ( @{ our $data->{Link} } ) { | |||||||||
| 53 | 0 | ▶ | next if $action->{rel} =~ /^(up|down|edit|controlAccess)$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | $actions{$action->{rel}} = $action->{href}; | |||||||||
| 55 | } | ||||||||||
| 56 | 0 | ▶ | return wantarray ? %actions : \%actions; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | =head2 dumper() | ||||||||||
| 60 | |||||||||||
| 61 | This debugging method returns the internal data structure representing all | ||||||||||
| 62 | known information on the vApp. | ||||||||||
| 63 | |||||||||||
| 64 | =cut | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub dumper { | ||||||||
|
Subroutine
dumper: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 67 | 0 | return our $data; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | =head2 power_on($vappid) | ||||||||||
| 71 | |||||||||||
| 72 | If it is an available action, it creates the task to power on a vApp. | ||||||||||
| 73 | |||||||||||
| 74 | It returns an array or arraref with three items: returned message, returned | ||||||||||
| 75 | numeric code, and a hashref of the full XML data returned. | ||||||||||
| 76 | |||||||||||
| 77 | The "Power On" action will deploy the vApp if it is currently undeployed. | ||||||||||
| 78 | |||||||||||
| 79 | A text error message is returned if the app is currently not able to be powered | ||||||||||
| 80 | on. (IE: It is already on, or is busy with another task.) | ||||||||||
| 81 | |||||||||||
| 82 | =cut | ||||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | sub power_on { | ||||||||
|
Subroutine
power_on: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 85 | 0 | my $self = shift @_; | |||||||||
| 86 | 0 | my %actions = $self->available_actions(); | |||||||||
| 87 | 0 | ▶ | return "Error: Unable to Power On the vApp at this time.\n" . Dumper(\%actions) unless defined $actions{'power:powerOn'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | |||||||||||
| 89 | 0 | return our $api->post($actions{'power:powerOn'}); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 0 | ▶ | sub power_off { | ||||||||
|
Subroutine
power_off: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 93 | |||||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 0 | ▶ | sub recompose { | ||||||||
|
Subroutine
recompose: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 97 | |||||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 2 | 1; | |||||||||
| 101 | |||||||||||
| 102 | __END__ | ||||||||||