- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Infoblox API - limit scope of search?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-16-2013 08:55 AM
Hello,
I'm trying to query a large class B network for fixed address records. For example, network 120.18.0.0/16 but I want to limit the search to a single subnet, like subnet 2. How do I do this with the search API? This is what I have:
my @retrieved_objs = $session->search(
object => "Infoblox:HCP::FixedAddr",
network => '120.18.2.0/24',
network_view => "default",
return_methods => ['name','ipv4addr','mac']
);
unless (@retrieved_objs) {
die("Search records failed: ",
$session->status_code() . ":" . $session->status_detail());
}
my $count = 0;
foreach $entry (@retrieved_objs)
{
$this_ip = $entry->ipv4addr();
$this_name = $entry->name();
$this_ip = $entry->ipv4addr();
$this_mac = $entry->mac();
print "$this_name | $this_mac | $this_ip \n";
}
This matches anything with 120.18.2 in it, so I get subnet 2, subnet 20, subnet 200 etc
How do I just get 120.18.2.0/24 ?
Thanks
Re: Infoblox API - limit
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-16-2013 08:38 AM
Hi,
I've noticed that the difference between the get and search methods is that search uses regex and get doesn't.
The dots in '120.18.2.0/24' are treated as wildcards. use \. to escape the dots.
Because of its use of regex you can also leave out the final 0 in the network address.
Re: Infoblox API - limit
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-17-2013 08:49 AM
Thanks Stef ! I had not realised it was a regex. That makes sense now.
Much appreciated.