basic implementation, rancid graph and nodemonitor missing
This commit is contained in:
@@ -17,8 +17,8 @@ SELECT *
|
||||
FROM device
|
||||
WHERE dns IS NULL
|
||||
OR name IS NULL
|
||||
OR regexp_replace(lower(dns), ? || '$', '')
|
||||
!= regexp_replace(lower(name), ? || '$', '')
|
||||
OR regexp_replace(lower(dns), ?, '')
|
||||
!= regexp_replace(lower(name), ?, '')
|
||||
ENDSQL
|
||||
|
||||
1;
|
||||
|
||||
@@ -97,9 +97,9 @@ sub search_by_ip {
|
||||
->search($cond, $attrs);
|
||||
}
|
||||
|
||||
=head1 search_by_name( \%cond, \%attrs? )
|
||||
=head1 search_by_dns( \%cond, \%attrs? )
|
||||
|
||||
my $set = $rs->search_by_name({dns => 'foo.example.com', active => 1});
|
||||
my $set = $rs->search_by_dns({dns => 'foo.example.com', active => 1});
|
||||
|
||||
Like C<search()>, this returns a ResultSet of matching rows from the
|
||||
NodeIp table.
|
||||
@@ -118,6 +118,11 @@ to search for. The value may optionally include SQL wildcard characters.
|
||||
|
||||
=item *
|
||||
|
||||
The C<cond> parameter may optionally have a suffix parameter which is a
|
||||
regular expression of domain names that must also match the results.
|
||||
|
||||
=item *
|
||||
|
||||
Results are ordered by time last seen.
|
||||
|
||||
=item *
|
||||
@@ -141,7 +146,13 @@ sub search_by_dns {
|
||||
die "dns field required for search_by_dns\n"
|
||||
if ref {} ne ref $cond or !exists $cond->{dns};
|
||||
|
||||
$cond->{dns} = { '-ilike' => delete $cond->{dns} };
|
||||
(my $suffix = (delete $cond->{suffix} || ''))
|
||||
=~ s|^\Q(?^\E|***:(?|;
|
||||
|
||||
$cond->{dns} = [ -and =>
|
||||
{ '-ilike' => delete $cond->{dns} },
|
||||
{ '~*' => "$suffix" },
|
||||
];
|
||||
|
||||
return $rs
|
||||
->search_rs({}, $search_attr)
|
||||
|
||||
Reference in New Issue
Block a user