Merge pull request #246 from ClusterLabs/anvil-tools-dev

* Fixed a bug in anvil-configure-host where if the same MAC address w…
main
Digimer 2 years ago committed by GitHub
commit 3ca8aa45b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Anvil/Tools/Database.pm
  2. 1
      share/words.xml
  3. 69
      tools/anvil-configure-host

@ -8995,7 +8995,7 @@ WHERE
{
# Something changed, update
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
$anvil->Database->write({debug => $debug, uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
}
else

@ -530,6 +530,7 @@ The definition data passed in was:
<key name="error_0373">Long-throw requires a license, and the license file is not installed, and '--license-file /path/to/drbd-proxy.license' was not passed.</key>
<key name="error_0374">The long-throw license file: [#!variable!file!#] was not found, so unable to install it.</key>
<key name="error_0375">There was a problem with the "Long-throw" lincense file. This will prevent Long-Throw DR from working. Details of the error will be recorded in the log file.</key>
<key name="error_0376">[ Error ] - (At least) two interfaces have the same MAC address assigned to them. This should not happen, and would cause endless reboots. Unable to complete configuration, please re-map the network again and watch for duplicates. The duplicate MAC address is: [#!variable!mac_address!#] which is used by both: [#!variable!iface1!#] and: [#!variable!iface2!#].</key>
<!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable -->

@ -11,6 +11,7 @@
# 5 = Failed to write the temp file with the new password needed to call anvil-change-password.
# 6 = The job-uuid was not found.
# 7 = The host is an active cluster member.
# 8 = Duplicate NICs assigned to the same MAC address
#
# TODO:
# - Add MTU support
@ -367,6 +368,72 @@ sub reconfigure_network
# $ssh_fh = "";
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cache::ssh_fh::${ssh_fh_key}" => $anvil->data->{cache}{ssh_fh}{$ssh_fh_key} }});
# }
# Before we continue, see if there's two interfaces pointing at the same NIC. If so, the node would
# endlessly reboot.
my $macs = {};
my $query = "
SELECT
variable_uuid,
variable_name,
variable_value
FROM
variables
WHERE
variable_name LIKE '\%_mac_to_set::value'
AND
variable_source_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)."
ORDER BY
variable_name ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $variable_uuid = $row->[0];
my $variable_name = $row->[1];
my $variable_value = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:variable_uuid' => $variable_uuid,
's2:variable_name' => $variable_name,
's3:variable_value' => $variable_value,
}});
if ($variable_name =~ /form::config_step2::(.*?)_mac_to_set::value/)
{
my $device = lc($1);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { device => $device}});
if (not exists $macs->{$variable_value})
{
$macs->{$variable_value} = $device;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"macs->${variable_value}" => $macs->{$variable_value},
}});
}
else
{
# Fail out!
my $variables = {
mac_address => $variable_value,
iface1 => $macs->{$variable_value},
iface2 => $device,
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "error_0376", variables => $variables});
$anvil->Job->update_progress({
progress => 100,
message => "error_0376",
variables => $variables,
job_status => "failed",
});
$anvil->nice_exit({exit_code => 8});
}
}
}
# We'll set this to '1' if we reconfigure the network
$anvil->data->{sys}{reboot} = 0;
@ -1518,7 +1585,7 @@ LIKE
AND
variable_source_table = 'hosts'
AND
variable_source_uuid = ".$anvil->Database->quote($anvil->data->{sys}{host_uuid})."
variable_source_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});

Loading…
Cancel
Save