From 5c3a693d5d66499a8a87984bd653ef0c4e92d174 Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 3 Jul 2017 18:46:00 -0400 Subject: [PATCH] * Fixed a bug where some Anvil! passwords needed to be altered to work with IPMI and this adaptation wasn't happening. * Removed the default '--host-uuid' from striker-installer.example for two reasons; ** 1. If the same kickstart is used, unaltered, on different dashboards they will have matching host_uuid entries in hosts (bug fix). ** 2. On rebuild, the host UUID could differ when using dmidecode's system-uuid would provide consistency over reinstalls (improved handling). Signed-off-by: Digimer --- AN/Tools/InstallManifest.pm | 16 ++++--------- AN/Tools/ScanCore.pm | 31 ++++++++++++++++--------- tools/anvil-generate-iso | 6 ----- tools/striker-installer | 46 +++++++++++++++++++++++++++---------- 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/AN/Tools/InstallManifest.pm b/AN/Tools/InstallManifest.pm index 33f89081..c9cd2ee2 100644 --- a/AN/Tools/InstallManifest.pm +++ b/AN/Tools/InstallManifest.pm @@ -3309,9 +3309,7 @@ sub configure_ipmi_on_node if ($line =~ /Success/i) { # Woo! - $an->Log->entry({log_level => 2, message_key => "log_0130", message_variables => { - channel => $channel, - }, file => $THIS_FILE, line => __LINE__}); + $an->Log->entry({log_level => 2, message_key => "log_0130", message_variables => { target => $channel }, file => $THIS_FILE, line => __LINE__}); } elsif ($line =~ /wrong password size/i) { @@ -3323,9 +3321,7 @@ sub configure_ipmi_on_node { # Password didn't take. :( $return_code = 1; - $an->Log->entry({log_level => 1, message_key => "log_0132", message_variables => { - channel => $channel, - }, file => $THIS_FILE, line => __LINE__}); + $an->Log->entry({log_level => 1, message_key => "log_0132", message_variables => { target => $channel }, file => $THIS_FILE, line => __LINE__}); } } if ($try_20) @@ -3350,17 +3346,13 @@ sub configure_ipmi_on_node if ($line =~ /Success/i) { # Woo! - $an->Log->entry({log_level => 2, message_key => "log_0133", message_variables => { - channel => $channel, - }, file => $THIS_FILE, line => __LINE__}); + $an->Log->entry({log_level => 2, message_key => "log_0133", message_variables => { target => $channel }, file => $THIS_FILE, line => __LINE__}); } elsif ($line =~ /password incorrect/i) { # Password didn't take. :( $return_code = 1; - $an->Log->entry({log_level => 1, message_key => "log_0132", message_variables => { - channel => $channel, - }, file => $THIS_FILE, line => __LINE__}); + $an->Log->entry({log_level => 1, message_key => "log_0132", message_variables => { target => $channel }, file => $THIS_FILE, line => __LINE__}); } } } diff --git a/AN/Tools/ScanCore.pm b/AN/Tools/ScanCore.pm index 34028607..f3515fd5 100644 --- a/AN/Tools/ScanCore.pm +++ b/AN/Tools/ScanCore.pm @@ -5744,15 +5744,7 @@ sub parse_install_manifest my $pdu3_key = "anvil_node".$i."_pdu3_outlet"; my $pdu4_key = "anvil_node".$i."_pdu4_outlet"; - # IPMI is, by default, tempremental about passwords. If the manifest doesn't specify - # the password to use, we'll copy the cluster password but then strip out special - # characters and shorten it to 16 characters or less. - my $default_ipmi_pw = $an->data->{cgi}{anvil_password}; - $default_ipmi_pw =~ s/!//g; - if (length($default_ipmi_pw) > 16) - { - $default_ipmi_pw = substr($default_ipmi_pw, 0, 16); - } + my $default_ipmi_pw = $an->data->{cgi}{anvil_password}; # Find the IPMI, PDU and KVM reference names my $ipmi_reference = ""; @@ -5861,6 +5853,23 @@ sub parse_install_manifest name1 => "cgi::$ipmi_password_key", value1 => $an->data->{cgi}{$ipmi_password_key}, }, file => $THIS_FILE, line => __LINE__}); + # IPMI is, by default, tempremental about passwords. If the manifest doesn't specify the + # password to use, we'll copy the cluster password but then strip out special characters and + # shorten it to 16 characters or less. + $an->data->{cgi}{$ipmi_password_key} =~ s/ //g; + $an->data->{cgi}{$ipmi_password_key} =~ s/!//g; + if (length($an->data->{cgi}{$ipmi_password_key}) > 16) + { + $an->data->{cgi}{$ipmi_password_key} = substr($an->data->{cgi}{$ipmi_password_key}, 0, 16); + } + + # Make sure the password matches later when we generate the cluster.conf file. + $an->data->{install_manifest}{$uuid}{node}{$node}{ipmi}{$ipmi_reference}{password} = $an->data->{cgi}{$ipmi_password_key}; + $an->Log->entry({log_level => 4, message_key => "an_variables_0002", message_variables => { + name1 => "cgi::$ipmi_password_key", value1 => $an->data->{cgi}{$ipmi_password_key}, + name2 => "install_manifest::${uuid}::node::${node}::ipmi::${ipmi_reference}::password", value2 => $an->data->{install_manifest}{$uuid}{node}{$node}{ipmi}{$ipmi_reference}{password}, + }, file => $THIS_FILE, line => __LINE__}); + # If the user remapped their network, we don't want to undo the results. if (not $an->data->{cgi}{perform_install}) { @@ -5959,8 +5968,8 @@ sub parse_install_manifest } # Build the string my $string = "{path}{example_install}." << EOF # and then call it with 'sh ".$conf->{path}{example_install}."' to save typing # all this out. # -# If you are rebuilding or replacing a dashboard and you know what the old host -# UUID was, you can specify it with '--host-uuid ' to have Scanner link -# this machine to the previous one's data in the ScanCore database. -# # To understand what all these switches do, and what other switches are # available, please run './striker-installer --help'. @@ -920,7 +915,6 @@ cat > ".$conf->{path}{example_install}." << EOF -b $my_bcn_ip/$conf->{sys}{ks}{bcn_netmask} \\\\ -p $dhcp_range \\\\ --peer-dashboard hostname=$conf->{sys}{ks}{prefix}-striker0${peer_number}.$conf->{sys}{ks}{domain},bcn_ip=$peer_ip \\\\ - --host-uuid $host_uuid \\\\ "; # Use '--rhn' on RHEL only. if ($conf->{sys}{os_type} eq "rhel") diff --git a/tools/striker-installer b/tools/striker-installer index b18bc865..0670903c 100755 --- a/tools/striker-installer +++ b/tools/striker-installer @@ -147,6 +147,7 @@ my $conf = { 'chmod' => "/bin/chmod", 'chown' => "/bin/chown", curl => "/usr/bin/curl", + dmidecode => "/usr/sbin/dmidecode", echo => "/bin/echo", gcc => "/usr/bin/gcc", git => "/usr/bin/git", @@ -5505,6 +5506,34 @@ sub install_striker_files exit(43); } } + else + { + # Use the system UUID as reported by dmidecode. + my $shell_call = $conf->{executable}{dmidecode}." --string system-uuid"; + my $host_uuid = ""; + logger($conf, $THIS_FILE, __LINE__, "shell_call: [$shell_call]", 3); + open (my $file_handle, "$shell_call 2>&1 |") or die "$THIS_FILE ".__LINE__."; Failed to call: [$shell_call], error was: $!\n"; + while(<$file_handle>) + { + chomp; + my $line = $_; + logger($conf, $THIS_FILE, __LINE__, "- Output: [$line]", 1); + if ($line =~ /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i) + { + $host_uuid = lc($line); + logger($conf, $THIS_FILE, __LINE__, "- host_uuid: [$host_uuid]", 1); + } + } + close $file_handle; + + if ($host_uuid) + { + logger($conf, $THIS_FILE, __LINE__, "- The system UUID is being used for the host UUID.", 1); + open (my $file_handle, ">", $conf->{path}{host_uuid}) or die "$THIS_FILE ".__LINE__."; Failed to write: [$conf->{path}{host_uuid}], the error was: $!\n"; + print $file_handle $host_uuid."\n"; + close $file_handle; + } + } # Update /etc/striker/striker.conf if a custom config was not used. if (not $conf->{switches}{'custom-config'}) @@ -8657,18 +8686,11 @@ SWITCHES If you want to use a set UUID to identify this machine in ScanCore, you can do so using this switch. This will only make sense if you are - rebuilding or replacing an old UUID. To record a machine's existing - host UUID, back up: - -|; - $help .= " $conf->{path}{host_uuid}\n"; -$help .= q| - In it will be the UUID used to identify each Anvil! - machine (Striker dashboards and Anvil! nodes). Note that the Install - Manifest records the UUIDs assigned to nodes as well. So replacing a - node using the previous manifest automatically re-uses the previous - host UUID. - + rebuilding or replacing an old dashboard with new hardware and you want + to use the old UUID to link the systems in the ScanCore database. + + Normally, the system UUID reported by dmidecode is used. + -i ,dg=[,dns1=,dns2=] This sets the IP address and subnet to be assigned to the