Service vlan redundancy support item

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.6@11079 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
zhaoertao
2011-11-30 09:53:46 +00:00
parent 8e34820345
commit 1c1618d2fc
5 changed files with 143 additions and 17 deletions
+10 -6
View File
@@ -98,10 +98,12 @@ sub fsp_api_action {
############################
# Get IP address
############################
$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name, $parameter );
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name, $parameter );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name, $parameter );
undef($parameter);
} else {
$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
}
if(!defined($fsp_ip)) {
@@ -234,8 +236,9 @@ sub fsp_state_action {
############################
# Get IP address
############################
$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
if(!defined($fsp_ip)) {
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res[0] = ["Failed to get the $fsp_name\'s ip"];
return ([-1, @res]);
}
@@ -351,8 +354,9 @@ sub fsp_api_create_parttion {
############################
# Get IP address
############################
$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
if(!defined($fsp_ip)) {
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res = "Failed to get the $fsp_name\'s ip";
return ([$fsp_name, $res, -1]);
}
+4 -2
View File
@@ -1,6 +1,7 @@
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT::FSPcfg;
use strict;
use Getopt::Long;
use xCAT::Usage;
@@ -847,8 +848,9 @@ sub fsp_api_passwd {
# Get IP address
############################
#$fsp_ip = xCAT::Utils::get_hdwr_ip($fsp_name);
$fsp_ip = xCAT::Utils::getNodeIPaddress($fsp_name);
if($fsp_ip == -1) {
#$fsp_ip = xCAT::Utils::getNodeIPaddress($fsp_name);
$fsp_ip = xCAT::Utils::getIPaddress($fsp_name);
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res = "Failed to get the $fsp_name\'s ip";
return ([$node_name, $res, -1]);
}
+8 -6
View File
@@ -221,10 +221,8 @@ sub mkhwconn_parse_args
if( ! exists $opt{port} )
{
$opt{port} = "0";
}
if( $opt{port} ne "0" and $opt{port} ne "1")
$opt{port} = "[0|1]";
} elsif( $opt{port} ne "0" and $opt{port} ne "1")
{
return( usage('Wrong value of --port option. The value can be 0 or 1, and the default value is 0.'));
}
@@ -612,7 +610,7 @@ sub lshwconn
# push @value, [$node_name, $values, $Rc];
# next;
# }
my %rec = ();
my @data_a = split("\n", $values);
foreach my $data(@data_a) {
if( $data =~ /state/) {
@@ -626,7 +624,11 @@ sub lshwconn
my $slot = $5;
my $ipadd = $6;
my $alt_ipaddr = $7;
$data = "$ipadd: $sp,ipadd=$ipadd,alt_ipadd=$alt_ipaddr,state=$state";
if (exists($rec{$slot})) {
next;
}
$rec{$slot} = 1;
$data = "$sp,ipadd=$ipadd,alt_ipadd=$alt_ipaddr,state=$state";
}
push @value, [$node_name, $data, $Rc];
}
+3 -1
View File
@@ -227,7 +227,9 @@ sub powercmd {
$action = "enter_rack_standby";
} elsif ( $action=~/^exit_rackstandby$/) {
$action = "exit_rack_standby";
} else {
} elsif ($action =~ /^resetsp$/) {
$action = "reboot_service_processor";
} else {
push @output, [$node_name, "$node_name\'s type isn't fsp or lpar. Not allow doing this operation", -1 ];
#return (\@output);
next;
+118 -2
View File
@@ -3004,8 +3004,124 @@ sub getNodeIPaddress
return undef;
}
}
#-------------------------------------------------------------------------------
=head3 getIPaddress - Used by DFM related functions to support service vlan redundancy.
Arguments:
Node name only one at a time
Returns: ip address(s)
Globals:
none
Error:
none
Example: my $c1 = xCAT::Utils::getIPaddress($nodetocheck);
=cut
#-------------------------------------------------------------------------------
sub getIPaddress
{
require xCAT::Table;
my $nodetocheck = shift;
my $port = shift;
my $side = "[A|B]";
if (!defined($port)) {
$port = "[0|1]";
}
# only need to parse IP addresses for Frame/CEC/BPA/FSP
my $type = xCAT::DBobjUtils->getnodetype($nodetocheck);
if ($type) {
my @children;
my %node_side_pairs = ();
my $children_num = 0;
my $parent;
my $ppctab = xCAT::Table->new( 'ppc' );
my $vpdtab = xCAT::Table->new( 'vpd' );
if ($type eq "bpa" or $type eq "fsp") {
my $tmp_p = $ppctab->getNodeAttribs($nodetocheck, ['parent']);
if ($tmp_p and $tmp_p->{parent}) {
$parent = $tmp_p->{parent};
} else {
return undef;
}
my $tmp_s = $vpdtab->getNodeAttribs($nodetocheck, ['side']);
if ($tmp_s->{side} and ($tmp_s->{side} =~ /(A|B)-\d/i)) {
$side = $1; # get side for the fsp, in order to get its brothers
} else {
return -3;
}
} elsif ($type eq "frame" or $type eq "cec") {
$parent = $nodetocheck;
} else {
return undef;
}
my @ps = $ppctab->getAllNodeAttribs(['node','parent','nodetype']);
my $tmp_parent;
my $tmp_node;
my $tmp_type;
#search for $nodetocheck's children or brothers
for my $entry ( @ps ) {
$tmp_parent = $entry->{parent};
$tmp_node = $entry->{node};
$tmp_type = $entry->{nodetype};
if ($tmp_parent and ($tmp_parent eq $parent) ) {
if (!defined($tmp_type)) {
$tmp_type = xCAT::DBobjUtils->getnodetype($tmp_node);
}
if ($tmp_type and ($tmp_type eq 'fsp' or $tmp_type eq 'bpa')) {
push @children, $tmp_node;
}
}
}
foreach my $tmp_n( @children) {
my $ent = $vpdtab->getNodeAttribs($tmp_n, ['side']);
if ($ent->{side} and $ent->{side} =~ /^$side-$port$/i) {
my $tmp_s = $ent->{side};
$tmp_s =~ s/a/A/;
$tmp_s =~ s/b/B/;
if (isIpaddr($tmp_n)) {
$node_side_pairs{$tmp_s} = $tmp_n;
$children_num++;
} else {
my $tmpip = xCAT::NetworkUtils->getipaddr($tmp_n);
if (!$tmpip) {
my $hoststab = xCAT::Table->new( 'hosts' );
my $tmp = $hoststab->getNodeAttribs($tmp_n, ['ip']);
if ($tmp->{ip}) {
$tmpip = $tmp->{ip};
}
}
if ($tmpip) {
$node_side_pairs{$tmp_s} = $tmpip;
$children_num++;
}
} # end of parse IP address for a fsp/bpa
} # end of parse a child's side
} #end of loop for children
if ($children_num == 0) {
return undef; #no children or brothers for this node.
}
my @keys = qw(A-0 A-1 B-0 B-1);
my $out_strings = undef;
foreach my $tmp (@keys) {
if (!$node_side_pairs{$tmp}) {
$node_side_pairs{$tmp} = '';
}
}
$out_strings = $node_side_pairs{"A-0"}.','.$node_side_pairs{"A-1"}.','.$node_side_pairs{"B-0"}.','.$node_side_pairs{"B-1"};
return $out_strings;
} else {
return undef;
}
}
#-------------------------------------------------------------------------------