Search code examples
perlsoapvmwarevspherevmware-tools

Perl VMOMI can't find the way to get VmwareTools status via SOAP VSphere API


I try to get the VmWare tools status for a particular VM from Perl's VMOMI module, but I can't figure how to do it.

What I tried :

use strict; use warnings;

use VMOMI;
use Data::Dumper;

my $host = 'vcenter1.example.com',
my $user = 'myuser';
my $pass = 'STRONG';

my $stub = new VMOMI::SoapStub(host => $host) || die "Failed to initialize VMOMI::SoapStub";

my $instance = new VMOMI::ServiceInstance(
    $stub,
    new VMOMI::ManagedObjectReference(
        type  => 'ServiceInstance',
        value => 'ServiceInstance',
    ),
);

# Login
my $content = $instance->RetrieveServiceContent;
my $session = $content->sessionManager->Login(userName => $user, password => $pass);

my $vm = new VMOMI::VirtualMachineToolsRunningStatus(
    $stub,
    new VMOMI::VirtualMachineToolsRunningStatus(
        type => 'VirtualMachine',
        value => 'vm-name-foobar'
    )
);
use Data::Dumper;
print Dumper $vm; 

# Logout
$content->sessionManager->Logout();

I have a key service_version but I guess it's the version of the remote VSphere server.

Any clue ? I don't have any vmware tools status, this is what I'm looking for.

I think I don't understand how to use VirtualMachineToolsRunningStatus class :/


Solution

  • python pyvmomi is better documented.

    Check https://github.com/vmware/pyvmomi and theres a sample script to test vmware tools https://github.com/vmware/pyvmomi-community-samples.git

    python list_vmwaretools_status.py
    

    Work as a charm !