- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am struggling with the object usage in perl; my goal is to pass a VM name as parameter and return some information of the ESXi parent host:
use strict;
use Data::Dumper;
use VMware::VIRuntime;
# Auth options
Opts::set_option('server', 'vCenter');
Opts::set_option('username', 'user1l');
Opts::set_option('password', 'password1');
print "Connecting \n";
Util::connect();
print "Connected \n";
my $VMView = Vim::find_entity_view(
'view_type' => 'VirtualMachine',
'filter' => { 'name' => 'eduv0002',}
);
print $VMView->summary->config->name,"\n";
print $VMView->runtime->host,"\n";
my $HostRef = $VMView->runtime->host;
print $HostRef;
Util::disconnect();
But the output is:
Connecting
Connected
vm-test
ManagedObjectReference=HASH(0x2435648)
Undefined subroutine &ManagedObjectReference::name called at ./test.pl line 24
So it looks like I can get the host with no issues but I don't know how to access its properties having a Managed Object Reference.
Any help is appreciated, thank you.
Juan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have a MOREF from the runtime.host property, you need another get_view call on it.
my $host = Vim::get_view(mo_ref => $HostRef);
print $host->{name} . "\n";
Reuben Stump | http://www.virtuin.com | @ReubenStump
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect, thanks for the quick reply.