lopezroy
Contributor
Contributor

How can I get the HostHardwareInfo object with a host reference?

Jump to solution

as title..Pls advise if there is anything liht getHostHardwardInfo() that I missed? Thanks

Message was edited by:

lopezroy

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal

You can use the managed object reference to the hostsystem and use getObjectProperty method, passing it the moref to your host system and the property.

e.g.

System.out.println("HOST INFO: "+getObjectProperty(hostRef, "hardware.systemInfo.uuid"));

System.out.println("HOST INFO: "+getObjectProperty(hostRef, "hardware.systemInfo.vendor"));

For finding the implementation of getObjectProperty, you can refer VMPowerOps.java sample code available with the java sdk.

View solution in original post

0 Kudos
5 Replies
hrobinson
VMware Employee
VMware Employee

You didn't mention the development language, so I will give you the answer for the VI Perl Toolkit.

First, you get the host view. In VI Perl, that's simple:

my $name = 'host1.eng.company.com'; # substitute with the host name

my $host_view = Vim::find_entity_view (view_type => 'HostSystem', filter => {name => "^$name\$"; surround name with ^ and $ to get an exact match

\# here are various fields of the hardware info object

print "Model: ", $host_view->systemInfo->model, "\n";

print "UUID: ", $host_view->systemInfo->uuid, "\n";

print "Vendor: ", $host_view->systemInfo->vendor, "\n";

print "CPU Speed", $host_view->cpuInfo->hz, "\n";

HostHardwareInfo is a data object that is retrieved when you get the HostSystem view (in Perl, at least).

H

roberthehe
Contributor
Contributor

-deleted-

Message was edited by:

roberthehe

0 Kudos
lopezroy
Contributor
Contributor

Thanks for your advise..Actually, I'm using Java SDK..

I already have the MoRef(hostSystem) by findByDnsName(), but I don't know how to go further with HostHardwareInfo object.

0 Kudos
admin
Immortal
Immortal

You can use the managed object reference to the hostsystem and use getObjectProperty method, passing it the moref to your host system and the property.

e.g.

System.out.println("HOST INFO: "+getObjectProperty(hostRef, "hardware.systemInfo.uuid"));

System.out.println("HOST INFO: "+getObjectProperty(hostRef, "hardware.systemInfo.vendor"));

For finding the implementation of getObjectProperty, you can refer VMPowerOps.java sample code available with the java sdk.

0 Kudos
lopezroy
Contributor
Contributor

Thanks a lot..

It's working.

0 Kudos