From 2b9029c71356a032ca78753a9395fe7549745c7f Mon Sep 17 00:00:00 2001 From: andywray Date: Fri, 18 Jan 2008 16:47:26 +0000 Subject: [PATCH] Add tabgrep command. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@294 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client-2.0/xCAT-client.spec | 1 + xCAT-server-2.0/lib/xcat/plugins/tabutils.pm | 22 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/xCAT-client-2.0/xCAT-client.spec b/xCAT-client-2.0/xCAT-client.spec index b9948bce5..a1b5fbc0d 100644 --- a/xCAT-client-2.0/xCAT-client.spec +++ b/xCAT-client-2.0/xCAT-client.spec @@ -72,6 +72,7 @@ ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/mkvm ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/rmvm ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/lsvm ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/chvm +ln -sf ../bin/xcatclient $RPM_BUILD_ROOT/%{prefix}/bin/tabgrep ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/lsslp ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/tabdump ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/makedns diff --git a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm index 9aeee066d..187ccf292 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm @@ -59,7 +59,8 @@ sub handled_commands { addattr => "tabutils", delattr => "tabutils", chtype => "tabutils", - nr => "tabutils" + nr => "tabutils", + tabgrep => "tabutils" } } @@ -130,6 +131,8 @@ sub process_request { return tabdump($args,$callback); } elsif ($command eq "gettab") { return gettab($request,$callback); + } elsif ($command eq "tabgrep") { + return tabgrep($nodes,$callback); } else { print "$command not implemented yet\n"; return (1,"$command not written yet"); @@ -446,6 +449,23 @@ sub chnode { } } +sub tabgrep { + my $node=shift; + my @tablist; + my $callback=shift; + + foreach (keys %{xCAT::Schema::tabspec}) { + if (grep /^node$/,@{$xCAT::Schema::tabspec{$_}->{cols}}) { + push @tablist,$_; + } + } + foreach (@tablist) { + my $tab=xCAT::Table->new($_); + if ($tab->getNodeAttribs($node->[0],["node"])) { + $callback->({data=>[$_]}); + } + } +}