From 8577607611236f464e268f06c2750cf9425cccaf Mon Sep 17 00:00:00 2001 From: yinle Date: Tue, 10 May 2011 08:00:32 +0000 Subject: [PATCH] modify sethmcmgt and rmhmcmgt, modify hcp and mgt about fsp/bpa with cec/frame git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9529 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCconn.pm | 67 ++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/perl-xCAT/xCAT/PPCconn.pm b/perl-xCAT/xCAT/PPCconn.pm index af327ce47..0a9b5bf74 100644 --- a/perl-xCAT/xCAT/PPCconn.pm +++ b/perl-xCAT/xCAT/PPCconn.pm @@ -5,6 +5,7 @@ use strict; use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; +use xCAT::DBobjUtils; ############################################## # Globals @@ -698,17 +699,25 @@ sub sethmcmgt my $hcp = shift; my $nodehm_tab = xCAT::Table->new('nodehm', -create=>1); - my $ent = $nodehm_tab->getNodeAttribs( $node, ['mgt']); - if ( !$ent or $ent->{mgt} ne 'hmc') - { - $nodehm_tab->setNodeAttribs( $node, { mgt=>'hmc'}); - } - - my $ppc_tab = xCAT::Table->new('ppc', -create=>1); - my $ent = $ppc_tab->getNodeAttribs( $node, ['hcp']); - if ( !$ent or $ent->{hcp} ne $hcp) - { - $ppc_tab->setNodeAttribs( $node, { hcp=>$hcp}); + my $ppc_tab = xCAT::Table->new('ppc', -create=>1); + my @nodes; + push @nodes, $node; + my $ntype = xCAT::DBobjUtils->getnodetype($node); + if ( $ntype =~ /^(cec|frame)$/ ) { + my $cnodep = xCAT::DBobjUtils->getchildren($node); + if ($cnodep) { + push @nodes, @$cnodep; + } + } + for my $n (@nodes) { + my $ent = $nodehm_tab->getNodeAttribs( $n, ['mgt']); + if ( !$ent or $ent->{mgt} ne 'hmc') { + $nodehm_tab->setNodeAttribs( $n, { mgt=>'hmc'}); + } + my $ent = $ppc_tab->getNodeAttribs( $n, ['hcp']); + if ( !$ent or $ent->{hcp} ne $hcp) { + $ppc_tab->setNodeAttribs( $n, { hcp=>$hcp}); + } } } ################################################################# @@ -720,22 +729,30 @@ sub rmhmcmgt my $hwtype = shift; my $nodehm_tab = xCAT::Table->new('nodehm', -create=>1); - my $ent = $nodehm_tab->getNodeAttribs( $node, ['mgt']); - if ( !$ent or $ent->{mgt} ne $hwtype) - { - if ($hwtype eq "cec" || $hwtype eq "frame") { - $nodehm_tab->setNodeAttribs( $node, { mgt=>"fsp"}); - } else { - $nodehm_tab->setNodeAttribs( $node, { mgt=>$hwtype}); + my $ppc_tab = xCAT::Table->new('ppc', -create=>1); + my @nodes; + push @nodes, $node; + my $ntype = xCAT::DBobjUtils->getnodetype($node); + if ( $ntype =~ /^(cec|frame)$/ ) { + my $cnodep = xCAT::DBobjUtils->getchildren($node); + if ($cnodep) { + push @nodes, @$cnodep; } } - - my $ppc_tab = xCAT::Table->new('ppc', -create=>1); - my $ent = $ppc_tab->getNodeAttribs( $node, ['hcp']); - if ( !$ent or $ent->{hcp} ne $node) - { - $ppc_tab->setNodeAttribs( $node, { hcp=>$node}); - } + for my $n (@nodes) { + my $ent = $nodehm_tab->getNodeAttribs( $n, ['mgt']); + if ( !$ent or $ent->{mgt} ne $hwtype) { + if ($hwtype eq "cec" || $hwtype eq "frame") { + $nodehm_tab->setNodeAttribs( $n, { mgt=>"fsp"}); + } else { + $nodehm_tab->setNodeAttribs( $n, { mgt=>$hwtype}); + } + } + my $ent = $ppc_tab->getNodeAttribs( $n, ['hcp']); + if ( !$ent or $ent->{hcp} ne $n) { + $ppc_tab->setNodeAttribs( $n, { hcp=>$n}); + } + } } 1;