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

Fixed a bug where 'all' host jobs would not be shown.
main
Digimer 1 year ago committed by GitHub
commit 07cedb601f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      Anvil/Tools/Get.pm
  2. 27
      Anvil/Tools/Storage.pm
  3. 46
      Anvil/Tools/System.pm
  4. 2
      Anvil/Tools/Words.pm
  5. 1
      share/words.xml
  6. 7
      tools/anvil-join-anvil
  7. 2
      tools/anvil-watch-bonds
  8. 8
      tools/striker-show-jobs

@ -1455,18 +1455,24 @@ AND
This returns the full host name for the local machine. This returns the full host name for the local machine.
This method takes no parameters. Parameters;
=head3 refresh (optional, default '0')
If set to C<< 1 >>, and if C<< sys::host_name >>, the cached value will be ignored and the hostname will be queried directly.
=cut =cut
sub host_name sub host_name
{ {
### NOTE: This method doesn't offer logging. ### NOTE: This method doesn't offer logging.
my $self = shift; my $self = shift;
my $parameter = shift;
my $anvil = $self->parent; my $anvil = $self->parent;
my $refresh = defined $parameter->{refresh} ? $parameter->{refresh} : 0;
my $host_name = ""; my $host_name = "";
# NOTE: Don't use 'ENV{HOSTNAME}'! It lags behind changes made by 'hostnamectl'. # NOTE: Don't use 'ENV{HOSTNAME}'! It lags behind changes made by 'hostnamectl'.
if ($anvil->data->{sys}{host_name}) if ((not $refresh) && ($anvil->data->{sys}{host_name}))
{ {
# We have an environment variable, so use it. # We have an environment variable, so use it.
$host_name = $anvil->data->{sys}{host_name}; $host_name = $anvil->data->{sys}{host_name};

@ -4178,6 +4178,33 @@ sub read_file
return("!!error!!"); return("!!error!!");
} }
### TODO: The '$file' should be bash-escaped.
# See if the file even exists on the target.
my $shell_call = $anvil->data->{path}{exe}{ls}." '".$file."'";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => $debug,
target => $target,
port => $port,
password => $password,
remote_user => $remote_user,
shell_call => $shell_call,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
error => $error,
output => $output,
return_code => $return_code,
}});
if ($return_code)
{
# The file doesn't exist, so we can't copy it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0465", variables => {
file => $file,
target => $target,
}});
return("!!error!!");
}
# Setup the temp file name. # Setup the temp file name.
my $temp_file = $file; my $temp_file = $file;
$temp_file =~ s/\//_/g; $temp_file =~ s/\//_/g;

@ -3402,19 +3402,51 @@ sub host_name
# Set? # Set?
if ($set) if ($set)
{ {
my $shell_call = $anvil->data->{path}{exe}{hostnamectl}." set-hostname $set"; my $shell_call = $anvil->data->{path}{exe}{hostnamectl}." set-hostname ".$set;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $output = ""; my $output = "";
my $return_code = ""; my $return_code = "";
if ($anvil->Network->is_local({host => $target})) if ($anvil->Network->is_local({host => $target}))
{ {
# Load the hosts from the database so that we know which on to update.
$anvil->Database->get_hosts();
my $host_uuid = $anvil->Get->host_uuid;
my $current_host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_uuid => $host_uuid,
current_host_name => $current_host_name,
}});
# Local call # Local call
($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
# Update the database
$anvil->Database->insert_or_update_hosts({
debug => $debug,
host_ipmi => $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_ipmi},
host_key => $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_key},
host_name => $set,
host_type => $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_type},
host_uuid => $host_uuid,
host_status => $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_status},
});
# Reload hosts
$anvil->Database->get_hosts();
# Reload the host name
$anvil->Get->host_name({refresh => 1});
# Update the stored hostname
$anvil->data->{sys}{host_name} = $set;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::host_name" => $anvil->data->{sys}{host_name},
}});
} }
else else
{ {
@ -3452,6 +3484,12 @@ sub host_name
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
# Update the stored hostname
$anvil->data->{sys}{host_name} = $set;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::host_name" => $anvil->data->{sys}{host_name},
}});
} }
else else
{ {
@ -3487,6 +3525,12 @@ sub host_name
host_name => $host_name, host_name => $host_name,
return_code => $return_code, return_code => $return_code,
}}); }});
# Update the stored hostname
$anvil->data->{sys}{host_name} = $host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::host_name" => $anvil->data->{sys}{host_name},
}});
} }
else else
{ {

@ -129,7 +129,7 @@ sub center_text
}}); }});
return($string) if $width eq ""; return($string) if $width eq "";
return("") if $parameter->{string} eq ""; return("") if $string eq "";
### NOTE: If a '#!string!x!#' is passed, the Log->entry method will translate it in the log itself, ### NOTE: If a '#!string!x!#' is passed, the Log->entry method will translate it in the log itself,
### so you won't see that string. ### so you won't see that string.

