From: <bl...@os...> - 2005-12-22 07:06:25
|
Author: bli Date: 2005-12-22 02:06:11 -0500 (Thu, 22 Dec 2005) New Revision: 4080 Modified: trunk/install_cluster trunk/lib/OSCAR/Database.pm trunk/packages/oda/config.xml trunk/packages/pfilter/scripts/post_clients trunk/scripts/oscar_wizard trunk/scripts/set_global_oscar_values trunk/scripts/wizard_prep Log: Fix for bug #1363093: - Overhauled set_global_oscar_values, need to now pass it --interface which is the user-specified network interface for the headnode - This value is then stored in the database under the "Clusters" table's "headnode_interface" field - Updated OSCAR::Database::get_headnode_iface() to get the correct information from the database - Removed redundant code for figuring out headnode's interface by calling get_headnode_iface() - Fixed pfilter's post_clients script to use the new function call as well Modified: trunk/install_cluster =================================================================== --- trunk/install_cluster 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/install_cluster 2005-12-22 07:06:11 UTC (rev 4080) @@ -253,6 +253,7 @@ croak "\nError: \'/tftpboot\' is gone!" if(! -d "/tftpboot" ); +$ENV{OSCAR_HEAD_INTERNAL_INTERFACE}=$adapter; # Run the wizard_prep script @@ -273,9 +274,6 @@ undef %incs; #print __FILE__,":",__LINE__,":INC:",join(", ",@INC),"\n"; - -$ENV{OSCAR_HEAD_INTERNAL_INTERFACE}=$adapter; - oscar_log_section("Prerequisites installed"); # Print some environment information Modified: trunk/lib/OSCAR/Database.pm =================================================================== --- trunk/lib/OSCAR/Database.pm 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/lib/OSCAR/Database.pm 2005-12-22 07:06:11 UTC (rev 4080) @@ -2545,10 +2545,8 @@ sub get_headnode_iface { my ($options_ref, $error_strings_ref) = @_; - my @results = (); - get_nics_info_with_node("oscar_server", \@results, $options_ref, $error_strings_ref); - my $ref = pop @results; - return $$ref{name}; + my $cluster_ref = get_cluster_info_with_name("oscar", $options_ref, $error_strings_ref); + return $$cluster_ref{headnode_interface}; } #======================================================================= Modified: trunk/packages/oda/config.xml =================================================================== --- trunk/packages/oda/config.xml 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/packages/oda/config.xml 2005-12-22 07:06:11 UTC (rev 4080) @@ -120,6 +120,7 @@ <installation_date> <type> date </type> </installation_date> + <headnode_interface/> </fields> </Clusters> Modified: trunk/packages/pfilter/scripts/post_clients =================================================================== --- trunk/packages/pfilter/scripts/post_clients 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/packages/pfilter/scripts/post_clients 2005-12-22 07:06:11 UTC (rev 4080) @@ -24,12 +24,13 @@ use strict; use Carp; -use lib '/usr/lib/systeminstaller'; +use lib "/usr/lib/systeminstaller", "$ENV{OSCAR_HOME}/lib"; use SystemInstaller::Machine; use File::Copy; use SIS::Image; use SIS::DB; +use OSCAR::Database; # function to return a sorted, unique lines only version of a passed list @@ -80,9 +81,9 @@ # in /etc/pfilter.conf my $on_interface = ""; -if ( exists $ENV{OSCAR_HEAD_INTERNAL_INTERFACE} && - $ENV{OSCAR_HEAD_INTERNAL_INTERFACE} ne "" ) { - $on_interface = "on $ENV{OSCAR_HEAD_INTERNAL_INTERFACE}"; +my $interface = get_headnode_iface(); +if ( $interface && $interface ne "" ) { + $on_interface = "on $interface"; } else { print "Warning, $0 cannot determine the cluster interface name,\n"; print "DHCP packets will be seen on this server from all network interfaces.\n"; Modified: trunk/scripts/oscar_wizard =================================================================== --- trunk/scripts/oscar_wizard 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/scripts/oscar_wizard 2005-12-22 07:06:11 UTC (rev 4080) @@ -70,17 +70,11 @@ my %options = (); my @errors = (); -if ( !defined($interface) || $interface eq '' ) { - my @result = (); - my $node = "oscar_server"; - get_nics_info_with_node($node,\@result,\%options,\@errors); - my $result_ref = pop @result; - $interface = $$result_ref{name}; -} +$interface = get_headnode_iface() if ( !defined($interface) || $interface eq '' ); # Set some things in the environment -$ENV{OSCAR_HEAD_INTERNAL_INTERFACE}=$interface; +#$ENV{OSCAR_HEAD_INTERNAL_INTERFACE}=$interface; $ENV{PATH}= $config->binpath .":" . $ENV{PATH}; # Create the main window... my $window = MainWindow->new(); @@ -88,7 +82,6 @@ chomp(my $shostname = `hostname -s`); $window->title("OSCAR Installation Wizard - $shostname"); - # Get OSCAR's version my $oscar_version; Modified: trunk/scripts/set_global_oscar_values =================================================================== --- trunk/scripts/set_global_oscar_values 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/scripts/set_global_oscar_values 2005-12-22 07:06:11 UTC (rev 4080) @@ -37,19 +37,48 @@ use POSIX; use OSCAR::oda; -my %options = (); +my %cmd_options = (); # set default option values -my %options = ( 'debug' => 0, - 'verbose' => 0 ); +%cmd_options = ( 'debug' => 0, + 'verbose' => 0 ); +sub usage { + + my ( $exit_status, @error_strings ) = @_; + my $progname = $0; + print <<USAGE; + +$progname + +$progname sets global OSCAR values and populate the OSCAR database. +You must specify the headnode interface as an argument. + +Options: + --[no]debug [do not] turn on debug output (default: no) + --help print out usage information then exits + --interface specifies the headnode interface to use (ethX) + --[no]verbose [do not] turn on verbose output (default: no) + +Usage: +$progname [options] + +USAGE + if ( @error_strings ) { + print "\n"; + warn shift @error_strings while @error_strings; + } + exit $exit_status; +} + my %field_value_hash = (); # parse command line options -GetOptions( \%options, +GetOptions( \%cmd_options, 'debug!', 'database|d=s', 'help', 'host|h=s', + 'interface|i=s', 'password=s', 'port|p=i', 'type|t=s', @@ -57,9 +86,24 @@ 'verbose!', 'version' ) || usage(1); -print "$0: after GetOptions ARGV=<@ARGV>\n" if $options{debug}; -oda::print_hash( "", "$0: options after GetOptions", \%options) if $options{debug}; +usage(0) if ! ( exists($cmd_options{interface}) ); +usage(0) if exists $cmd_options{help}; +print "$0: after GetOptions ARGV=<@ARGV>\n" if $cmd_options{debug}; +oda::print_hash( "", "$0: options after GetOptions", \%cmd_options) if $cmd_options{debug}; + +if (! ($cmd_options{interface} =~ /^eth/) ) { + print "Interface specified not in the format of ethX.\n" if ! ($cmd_options{interface} =~ /^eth/); + exit(1); +} + +`ifconfig $cmd_options{interface} > /dev/null 2>&1`; + +if ("$?") { + print "Interface specified does not exist.\n"; + exit(1); +} + my ($oscar_server_distribution,$oscar_server_distribution_version) = which_distro_server(); my $mysql_service_name = which_mysql_name($oscar_server_distribution,$oscar_server_distribution_version); @@ -127,6 +171,7 @@ "server_distribution" => $oscar_server_distribution, "server_distribution_version" => $oscar_server_distribution_version, "server_architecture" => $oscar_server_architecture, + "headnode_interface" => "$cmd_options{interface}", "installation_date" => "NOW()" ); insert_into_table (\%options,"Clusters", \%field_value_hash,\@error_strings); } else { @@ -137,6 +182,7 @@ "server_distribution" => $oscar_server_distribution, "server_distribution_version" => $oscar_server_distribution_version, "server_architecture" => $oscar_server_architecture, + "headnode_interface" => "$cmd_options{interface}", "installation_date" => "NOW()" ); update_table(\%options,"Clusters", \%field_value_hash,undef,\@error_strings); } Modified: trunk/scripts/wizard_prep =================================================================== --- trunk/scripts/wizard_prep 2005-12-22 00:51:38 UTC (rev 4079) +++ trunk/scripts/wizard_prep 2005-12-22 07:06:11 UTC (rev 4080) @@ -251,7 +251,7 @@ # More ODA setup my $exit_status = - system( "$ENV{OSCAR_HOME}/scripts/set_global_oscar_values" ) / 256; + system( "$ENV{OSCAR_HOME}/scripts/set_global_oscar_values --interface $ENV{OSCAR_HEAD_INTERNAL_INTERFACE}" ) / 256; croak("Couldn't initialize the global database values table") if $exit_status; my $exit_status = |