VMware {code} Community
lopezroy
Contributor
Contributor
Jump to solution

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

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

Message was edited by:

lopezroy

Reply
0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

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

Reply
0 Kudos
5 Replies
hrobinson
VMware Employee
VMware Employee
Jump to solution

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
Jump to solution

-deleted-

Message was edited by:

roberthehe

Reply
0 Kudos
lopezroy
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

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.

Reply
0 Kudos
lopezroy
Contributor
Contributor
Jump to solution

Thanks a lot..

It's working.

Reply
0 Kudos