From 261d06acc371574871f3067f4c1ca9a7ed40dc88 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 28 Jul 2010 19:23:51 +0000 Subject: [PATCH] -Add a 'secret' findmac command. fleshing out to a real command TBD git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6900 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/switch.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 98da62206..7cfdbffd8 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -11,6 +11,7 @@ sub handled_commands { $macmap = xCAT::MacMap->new(); return { findme => 'switch', + findmac => 'switch', }; } @@ -18,6 +19,14 @@ sub process_request { my $req = shift; my $cb = shift; my $doreq = shift; + my $node; + my $mac = ''; + if ($req->{command}->[0] eq 'findmac') { + $mac = $req->{arg}->[0]; + $node = $macmap->find_mac($mac,0); + $cb->({node=>[{name=>$node,data=>$mac}]}); + return; + } my $ip = $req->{'_xcat_clientip'}; if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { #Don't attempt switch discovery of a VM Guest @@ -28,7 +37,6 @@ sub process_request { #discovery working. Food for thought. return; } - my $mac = ''; my $arptable = `/sbin/arp -n`; my @arpents = split /\n/,$arptable; foreach (@arpents) { @@ -37,7 +45,6 @@ sub process_request { last; } } - my $node; my $firstpass=1; if ($mac) { $node = $macmap->find_mac($mac,$req->{cacheonly}->[0]);