Reply
Highlighted
Accepted Solution

Getting Extensible Attribute value from existing DHCP filter using Perl API

benngl
Techie
Posts: 5
2601     0

I have IPv4 filters that contain HW addrs.  Each HW addr has a defined extensible attribute called "Security Zone". When I try to get them w/the code below, it fails w/this msg:

 

       Use of uninitialized value $zone in concatenation (.) or string at ./Infoblox.pl

 

---------------------

 

my @retrieved_objs = $session->get (
         object => "Infoblox:Smiley Very HappyHCP::MAC",
         mac => "00:03:93:ae:32:0e",
);

 

foreach my $item (@retrieved_objs) {
         my $filter=$item->filter;

         print "$filter\n";
         my $attrs=$item->extensible_attributes();
         my $zone=$attrs->{'Security Zone'};
         print "$zone\n";
}

 

Thanks for any suggestions.

Re: Getting Extensible Attribute value from existing DHCP filter using Perl API

[ Edited ]
jsteele
Member
Posts: 0
2602     0

The code is generally sound.  The error you're seeing is being returned from an object w/o the attribute defined.  If you just want to not get the error, you can do something like:

 

print "$zone\n" if $zone;

 

or return something more useful to find the offender, of course, like:

 

if ($zone) { print "$zone\n"; }

else { print $item->mac(),"\n"; }

Re: Getting Extensible Attribute value from existing DHCP filter using Perl API

benngl
Techie
Posts: 5
2602     0

Should I be using a different object?  I've confirmed the extensible attribute exists for the HW addr.  The HW addr is under the filter. 

 

Thanks for your help.

Re: Getting Extensible Attribute value from existing DHCP filter using Perl API

jsteele
Member
Posts: 0
2602     0

Are you trying to get the attrib off of each MAC entry, or the filter itself?  (Obviously, I'm only working from a snippet here, so I don't have full context.)

 

If per-MAC, I'd suggest putting in the if/else I posted earlier, and then go look at it and verify whether the attrib is in fact there, or if you possibly have something else suspicious.

 

Re: Getting Extensible Attribute value from existing DHCP filter using Perl API

benngl
Techie
Posts: 5
2602     0

Was misreading the columns and the extensible attribute was spelled differently. All good, now.  Thanks, again, for your confirmation.

 

 

gary

Showing results for 
Search instead for 
Do you mean 

Recommended for You