Commit c2886c8c authored by Leigh Stoller's avatar Leigh Stoller

Add FindLansByMember() to find any lans that are using an interface.

parent ceefba2c
......@@ -994,6 +994,42 @@ sub FindMember($$$)
return Lan::Member->Lookup($self, $memberid);
}
#
# Find lans by membership.
#
sub FindLansByMember($$$)
{
my ($class, $node, $iface_id) = @_;
my @result = ();
if (!ref($node)) {
$node = Node->Lookup($node);
return ()
if (!defined($node));
}
my $node_id = $node->node_id();
my $query_result =
DBQueryWarn("select lma1.lanid from lan_member_attributes as lma1, " .
" lan_member_attributes as lma2 ".
"where lma1.lanid = lma2.lanid and ".
" lma1.memberid=lma2.memberid and ".
" lma1.attrkey='node_id' and " .
" lma1.attrvalue='$node_id' and " .
" lma2.attrkey='iface' and " .
" lma2.attrvalue='$iface_id'");
return ()
if (!$query_result || !$query_result->numrows);
while (my ($lanid) = $query_result->fetchrow_array()) {
my $lan = Lan->Lookup($lanid);
push(@result, $lan)
if (defined($lan));
}
return @result;
}
#
# Remove a member from a lan.
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment