Batistuta_g_2000 has asked for the wisdom of the Perl Monks concerning the following question:
Getting error: Can't call method ipConfig on and undefined value? Is referencing an MOB reference but I cant see a problem, are there any obvious "Perl" problems with it? Thanks#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use VMware::VIRuntime; my %opts = ( vm => { type => "=s", help => "Name for the VM", required => 1, }, ip => { type => "=s", help => "Name for the IP", required => 1, }, ); Opts::add_options(%opts); Opts::parse(); Opts::validate(); Util::connect(); my $ip_address = Opts::get_option('ip'); my $vmname = Opts::get_option('vm'); my %filter=(name=>$vmname); my $vm = Vim::find_entity_view(view_type => 'VirtualMachine',filter=>\ +%filter); foreach my $ip (@{$vm->guest->net->ipConfig->ipAddress}) { my $ip_address = Opts::get_option('ip'); my $ipadd = ref $ip; if ($ipadd eq $ip_address) { print "Found $ip for $vmname \n"; } # } } Util::disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does this not work? - Can't call method on an undefined value!!!
by moritz (Cardinal) on May 06, 2013 at 17:16 UTC | |
|
Re: Why does this not work? - Can't call method on an undefined value!!!
by graff (Chancellor) on May 07, 2013 at 02:31 UTC | |
|
Re: Why does this not work? - Can't call method on an undefined value!!!
by LanX (Saint) on May 06, 2013 at 16:08 UTC |