VMware {code} Community
Box293
Enthusiast
Enthusiast
Jump to solution

How do I change the licenseManager focus to be a host when connected to a vCenter server

I've been using the VMware Perl SDK.

I've been writing a script to query host licensing.

When I connect directly to a host, I am able to query that hosts ESX(i)'s license, if it is in evaluation mode or not. I am happy with that functionality.

When I connect to a vCenter server, I want to be able to change the licenseManager focus to be a specific host. How do I do this?

for example:

my $service_content = Vim::get_service_content();

my $license_manager = Vim::get_view(mo_ref => $service_content->licenseManager);

With the above code, when I connect to vCenter the focus is on the vCenter server's licenses and all licenses it has.

I would like to be able to focus on a particular host. How do I do this this?

VCP3 & VCP4 32846 VSP4 VTSP4
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Box293
Enthusiast
Enthusiast
Jump to solution

I played around a bit more and I found that I can use the QueryAssignedLicenses sub and target the host directly.

Continuing my code from my original post

my $target_host_view = Vim::find_entity_view(view_type => 'HostSystem', filter => {name => 'ESXiHOST'});

licenseAssignmentManager);

my $assigned_licenses = $license_assignment_manager->QueryAssignedLicenses(entityId => $target_host_view->summary->host->value);

$assigned_licenses will now be an array object with your assigned license.

Seeing as there is one one object in the array you could also do:

my $license = @{$assigned_licenses}[0]->assignedLicense;

And you could display items such as:

print $license->name . "\n";

print $license->licenseKey . "\n";

VCP3 & VCP4 32846 VSP4 VTSP4

View solution in original post

0 Kudos
2 Replies
stumpr
Virtuoso
Virtuoso
Jump to solution

Each host has a license manager off configManager.

$lm_mor = $host->configManager->licenseManager;

you you can get these all in a list and call get_views() on them to get per host license info.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Box293
Enthusiast
Enthusiast
Jump to solution

I played around a bit more and I found that I can use the QueryAssignedLicenses sub and target the host directly.

Continuing my code from my original post

my $target_host_view = Vim::find_entity_view(view_type => 'HostSystem', filter => {name => 'ESXiHOST'});

licenseAssignmentManager);

my $assigned_licenses = $license_assignment_manager->QueryAssignedLicenses(entityId => $target_host_view->summary->host->value);

$assigned_licenses will now be an array object with your assigned license.

Seeing as there is one one object in the array you could also do:

my $license = @{$assigned_licenses}[0]->assignedLicense;

And you could display items such as:

print $license->name . "\n";

print $license->licenseKey . "\n";

VCP3 & VCP4 32846 VSP4 VTSP4
0 Kudos