From f8efba5118483e94a850b244f548064cfb09e31d Mon Sep 17 00:00:00 2001 From: yinle Date: Thu, 17 Feb 2011 08:13:16 +0000 Subject: [PATCH] FSP/BPA redundancy :add a function judge_node to judge if the data is defined in xCAT 2.5 or later git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8872 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/DBobjUtils.pm | 62 +++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 12b62f28d..208dd984d 100644 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2064,11 +2064,11 @@ sub parse_access_tabentry() sub getchildren { my $parent = shift; - my $port = shift; if (($parent) && ($parent =~ /xCAT::/)) { $parent = shift; } + my $port = shift; my @children = (); my @children_prot = (); if (!%::PARENT_CHILDREN) { @@ -2260,4 +2260,64 @@ sub getcecchildren } return undef; } +#------------------------------------------------------------------------------- + +=head3 judge_node + judge the node is a real FSP/BPA, + use to distinguish if the data is defined in xCAT 2.5 or later + Arguments: + node name + Returns: + 0 is a fake FSP/BPA,defined in xCAT 2.5 + 1 is a real FSP/BPA,defined in xCAT 2.6 or later + Error: + none + Example: + $result = judge_node($nodetocheck); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub judge_node +{ + my $node = shift; + if (($node) && ($node =~ /xCAT::/)) + { + $node = shift; + } + my $type = shift; + my $flag = 0; + my $parenttype; + my $nodeparent; + my $ppctab = xCAT::Table->new( 'ppc' ); + if ( $ppctab ) { + $nodeparent = $ppctab->getNodeAttribs($node, ["parent"]); + if ($nodeparent and $nodeparent->{parent}) { + $parenttype = getnodetype($nodeparent->{parent}); + } + } + + if ($type =~ /^fsp$/) { + if ($nodeparent->{parent} =~ /^cec$/) + { + $flag = 1; + } else + { + $flag = 0; + } + } + + if ($type =~ /^bpa$/) { + if ($nodeparent->{parent} =~ /^frame$/) + { + $flag = 1; + } else + { + $flag = 0; + } + } + + return $flag; +} 1;