Calling Methods
After you have retrieved the view object
that corresponds to a managed object, you can run methods on that view to make
use of the managed object’s services.
You can run a method by
specifying the method's
name
parameter, like in the following example.
$vm->MigrateVM (name => 'productionVM');
The type of parameter required by the method
depends on the operation defined in the vSphere API. It might be a simple type,
data object, or managed object reference. For information about specific
parameters and data types, see the
vSphere API Reference Guide
.
Blocking operations are run as methods on a view
object. For example, to suspend a virtual machine, make the following call.
$vm_view->SuspendVM();
You can execute any operation that is defined for
a managed object as a method on a corresponding view object. Because the
vSphere SDK for Perl creates an accessor and a mutator method (getter and
setter method) for each property defined in the managed object, you can
reference the name of any property as a method call of the view, like in the
following example.
my $network_name = $network_view->name
The vSphere SDK for Perl allows you to pass a view
object to a method that requires a
ManagedObjectReference
. For example, if you have the
view that represents a host ($host
), you can pass the view to
the
powerOn()
method as follows.
my $host = Vim::find_entity_view (view_type => 'HostSystem', name => 'my host'); my $vm = Vim::find_entity_view (view_type => 'VirtualMachine', name => 'my virtual machine'); $vm->powerOn (host => $host)
Specifying Untyped Arguments in Scheduled Tasks and Callbacks discusses using the vSphere
SDK for Perl
PrimType
structure in some calls.