VMware Cloud Community
coza
Contributor
Contributor

Getting host serial number (asset tag) via Perl

I have an existing (large) perl script that collects host and VM hardware information and places it in a internal custom DB.     Since an upgrade to vsphere 6.5 getting the serial number from hosts has broken. 

We were getting the serial number from the hosts via WSMAN as per below

my $client = WSMan::StubOps->new(

path => '/wsman',

username => $ticket->sessionId,

password => $ticket->sessionId,

port => '80',

address => $hostView->name,

namespace => 'root/cimv2',

timeout  => '120'

);

$client->register_class_ns(

OMC => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2',

VMware => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2',

);

eval {

foreach ($client->EnumerateInstances(class_name => 'CIM_PhysicalPackage')){

if ($_->ElementName =~ m/Chassis/i && $_->ChassisTypeDescription !~ m/Blade Enclosure/i) {

$hostData{serialnumber} = $_->SerialNumber;

last;

}

}

};

That no longer works and it throws the error:

Use of uninitialized value in sprintf at C:/Perl/site/lib/SOAP/Lite.pm line 3642

As far as I can gleam from the small amount of information available WSMAN is no longer available in vsphere 6.5.

I cannot use the hostsystem view as the serial number for the hosts is not in that output.

$hostViews = Vim::find_entity_views(view_type => 'HostSystem');

Is there any other way using Perl to extract the hosts serial number?  I am loafed to rewrite the script in another language due to its size and complexity.

0 Kudos
0 Replies