Quantcast
Channel: VMware Communities : Discussion List - vSphere SDK for Perl
Viewing all articles
Browse latest Browse all 1577

can not show vms

$
0
0

I am wanna to connect my Vcenter to show one cluster all vms ,but it report error :Can't call method "serialize" on unblessed reference at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 2435.

 

I want to show cpu ,mem ,net ,io static ,and write all these data to mysql ,but I am stuck here .

 

 

 

 

#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use utf8;
use VMware::VIRuntime;
use VMware::VILib;
my %opts = (
    cluster => {
        type =>"=s" ,
        help => "Enter the Cluster name" ,
        required => 1,
    }  
);
#connect the host
Opts::add_options(%opts);
Opts::parse();
Opts::validate();
Util::connect();
#script start
my $cluster = Vim::find_entity_views (view_type =>'ClusterComputeResource',
                                      properties => ['name'],
                                      filter =>{'name' =>Opts::get_option('cluster')});
my $vms = Vim::find_entity_views( view_type=>'VirtualMachine',
                                  properties => ['name'],
                                  begin_entity => $cluster );   
    foreach my $vm ( @{$vms || []} ) {
        my $vmname = '"' . $vm->{'name'} . '"';
        print $vmname;
    }  
Util::disconnect;
~                

 


Viewing all articles
Browse latest Browse all 1577

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>