@ -733,6 +733,7 @@ The XML that failed sanity check was:
#!variable!xml!# #!variable!xml!#
======== ========
]]></key> ]]></key>
<key name="error_0465"><![CDATA[The file: [#!variable!file!#] doesn't exist on the target: [#!variable!target!#].]]></key>
<!-- Files templates --> <!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable --> <!-- NOTE: Translating these files requires an understanding of which lines are translatable -->

@ -1505,6 +1505,9 @@ sub check_local_network
}}); }});
$anvil->data->{sys}{host_name} = $new_host_name; $anvil->data->{sys}{host_name} = $new_host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
'sys::host_name' => $anvil->data->{sys}{host_name},
}});
# If the hostname isn't the same, change it. # If the hostname isn't the same, change it.
if ($old_host_name ne $new_host_name) if ($old_host_name ne $new_host_name)
@ -1540,6 +1543,10 @@ sub check_local_network
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0077", variables => { host_name => $new_host_name }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0077", variables => { host_name => $new_host_name }});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
'sys::host_name' => $anvil->data->{sys}{host_name},
}});
# Read the local network manager data. # Read the local network manager data.
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0080"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0080");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0080"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0080"});

@ -663,6 +663,8 @@ while(1)
my $centered_failures = $anvil->Words->center_text({string => $fail_count, width => $failures_length}); my $centered_failures = $anvil->Words->center_text({string => $fail_count, width => $failures_length});
my $centered_mac_address = $anvil->Words->center_text({string => $mac_address, width => $mac_length}); my $centered_mac_address = $anvil->Words->center_text({string => $mac_address, width => $mac_length});
$anvil->data->{bond}{$bond_name}{slave}{$in_slave}{mii_status_raw} = "" if not $anvil->data->{bond}{$bond_name}{slave}{$in_slave}{mii_status_raw};
my $iface_name_colour = $anvil->data->{bond}{$bond_name}{slave}{$in_slave}{mii_status_raw} eq "up" ? $anvil->data->{colours}{bond}{interface} : $anvil->data->{bond}{$bond_name}{slave}{$in_slave}{status_colour}; my $iface_name_colour = $anvil->data->{bond}{$bond_name}{slave}{$in_slave}{mii_status_raw} eq "up" ? $anvil->data->{colours}{bond}{interface} : $anvil->data->{bond}{$bond_name}{slave}{$in_slave}{status_colour};
my $say_iface_name = colored($centered_iface_name, $iface_name_colour); my $say_iface_name = colored($centered_iface_name, $iface_name_colour);

@ -42,13 +42,13 @@ if (($anvil->data->{switches}{'ended-within'} eq "") or ($anvil->data->{switches
}}); }});
} }
$anvil->data->{show}{host_uuid} = ""; $anvil->data->{switches}{host_uuid} = "";
if (($anvil->data->{switches}{host}) && ($anvil->data->{switches}{host} ne "all")) if (($anvil->data->{switches}{host}) && ($anvil->data->{switches}{host} ne "all"))
{ {
# Get the host_uuid # Get the host_uuid
$anvil->data->{show}{host_uuid} = $anvil->Database->get_host_uuid_from_string({debug => 2, string => $anvil->data->{switches}{host}}); $anvil->data->{switches}{host_uuid} = $anvil->Database->get_host_uuid_from_string({debug => 2, string => $anvil->data->{switches}{host}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"show::host_uuid" => $anvil->data->{show}{host_uuid}, "switches::host_uuid" => $anvil->data->{switches}{host_uuid},
}}); }});
} }
@ -79,7 +79,7 @@ sub show_jobs
$anvil->Database->get_hosts({debug => 3}); $anvil->Database->get_hosts({debug => 3});
$anvil->Database->get_jobs({ $anvil->Database->get_jobs({
debug => 2, debug => 2,
job_host_uuid => $anvil->data->{show}{host_uuid} // "all", job_host_uuid => $anvil->data->{switches}{host_uuid} ? $anvil->data->{switches}{host_uuid} : "all",
ended_within => $anvil->data->{switches}{'ended-within'}, ended_within => $anvil->data->{switches}{'ended-within'},
}); });

Loading…
Cancel
Save