rnetboot enhancement for iscsi dump
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6057 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -43,7 +43,7 @@ sub parse_args { | ||||
|     $Getopt::Long::ignorecase = 0; | ||||
|     Getopt::Long::Configure( "bundling" ); | ||||
|  | ||||
|     if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version F f s=s m:s@ r=s t=s) )) {  | ||||
|     if ( !GetOptions( \%opt, qw(h|help V|Verbose v|version I|iscsiboot F f s=s m:s@ r=s t=s) )) {  | ||||
|         return( usage() ); | ||||
|     } | ||||
|  | ||||
| @@ -107,6 +107,7 @@ sub do_rnetboot { | ||||
|     my $ssh     = @$exp[0]; | ||||
|     my $userid  = @$exp[4]; | ||||
|     my $pw      = @$exp[5]; | ||||
|     my $subreq = $request->{subreq}; | ||||
|     my $cmd; | ||||
|     my $result; | ||||
|  | ||||
| @@ -179,8 +180,58 @@ sub do_rnetboot { | ||||
|     ####################################### | ||||
|     # Network specified | ||||
|     ####################################### | ||||
|     $cmd.= " -s auto -d auto -m $opt->{m} -S $opt->{S} -G $opt->{G} -C $opt->{C}"; | ||||
|     $cmd.= " -s auto -d auto -m $opt->{m} -S $opt->{S} -G $opt->{G} -C $opt->{C} -N $opt->{N}"; | ||||
|     | ||||
|     ####################################### | ||||
|     # Get required attributes from master | ||||
|     # of the node if -I|--iscsiboot is | ||||
|     # specified | ||||
|     ####################################### | ||||
|     if (  exists( $opt->{I} )) { | ||||
|         my $ret; | ||||
|         my $dump_target; | ||||
|         my $dump_lun; | ||||
|         my $dump_port; | ||||
|         my $noderestab = xCAT::Table->new('noderes'); | ||||
|         unless ($noderestab) | ||||
|         { | ||||
|             xCAT::MsgUtils->message('S', | ||||
|                                 "Unable to open noderes table.\n"); | ||||
|             return 1; | ||||
|         } | ||||
|         my $et = $noderestab->getNodeAttribs($node, ['xcatmaster']); | ||||
|         if ($et and $et->{'xcatmaster'}) | ||||
|         { | ||||
|             $ret = xCAT::Utils->runxcmd( | ||||
|             { | ||||
|                 command => ['xdsh'], | ||||
|                 node    => [$et->{'xcatmaster'}], | ||||
|                 arg     => [ 'cat /tftpboot/$node.info' ] | ||||
|             }, | ||||
|             $subreq, 0, 0 ); | ||||
|         } else { | ||||
|             $ret = `cat /tftpboot/$node.info`; | ||||
|         } | ||||
|         chomp($ret); | ||||
|         my @attrs = split /\n/, $ret; | ||||
|         foreach (@attrs) | ||||
|         { | ||||
|             if (/DUMP_TARGET=(.*)$/) { | ||||
|                 $dump_target = $1; | ||||
|             } elsif (/DUMP_LUN=(.*)$/) { | ||||
|                 $dump_lun = $1; | ||||
|                 $dump_lun =~ s/^0x(.*)$/$1/g; | ||||
|             } elsif (/DUMP_PORT=(.*)$/) { | ||||
|                 $dump_port =$1; | ||||
|             } | ||||
|         } | ||||
|         if ( defined($dump_target) and defined($dump_lun) and defined($dump_port) ) { | ||||
|             $cmd.= " -T \"$dump_target\" -L \"$dump_lun\" -p \"$dump_port\""; | ||||
|         } else { | ||||
|             return( [RC_ERROR,"Unable to find DUMP_TARGET, DUMP_LUN, DUMP_PORT for iscsi dump"] ); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     ####################################### | ||||
|     # Add command options | ||||
|     ####################################### | ||||
| @@ -262,8 +313,11 @@ sub rnetboot { | ||||
|         G => $o->{gateway}, | ||||
|         S => $o->{server}, | ||||
|         C => $o->{client}, | ||||
|         N => $o->{netmask}, | ||||
|         m => $o->{mac} | ||||
|     ); | ||||
|  | ||||
|  | ||||
|     ##################################### | ||||
|     # Strip colons from mac address  | ||||
|     ##################################### | ||||
| @@ -281,6 +335,13 @@ sub rnetboot { | ||||
|     if ( exists( $options->{s} )) { | ||||
|         $opt{s} = $options->{s}; | ||||
|     } | ||||
|     ##################################### | ||||
|     # Do iscsi boot | ||||
|     ##################################### | ||||
|     if ( exists( $options->{I} )) { | ||||
|         $opt{I} = 1;  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     ##################################### | ||||
|     # Invalid target hardware  | ||||
|   | ||||
| @@ -842,6 +842,13 @@ sub resolve_netwk { | ||||
|         } | ||||
|         my $gateway_ip = @$ip[1]; | ||||
|  | ||||
|         my $netmask = $nethash{$_}{mask}; | ||||
|         if ( !defined( $netmask )) { | ||||
|             my $msg = sprintf("$_: $errmsg{NO_ATTR}","mask","networks"); | ||||
|             send_msg( $request, 1, $msg ); | ||||
|             next; | ||||
|         } | ||||
|  | ||||
|         ################################# | ||||
|         # Get server (-S) | ||||
|         ################################# | ||||
| @@ -883,6 +890,7 @@ sub resolve_netwk { | ||||
|         $result{$_}{server}  = $server_ip; | ||||
|         $result{$_}{client}  = $client_ip; | ||||
|         $result{$_}{mac}     = $ent->{mac}; | ||||
|         $result{$_}{netmask} = $netmask; | ||||
|     } | ||||
|     return( \%result ); | ||||
| } | ||||
|   | ||||
| @@ -607,7 +607,7 @@ proc get_adap_prop { phandle } { | ||||
|                 return | ||||
|             } | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout in getting adapter properpties\n" | ||||
|                 nc_msg "timeout state is $state\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
| @@ -738,7 +738,7 @@ proc get_mac_addr { phandle } { | ||||
|                             return $mac_address | ||||
|                         } | ||||
|                         timeout { | ||||
|                             send_user "$PROGRAM: Timeout\n" | ||||
|                             send_user "$PROGRAM: Timeout when getting mac address\n" | ||||
|                             nc_msg "timeout state is $state\n" | ||||
|                             set rc 1 | ||||
|                             return | ||||
| @@ -762,7 +762,7 @@ proc get_mac_addr { phandle } { | ||||
|                 return | ||||
|             } | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout in getting mac address\n" | ||||
|                 nc_msg "timeout state is $state\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
| @@ -872,7 +872,7 @@ proc get_adaptr_loc { phandle } { | ||||
|                             return | ||||
|                         } | ||||
|                         timeout { | ||||
|                             send_user "$PROGRAM: Timeout\n" | ||||
|                             send_user "$PROGRAM: Timeout when openning console\n" | ||||
|                             set rc 1 | ||||
|                             return | ||||
|                         } | ||||
| @@ -895,7 +895,7 @@ proc get_adaptr_loc { phandle } { | ||||
|                 return | ||||
|             } | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout in openning console\n" | ||||
|                 nc_msg "$PROGRAM Status: timeout state is $state\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
| @@ -1152,7 +1152,7 @@ proc ping_server { full_path_name phandle } { | ||||
|                                     return | ||||
|                                 } | ||||
|                                 timeout { | ||||
|                                     send_user "$PROGRAM: Timeout\n" | ||||
|                                     send_user "$PROGRAM: Timeout in ping server\n" | ||||
|                                     set 1 | ||||
|                                     return | ||||
|                                 } | ||||
| @@ -1205,7 +1205,7 @@ proc ping_server { full_path_name phandle } { | ||||
|                 return | ||||
|             } | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout when pinging server\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
|             } | ||||
| @@ -1345,7 +1345,7 @@ proc set_disk_boot {} { | ||||
|                         | ||||
|  | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout in settin boot order\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
|             } | ||||
| @@ -1381,6 +1381,10 @@ proc boot_network {} { | ||||
|     global server_ip | ||||
|     global client_ip | ||||
|     global gateway_ip | ||||
|     global netmask | ||||
|     global dump_target | ||||
|     global dump_lun | ||||
|     global dump_port | ||||
|     global extra_args | ||||
|     global PROGRAM | ||||
|     global NODENAME | ||||
| @@ -1411,14 +1415,19 @@ proc boot_network {} { | ||||
|     # duplex during boot. | ||||
|     # state 0, stack count 0 | ||||
|     set done(0) 0 | ||||
|     if {$extra_args != "" } { | ||||
|         set net_device(0) "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip $extra_args" | ||||
|     if {$dump_target != ""} { | ||||
|         set net_device(0) "$full_path_name:iscsi,ciaddr=$client_ip,subnet-mask=$netmask,itname=dummy,iport=$dump_port,ilun=$dump_lun,iname=$dump_target,siaddr=$server_ip,2" | ||||
|         set pattern(0) "iSCSI" | ||||
|     } else { | ||||
|         set net_device(0) "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip" | ||||
|         if {$extra_args != "" } { | ||||
|             set net_device(0) "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip $extra_args" | ||||
|         } else { | ||||
|             set net_device(0) "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip" | ||||
|         } | ||||
|         set pattern(0) "BOOTP" | ||||
|     } | ||||
|     set cmd(0) "boot $net_device(0)\r" | ||||
|     set msg(0) "$PROGRAM Status: network boot initiated\n" | ||||
|     set pattern(0) "BOOTP" | ||||
|     set newstate(0) 99 | ||||
|  | ||||
|     # If the install adapter is FDDI, don't set the speed and duplex | ||||
| @@ -1516,7 +1525,7 @@ proc boot_network {} { | ||||
|                 return | ||||
|             } | ||||
|             timeout { | ||||
|                 send_user "$PROGRAM: Timeout\n" | ||||
|                 send_user "$PROGRAM: Timeout in boot network\n" | ||||
|                 nc_msg "timeout state is $state\n" | ||||
|                 set rc 1 | ||||
|                 return | ||||
| @@ -1571,6 +1580,9 @@ proc Boot {} { | ||||
|         -ex {------} { | ||||
|             nc_msg "$PROGRAM: # Network boot proceeding, exiting.\n" | ||||
|         } | ||||
|         -ex {iSCSI} { | ||||
|             nc_msg "$PROGRAM: # Network boot proceeding, exiting.\n" | ||||
|         } | ||||
|         timeout { | ||||
|             set mins [expr ($timeout/60)] | ||||
|             send_user "$PROGRAM: Timeout waiting for the boot image to boot up. \ | ||||
| @@ -1858,6 +1870,10 @@ set server_ip "" | ||||
| set gateway_ip "" | ||||
| set extra_args "" | ||||
| set macaddress "" | ||||
| set netmask "" | ||||
| set dump_target "" | ||||
| set dump_lun "" | ||||
| set dump_port "" | ||||
| set phys_loc "" | ||||
| set userid "" | ||||
| set passwd "" | ||||
| @@ -1914,6 +1930,10 @@ while { [llength $argv] > 0} { | ||||
|                set argv [lrange $argv 1 end] | ||||
|              } | ||||
|  | ||||
|         "-N" { set netmask [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-S" { set server_ip [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
| @@ -1942,6 +1962,10 @@ while { [llength $argv] > 0} { | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-L" { set dump_lun [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-l" { set phys_loc [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
| @@ -1954,10 +1978,18 @@ while { [llength $argv] > 0} { | ||||
|                set argv [lrange $argv 1 end] | ||||
|              } | ||||
|  | ||||
|         "-p" { set dump_port [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-s" { set adap_speed [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-T" { set dump_target [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|              } | ||||
|  | ||||
|         "-t" { set list_type [lindex $argv 1] | ||||
|                set argv [lrange $argv 2 end] | ||||
|  | ||||
| @@ -2614,8 +2646,12 @@ if { $noboot } { # Display information for all supported adapters | ||||
| # | ||||
| # mission accomplished, beam me up scotty. | ||||
| # | ||||
| if { (!$noboot) && ( $rc == 0 ) } {  | ||||
|     send_user "# Finished.\n"  | ||||
| if { !$noboot  } {  | ||||
|     if { $rc == 0 } { | ||||
|         send_user "# Finished.\n"  | ||||
|     } else { | ||||
|         send_user "# Finished in an error.\n" | ||||
|     } | ||||
| } else { | ||||
|     set done 0 | ||||
|     set query_count 0 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user