From d79ae69084d020f1aea3709e33598dd8e36e786d Mon Sep 17 00:00:00 2001 From: zhanx Date: Mon, 27 Jul 2009 15:28:11 +0000 Subject: [PATCH] Fix defect 2822229 lsslp should set the correct node name in xCAT DB for BPA; 2824599 lsslp should add more attribute in DB for FSP/HMC git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3881 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCdb.pm | 7 ++++- perl-xCAT/xCAT/PPCfsp.pm | 7 +++++ perl-xCAT/xCAT/Utils.pm | 40 +++++++++++++++++++++++++++ xCAT-server/lib/perl/xCAT/PPC.pm | 13 +++++---- xCAT-server/lib/xcat/plugins/lsslp.pm | 10 ++++--- 5 files changed, 66 insertions(+), 11 deletions(-) diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 07124c7d8..e47e3f2e1 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -175,7 +175,7 @@ sub add_ppchcp { my $hwtype = shift; my $data = shift; - my @tabs = qw(ppchcp nodehm nodelist); + my @tabs = qw(ppchcp nodehm nodelist nodetype); my %db = (); my $name = @$data[4]; @@ -202,6 +202,11 @@ sub add_ppchcp { # Update nodehm table ################################### $db{nodehm}->setNodeAttribs( $name, {mgt=>lc($hwtype)} ); + + ################################### + # Update nodetype table + ################################### + $db{nodetype}->setNodeAttrbs( $name, {nodetype=>lc($hwtype)}); ################################### # Update nodelist table diff --git a/perl-xCAT/xCAT/PPCfsp.pm b/perl-xCAT/xCAT/PPCfsp.pm index 3c98bdc84..5da516826 100644 --- a/perl-xCAT/xCAT/PPCfsp.pm +++ b/perl-xCAT/xCAT/PPCfsp.pm @@ -8,6 +8,7 @@ use HTTP::Cookies; use HTML::Form; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; +use Socket; ########################################## @@ -129,6 +130,7 @@ sub connect { ################################## # Set options ################################## +# my $serverip = inet_ntoa(inet_aton($server)); my $url = "https://$server/cgi-bin/cgi?form=2"; $ua->cookie_jar( $cookie ); $ua->timeout( $timeout ); @@ -1742,6 +1744,11 @@ sub set_netcfg $inc_type = 'Dynamic'; push @set_entries, 'IP type to dynamic.'; } + elsif ( $inc_ip eq '*') + { + $inc_type = 'Static'; + ($inc_ip, $inc_host, $inc_gateway, $inc_netmask) = xCAT::Utils::getNodeNetworkCfg(@$exp[1]); + } else { $inc_type = 'Static'; diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 36b8e9081..31dd39c87 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4896,4 +4896,44 @@ sub isIpaddr return 1; } } + +#------------------------------------------------------------------------------- + +=head3 getNodeNetworkCfg + Description: + Get node network configuration, including "IP, hostname(the nodename),and netmask" by this node's name. + + Arguments: + node: the nodename + Returns: + Return an array, which contains (IP,hostname,gateway,netmask'). + undef - Failed to get the network configuration info + Globals: + none + Error: + none + Example: + my ($ip,$host,undef,$mask) = xCAT::Utils::getNodeNetworkCfg('node1'); + Comments: + Presently gateway is always blank. Need to be improved. + +=cut + +#------------------------------------------------------------------------------- +sub getNodeNetworkCfg +{ + my $node = shift; + + my $nets = xCAT::Utils::my_nets(); + my $ip = inet_ntoa(inet_aton($node)); + my $mask = undef; + for my $net (keys %$nets) + { + my $netname; + ($netname,$mask) = split /\//, $net; + last if ( xCAT::Utils::isInSameSubnet( $netname, $ip, $mask, 1)); + } + return ($ip, $node, undef, xCAT::Utils::formatNetmask($mask,1,0)); +} + 1; diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index affc87bd0..c00ff9b15 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -538,13 +538,14 @@ sub resolve_hcp { # Process each node #################################### foreach my $hcp ( @$noderange ) { - my ($ent) = $db->getAttribs( {hcp=>$hcp},"hcp" ); +# my ($ent) = $db->getAttribs( {hcp=>$hcp},"hcp" ); +# my ($ent) = $db->getNodeAttribs( $hcp, ["hcp"]); - if ( !defined( $ent )) { - my $msg = sprintf( "$hcp: $errmsg{NODE_UNDEF}", $tab ); - send_msg( $request, 1, $msg ); - next; - } +# if ( !defined( $ent )) { +# my $msg = sprintf( "$hcp: $errmsg{NODE_UNDEF}", $tab ); +# send_msg( $request, 1, $msg ); +# next; +# } ################################ # Get userid and password ################################ diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index 9645b0ce4..be678ce94 100644 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -1120,6 +1120,7 @@ sub gethost_from_url { if ( !defined( $ip )) { return undef; } + ####################################### # Check if valid IP ####################################### @@ -1161,6 +1162,7 @@ return undef if ($opt{H}); $host = getFactoryHostname($type,$mtm,$sn); #return( $ip ); } + ####################################### # Convert hostname to short-hostname ####################################### @@ -1188,7 +1190,7 @@ sub getFactoryHostname my $mtm = shift; my $sn = shift; - if ( $type eq SERVICE_FSP) + if ( $type eq SERVICE_FSP or $type eq SERVICE_BPA) { return "Server-$mtm-SN$sn"; } @@ -1525,7 +1527,7 @@ sub xCATdB { { if ( $ent->{mtm} and $ent->{serial}) { - $sn_node{"$ent->{mtm}*$ent->{serial}"} = $ent->{node}; + $sn_node{"Server-" . $ent->{mtm} . "-SN" . $ent->{serial}} = $ent->{node}; } } } @@ -1585,7 +1587,7 @@ sub xCATdB { } else { - $frame = "$bpc_model*$bpc_serial"; + $frame = "Server-$bpc_model-SN$bpc_serial"; } } ######################################## @@ -1615,7 +1617,7 @@ sub xCATdB { my $server = ""; my $values = join( ",", - lc($type),$name,$cageid,$model,$serial,$server,$prof,$frame,$ips ); + lc($type),$name,$cageid,$model,$serial,$name,$prof,$frame,$ips ); xCAT::PPCdb::add_ppc( "fsp", [$values] ); } elsif ( $type =~ /^(RSA|MM)$/ ) {