| 1 | package VMware::vCloud; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Cache::Bounded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use VMware::API::vCloud; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use VMware::vCloud::vApp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | $VMware::vCloud::VERSION = '2.404'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | VMware::vCloud - VMware vCloud Director | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | my $vcd = new VMware::vCloud ( $hostname, $username, $password, $orgname, { debug => 1 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | my %vapps = $vcd->list_vapps(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my $vappid = $vapps{'My Personal vApp'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $vapp = $vcd->get_vapp($vappid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $ret = $vapp->power_on(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | This module provides a Perl interface to VMware's vCloud Director. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | It's intention is to provide a high-level perl-style interface to vCloud | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | Director actions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | If you are looking for a direct and low-level access to the vCloud API, you may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | want to look at VMware::API::vCloud, which is packaged and used by this module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 END OF LIFE NOTICE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | VMware marked vCloud Director as "End of Availability" on March 12, 2015. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | (This was as part of vCloud Suite 6. The standalone vCloud Director was EOA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | in September 2013.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | Correspondingly, this module will likely see no further development. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 COMPATIBILITY WARNING: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | This fork is incompatible with original VMware::vCloud, as it uses only "id" as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | the XML key to convert its data tree into a perl hash. Not the implicit set of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | "name, key, id" (in that order). Name may not be unique and returned datasets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | can contain overwritten data when used. Due to this change, many API call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | wrappers will fail, without prior adjusting to either work with "id" identifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | or handling received ARRAYREF instead of HASHREF (in case of missing "id", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | no associative array is created). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | If you wish to avoid this compatibility change, use release 2.402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =head1 EXAMPLE SCRIPTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | Included in the distribution of this module are several example scripts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Hopefully they provide an illustrative example of the use of vCloud Director. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | All scripts have their own POD and accept command line parameters in a similar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | way to the VIPERL SDK utilities and vghetto scripts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | login.pl - An example script that demonstrates logging in to the server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | org_get.pl - Selects a random organization and prints a Data::Dumper dump of it's information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | list-vapps.pl - Prints a list of all VMs the user has access to. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | =head1 MODULE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =head2 new($host,$user,$pass,$org,$conf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | This method instances the VMware::vCloud object and verifies the user can log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | onto the server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $host, $user, and $pass are required. They should contain the login information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | for the vCloud server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $org and $conf are optional. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $org is the vCloud Organization to connect to. If $org is not given, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | default of 'System' is used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | $conf is an optional hasref containing tuneable parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | * debug - set to a true value to turn on STDERR debugging statements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $class = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | our $host = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | our $user = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | our $pass = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | our $org = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | our $conf = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $org = 'System' unless $org; # Default to "System" org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | bless($self,$class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | our $cache = new Cache::Bounded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->{api} = new VMware::API::vCloud ($host,$user,$pass,$org,$conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $self->{raw_login_data} = $self->{api}->login(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $self->{api}->logout() if defined $self->{api}->{have_session} and $self->{api}->{have_session} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"api"}{"have_session"} and $self->{"api"}{"have_session"} > 0
MC/DC0%0/2
defined $self->{"api"}{"have_session"} and $self->{"api"}{"have_session"} > 0
defined $self->{"api"}{"have_session"}
$self->{"api"}{"have_session"} > 0
Truth table0%0/3
A and B
A= defined $self->{"api"}{"have_session"}B= $self->{"api"}{"have_session"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =head2 debug(1|0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | This turns debugging on and off programatically. An argument of '1' for debugging, '0' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | for no debugging. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $val = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{api}->{debug} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | =head2 login() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | This method is deprecated and will be removed in later releases. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | This method roughly emulates the default login action of the API: It returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | information on which organizations are accessible to the user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | It is a synonym for list_orgs() and all details on return values should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | take from that method's documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub login { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
login: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $self->list_orgs(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | =head2 purge() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | This method clears the in-module caching of API responses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | This module caches many API calls to reduce response times and load on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | server. This cache is automatically cleared when a method that changes the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | status of the VCD server is called. However, there may be times when you have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | a lon running process, or wish to manually clear the cache yourself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub purge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
purge: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | our $cache->purge(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ### Standard methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =head1 VAPP METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =head2 create_vapp_from_template($name,$vdcid,$tmplid,$netid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | Given a name, VDC, template and network, instantiate the template with the given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | settings and other defaults. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | Details of the create task will be returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # bridged, isolated, or natRouted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # NONE, MANUAL, POOL, DHCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub create_vapp_from_template { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_vapp_from_template: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $name = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $vdcid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $tmplid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $netid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my %template = $self->get_template($tmplid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my %vdc = $self->get_vdc($vdcid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my @links = @{$vdc{Link}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | for my $ref (@links) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | #$url = $ref->{href} if $ref->{type} eq 'application/vnd.vmware.vcloud.composeVAppParams+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $url = $ref->{href} if $ref->{type} eq 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $fencemode = 'bridged'; # bridged, isolated, or natRouted | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $IpAddressAllocationMode = 'POOL'; # NONE, MANUAL, POOL, DHCP | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return $self->{api}->vapp_create_from_template($url,$name,$netid,'bridged',$template{href},'POOL',$vdcid,$tmplid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | =head2 create_vapp_from_sources(...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | Create a vApp from varied sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | Details of the create task will be returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # bridged, isolated, or natRouted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # NONE, MANUAL, POOL, DHCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub create_vapp_from_sources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_vapp_from_sources: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $name = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $vdcid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $tmplid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $netid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my %template = $self->get_template($tmplid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my %vdc = $self->get_vdc($vdcid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @links = @{$vdc{Link}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | for my $ref (@links) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | #$url = $ref->{href} if $ref->{type} eq 'application/vnd.vmware.vcloud.composeVAppParams+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $url = $ref->{href} if $ref->{type} eq 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $fencemode = 'bridged'; # bridged, isolated, or natRouted | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $IpAddressAllocationMode = 'POOL'; # NONE, MANUAL, POOL, DHCP | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $self->{api}->vapp_create_from_sources($url,$name,$netid,'bridged',$template{href},'POOL',$vdcid,$tmplid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | =head2 delete_vapp($vapp_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | Given the org HREF, call a delete on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub delete_vapp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_vapp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->purge(); # Clear cache when deleting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return $self->{api}->delete($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | =head2 get_vapp($vappid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | Given an vApp id, it returns a vApp object for that vApp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | See the documentation on VMware::vCloud::vApp for full details on this object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub get_vapp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_vapp: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $vapp = our $cache->get('get_vapp:'.$href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return $vapp if defined $vapp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $vapp = new VMware::vCloud::vApp ( $self->{api}, $href ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $cache->set('get_vapp:'.$href,$vapp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return $vapp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | =head2 list_vapps() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | This method returns a hash or hashref of Template names and IDs the user has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | access too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | sub list_vapps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_vapps: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $vapps = our $cache->get('list_vapps:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | unless ( defined $vapps ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my %vdcs = $self->list_vdcs($self->{'api'}{'orgname'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | for my $vdcid ( keys %vdcs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my %vdc = $self->get_vdc($vdcid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | for my $entity ( @{$vdc{ResourceEntities}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | for my $name ( keys %{$entity->{ResourceEntity}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | next unless $entity->{ResourceEntity}->{$name}->{type} eq 'application/vnd.vmware.vcloud.vApp+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $href = $entity->{ResourceEntity}->{$name}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $vapps->{$href} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $cache->set('list_vapps:',$vapps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return wantarray ? %$vapps : $vapps if defined $vapps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | =head1 TEMPLATE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | =head2 get_template($templateid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | Given an organization id, it returns a hash of data for that organization. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub get_template { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_template: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $id = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $tmpl = our $cache->get('get_template:'.$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return %$tmpl if defined $tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $raw_tmpl_data = $self->{api}->template_get($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my %tmpl = %$raw_tmpl_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | #$tmpl{description} = $raw_org_data->{Description}->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | #$tmpl{name} = $raw_org_data->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | #$raw_org_data->{href} =~ /([^\/]+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | #$org{id} = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | #$org{contains} = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | #for my $link ( @{$raw_org_data->{Link}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | #$link->{type} =~ /^application\/vnd.vmware.vcloud.(\w+)\+xml$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | #my $type = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | #$link->{href} =~ /([^\/]+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | #my $id = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | #next if $type eq 'controlAccess'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | #$org{contains}{$type}{$id} = $link->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $cache->set('get_template:'.$id,\%tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return ( wantarray ? %tmpl : \%tmpl ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | =head2 list_templates() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | This method returns a hash or hashref of Template names and IDs the user has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | access too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | sub list_templates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_templates: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $templates = our $cache->get('list_templates:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | return %$templates if defined $templates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my %orgs = $self->list_orgs(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my %vdcs = $self->list_vdcs($self->{'api'}{'orgname'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my %templates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | for my $vdcid ( keys %vdcs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my %vdc = $self->get_vdc($vdcid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | for my $entity ( @{$vdc{ResourceEntities}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | for my $name ( keys %{$entity->{ResourceEntity}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | next unless $entity->{ResourceEntity}->{$name}->{type} eq 'application/vnd.vmware.vcloud.vAppTemplate+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $href = $entity->{ResourceEntity}->{$name}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $templates{$href} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $cache->set('list_templates:',\%templates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | return %templates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | =head1 CATALOG METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | =head2 create_catalog($org_href,$conf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | This method creates a new, empty catalog in the given organization. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | $conf is a hashref that can contain: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | =item * name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | =item * description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | =item * is_published | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Org HREF example: http://example.vcd.server/api/admin/org/{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | sub create_catalog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_catalog: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return $self->{api}->catalog_create(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | =head2 delete_catalog($catalog_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | Given the org HREF, call a delete on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.reference.doc_51%2Fdoc%2Foperations%2FDELETE-Catalog.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub delete_catalog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_catalog: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->purge(); # Clear cache when deleting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | return $self->{api}->delete($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | =head1 ORG METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | =head2 create_org(\%conf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | sub create_org { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_org: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $conf = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return $self->{api}->org_create($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | =head2 delete_org($org_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | Given the org HREF, call a delete on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | sub delete_org { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_org: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $self->purge(); # Clear cache when deleting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return $self->{api}->delete($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | =head2 delete_org_network($org_network_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | Given the org network HREF, call a delete on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | sub delete_org_network { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_org_network: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $self->purge(); # Clear cache when deleting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | return $self->{api}->delete($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | =head2 disable_org($org_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | Given a Org href, call the disable action on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | sub disable_org { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_org: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | $href .= '/action/disable' unless $href =~ /\/action\/disable$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return $self->{api}->post($href,undef,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | =head2 enable_org($org_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | Given a Org href, call the enable action on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub enable_org { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_org: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $href .= '/action/enable' unless $href =~ /\/action\/enable$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return $self->{api}->post($href,undef,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | =head2 get_org($org_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | Given an organization id, it returns a hash or hashref of data for that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | organization. Returned data: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | name - Name of the organization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | description - Description field of the organization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | href - anchor HREF for the organization in the API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | id - UUID identified in the href. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | contains - A hashref of contained objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | catalogs = references to the catalogs within the org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | vdcs - references to the org VDCs within the org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | raw - The raw returned XML structure for the organization from the API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub get_org { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_org: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $id = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $org = our $cache->get('get_org:'.$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | return ( wantarray ? %$org : $org ) if defined $org; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $raw_org_data = $self->{api}->org_get($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my %org; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $org{raw} = $raw_org_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $org{catalogs} = $raw_org_data->{Catalogs}->[0]->{CatalogReference}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $org{description} = $raw_org_data->{Description}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $org{href} = $raw_org_data->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $org{name} = $raw_org_data->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $org{networks} = $raw_org_data->{Networks}->[0]->{Network}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $org{vdcs} = $raw_org_data->{Vdcs}->[0]->{Vdc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $raw_org_data->{href} =~ /([^\/]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $org{id} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $org{contains} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | for my $link ( @{$raw_org_data->{Link}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $link->{type} =~ /^application\/vnd.vmware.vcloud.(\w+)\+xml$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $id = $link->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | next if $type eq 'controlAccess'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $org{contains}{$type}{$id} = $link->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $cache->set('get_org:'.$id,\%org); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | return wantarray ? %org : \%org; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | =head2 list_orgs() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | This method returns a hash or hashref of Organization names and IDs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | sub list_orgs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_orgs: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $orgs = our $cache->get('list_orgs:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | unless ( defined $orgs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $orgs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $ret = $self->{api}->org_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | for my $org ( @{$ret->{Org}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | warn "Org type of $org->{type} listed for $org->{name}\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | unless $org->{type} eq 'application/vnd.vmware.vcloud.org+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my $href = $org->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $orgs->{$org->{name}} = $href; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $cache->set('list_orgs:',$orgs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | return wantarray ? %$orgs : $orgs if defined $orgs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | =head1 ORG VDC METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | =head2 create_vdc($org_url,$conf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | sub create_vdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_vdc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $conf = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | return $self->{api}->org_vdc_create($href,$conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | =head2 delete_vdc($vdc_href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | Given the org VDC HREF, call a delete on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | sub delete_vdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_vdc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $self->purge(); # Clear cache when deleting | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | return $self->{api}->delete($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | =head2 disable_vdc($vdc_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | Given a VDC href, call the disable action on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | sub disable_vdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_vdc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $href .= '/action/disable' unless $href =~ /\/action\/disable$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return $self->{api}->post($href,undef,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | =head2 enable_vdc($vdc_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | Given a VDC href, call the enable action on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | sub enable_vdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_vdc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | $href .= '/action/enable' unless $href =~ /\/action\/enable$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | return $self->{api}->post($href,undef,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | =head2 get_vdc($vdc_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | Given an VDC href, it returns a hash of data for that vDC. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub get_vdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_vdc: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $id = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $vdc = our $cache->get('get_vdc:'.$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | return %$vdc if defined $vdc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $raw_vdc_data = $self->{api}->vdc_get($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my %vdc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $vdc{description} = $raw_vdc_data->{Description}->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $vdc{name} = $raw_vdc_data->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $raw_vdc_data->{href} =~ /([^\/]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $vdc{id} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $vdc{contains} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | for my $link ( @{$raw_vdc_data->{Link}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $link->{type} =~ /^application\/vnd.vmware.vcloud.(\w+)\+xml$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $link->{href} =~ /([^\/]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $id = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | next if $type eq 'controlAccess'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $vdc{contains}{$type}{$id} = $link->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $cache->set('get_vdc:'.$id,$raw_vdc_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | return wantarray ? %$raw_vdc_data : $raw_vdc_data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | =head2 list_vdcs() | list_vdcs($orgid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | This method returns a hash or hashref of VDC names and IDs the user has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | access too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | The optional argument of an $orgname will limit the returned list of VDCs in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | that Organization. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | sub list_vdcs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_vdcs: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $orgname = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | $orgname = '' if !defined $orgname || $orgname =~ /^[sS]ystem$/; # Show all if the org is System | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $orgname or $orgname =~ /^[sS]ystem$/
MC/DC0%0/2
not defined $orgname or $orgname =~ /^[sS]ystem$/
not defined $orgname
$orgname =~ /^[sS]ystem$/
Truth table0%0/3
not(A) or B
A= not defined $orgnameB= $orgname =~ /^[sS]ystem$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $vdcs = our $cache->get("list_vdcs:$orgname:"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | unless ( defined $vdcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $vdcs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my %orgs = $self->list_orgs(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | %orgs = ( $orgname => $orgs{$orgname} ) if defined $orgname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | for my $orgname ( keys %orgs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my %org = $self->get_org($orgs{$orgname}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | for my $vdcid ( keys %{$org{contains}{vdc}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $vdcs->{$vdcid} = $org{contains}{vdc}{$vdcid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $cache->set("list_vdcs:$orgname:",$vdcs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | return wantarray ? %$vdcs : $vdcs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | =head1 PROVIDER VDC METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | =head2 get_pvdc($pvdc_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | Returns a hashref of the information on the PVDC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | sub get_pvdc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_pvdc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | return $self->{api}->pvdc_get($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =head2 list_pvdcs() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | Returns a hashref of the information on available PVDCs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub list_pvdcs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_pvdcs: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $admin_urls = $self->admin_urls(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $pvdcs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | for my $name ( keys %{$admin_urls->{pvdcs}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $href = $admin_urls->{pvdcs}->{$name}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $pvdcs->{$href} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | return wantarray ? %$pvdcs : $pvdcs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | =head1 NETWORK METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | =head2 create_org_network | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | Create an org network | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | The conf hash reference can contain: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | =item * name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | =item * desc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | =item * gateway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | =item * netmask | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | =item * dns1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | =item * dns2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | =item * dnssuffix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | =item * is_enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | =item * is_shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | =item * start_ip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | =item * end_ip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | sub create_org_network { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_org_network: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $conf = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | return $self->{api}->org_network_create($href,$conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | =head2 list_networks() | list_networks($vdcid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | This method returns a hash or hashref of network names and IDs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | Given an optional VDCid it will return only the networks available in that VDC. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | sub list_networks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_networks: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | my $vdcid = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | my $networks = our $cache->get("list_networks:$vdcid:"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | return %$networks if defined $networks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | my %networks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | my %vdcs = ( $vdcid ? ( $vdcid => 1 ) : $self->list_vdcs() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | for my $vdcid ( keys %vdcs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | my %vdc = $self->get_vdc($vdcid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my @networks = @{$vdc{AvailableNetworks}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | for my $netblock (@networks) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | for my $name ( keys %{$netblock->{Network}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my $href = $netblock->{Network}->{$name}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $networks{$name} = $href; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | $cache->set("list_networks:$vdcid:",\%networks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return %networks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | =head1 TASKS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | =head3 get_task($href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | Returns a hash or hashref of the given task. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | Contents include: (but aren't limited to) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | * href | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | * operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | * expiryTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | * startTime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | * Progress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | * operationName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | * operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | * status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | sub get_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_task: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | return $self->{api}->task_get($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | =head3 progress_of_task($task_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | my ($percent,$status) = $vcd->progress_of_task($task_href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | Returns the approximate percentage of completion of the task as an integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | between 1 and 101. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | The text status of the task is returned as well: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | * queued - The task has been queued for execution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | * preRunning - The task is awaiting preprocessing or administrative action. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | * running - The task is running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | * success - The task completed with a status of success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | * error - The task encountered an error while running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | * cancelled - The task was canceled by the owner or an administrator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | * aborted - The task was aborted by an administrative action. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | sub progress_of_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
progress_of_task: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $task = $self->get_task($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $status = $task->{status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if ( $status eq 'queued' or $status eq 'preRunning' or $status eq 'running' or $status eq 'success' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$status eq "queued" or $status eq "preRunning" or $status eq "running" or $status eq "success"
$status eq "queued" or $status eq "preRunning" or $status eq "running"
$status eq "queued" or $status eq "preRunning"
MC/DC0%0/4
$status eq "queued" or $status eq "preRunning" or $status eq "running" or $status eq "success"
$status eq "queued"
$status eq "preRunning"
$status eq "running"
$status eq "success"
Truth table0%0/5
A or B or C or D
A= $status eq "queued"B= $status eq "preRunning"C= $status eq "running"D= $status eq "success"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | return ( $task->{Progress}->[0], $status ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | die Dumper($task); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | return ( (defined $task->{Progress}->[0] ? $task->{Progress}->[0] : 101), $status ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | =head3 wait_on_task($href) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | Given a task href, this method will query the task every second, and only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | return once the task is completed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | Specifically, this method will block and continue to query the task while it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | has any of the following statuses: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | * queued - The task has been queued for execution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | * preRunning - The task is awaiting preprocessing or administrative action. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | * running - The task is running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | Any of the following statuses will cause this method to return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | * success - The task completed with a status of success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | * error - The task encountered an error while running. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | * cancelled - The task was canceled by the owner or an administrator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | * aborted - The task was aborted by an administrative action. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | The return value will be and array or arrayref composed of two elements: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | * The status code returned by the server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | * A hashref comprising the most recently retrived for of the task object. IE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | the same output as get_task() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | sub wait_on_task { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_on_task: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $href = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $task = $self->get_task($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my $status = $task->{status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | while ( $status eq 'queued' or $status eq 'preRunning' or $status eq 'running' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$status eq "queued" or $status eq "preRunning" or $status eq "running"
$status eq "queued" or $status eq "preRunning"
MC/DC0%0/3
$status eq "queued" or $status eq "preRunning" or $status eq "running"
$status eq "queued"
$status eq "preRunning"
$status eq "running"
Truth table0%0/4
A or B or C
A= $status eq "queued"B= $status eq "preRunning"C= $status eq "running"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | sleep 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $task = $self->get_task($href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $status = $task->{status}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | return wantarray ? ( $status, $task ) : [ $status, $task ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | =head1 ADMINISTRATIVE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | =head3 admin_urls() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | Returns the list of administrative action URLs available to the user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | sub admin_urls { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
admin_urls: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | return $self->{api}->admin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | =head3 create_external_network($name,$gateway,$netmask,$dns1,$dns2,$suffix,$vimref,$moref,$objtype) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | ▶ | sub create_external_network { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_external_network: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | my $conf = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | my $xml = ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | <vmext:VMWExternalNetwork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | name="'.$conf->{name}.'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | type="application/vnd.vmware.admin.vmwexternalnet+xml"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | <vcloud:Description>ExternalNet</vcloud:Description> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | <vcloud:Configuration> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | <vcloud:IpScopes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | <vcloud:IpScope> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | <vcloud:IsInherited>false</vcloud:IsInherited> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | <vcloud:Gateway>'.$conf->{gateway}.'</vcloud:Gateway> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | <vcloud:Netmask>'.$conf->{subnet}.'</vcloud:Netmask> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | <vcloud:Dns1>'.$conf->{dns1}.'</vcloud:Dns1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | <vcloud:Dns2>'.$conf->{dns2}.'</vcloud:Dns2> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | <vcloud:DnsSuffix>'.$conf->{suffix}.'</vcloud:DnsSuffix> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | <vcloud:IpRanges> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | <vcloud:IpRange> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | <vcloud:StartAddress>'.$conf->{ipstart}.'</vcloud:StartAddress> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | <vcloud:EndAddress>'.$conf->{ipend}.'</vcloud:EndAddress> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | </vcloud:IpRange> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | </vcloud:IpRanges> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | </vcloud:IpScope> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | </vcloud:IpScopes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | <vcloud:FenceMode>isolated</vcloud:FenceMode> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | </vcloud:Configuration> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | <vmext:VimPortGroupRef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | <vmext:VimServerRef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | href="'.$conf->{vimserver}.'" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | <vmext:MoRef>'.$conf->{mo_ref}.'</vmext:MoRef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | <vmext:VimObjectType>'.$conf->{mo_type}.'</vmext:VimObjectType> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | </vmext:VimPortGroupRef> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | </vmext:VMWExternalNetwork>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | return $self->{api}->post($self->{api}->{learned}->{url}->{admin}.'extension/externalnets','application/vnd.vmware.admin.vmwexternalnet+xml',$xml); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | =head3 extensions() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | Returns the data structure for the admin extensions available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | ▶ | sub extensions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extensions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | return $self->{api}->admin_extension_get(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | =head2 list_datastores() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | Requires using a sysadmin account and attaching to the System org. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | Returns a hash(ref) of datastore information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | sub list_datastores { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_datastores: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | my $ret = $self->{api}->datastore_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | return wantarray ? %{$ret->{DatastoreRecord}} : $ret->{DatastoreRecord}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | =head3 list_external_networks() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | Returns a hash or hasref of all available external networks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | sub list_external_networks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_external_networks: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | my $extensions = $self->extensions(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $extnet_url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | for my $link ( @{$extensions->{'vcloud:Link'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | $extnet_url = $link->{href} if $link->{type} eq 'application/vnd.vmware.admin.vmwExternalNetworkReferences+xml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $ret = $self->{api}->get($extnet_url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | my $externals = $ret->{'vmext:ExternalNetworkReference'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | return wantarray ? %$externals : $externals; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | =head3 list_portgroups() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | Returns a hash or hashref of available portgroups on the first associated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | vcenter server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | sub list_portgroups { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_portgroups: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | my $query = $self->{api}->get('https://'. our $host .'/api/query?type=portgroup&pageSize=250'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my %portgroups = %{$query->{PortgroupRecord}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | return wantarray ? %portgroups : \%portgroups; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | =head3 vimserver() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | Returns a reference to the first associated vcenter server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | sub vimserver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vimserver: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | my $ret = $self->{api}->admin_extension_vimServerReferences_get(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | my $vims = $ret->{'vmext:VimServerReference'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | my $vim = ( keys %$vims )[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | my $vimserver_href = $vims->{$vim}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | return $self->{api}->admin_extension_vimServer_get($vimserver_href); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | =head3 webclienturl($type,$moref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | Give the vimserver type and managed object reference, this method returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | URL for viewing the object via the vSphere Web client. This is handy for finding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | further details on objects within vSphere. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | sub webclienturl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
webclienturl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my $self = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my $type = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | my $moref = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $ret = $self->{api}->admin_extension_vimServerReferences_get(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $vims = $ret->{'vmext:VimServerReference'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | my $vim = ( keys %$vims )[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $vimserver_href = $vims->{$vim}->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | my $urlrequest = $vimserver_href .'/'. $type .'/'. $moref .'/vSphereWebClientUrl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | return $urlrequest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||