* Fixed a bug in Database->manage_anvil_conf() where the wrong password and port was being set.

* Fixed a bug in Get->host_uuid() where the call to get the host UUID from dmidecode was broken.
* Updated striker -> Initialize host to allow the user to set the host name of a node or host being initialized, allowing it to be registered with Red Hat under the proper name and make it easier to track which machine is which during initial Anvil! build.
* Fixed a few minor bugs with variable insertions into translated strings.
* Updated striker-initialize-host to use a progressive progress value rather than statically assigned steps.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 3e01537209
commit b57546e663
  1. 4
      Anvil/Tools/Database.pm
  2. 3
      Anvil/Tools/Get.pm
  3. 4
      Anvil/Tools/System.pm
  4. 73
      cgi-bin/striker
  5. 30
      html/skins/alteeve/anvil.html
  6. 4
      share/words.xml
  7. 12
      tools/striker-get-peer-data
  8. 136
      tools/striker-initialize-host
  9. 6
      tools/striker-manage-install-target

@ -5802,8 +5802,8 @@ sub manage_anvil_conf
if (not $remove)
{
$insert = $host_variable." = ".$db_host."\n";
$insert .= $port_variable." = ".$port."\n";
$insert .= $password_variable." = ".$password."\n";
$insert .= $port_variable." = ".$db_port."\n";
$insert .= $password_variable." = ".$db_password."\n";
$insert .= $ping_variable." = ".$db_ping."\n";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {

@ -596,7 +596,8 @@ sub host_uuid
elsif (($< == 0) or ($> == 0))
{
# Create the UUID file.
($uuid, my $return_code) = lc($anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{dmidecode}." --string system-uuid"}));
($uuid, my $return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{dmidecode}." --string system-uuid"});
$uuid = lc($uuid);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
uuid => $uuid,
return_code => $return_code,

@ -350,6 +350,10 @@ sub call
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => $secure, list => {
output => $output,
return_code => $return_code,
}});
return($output, $return_code);
}

@ -257,7 +257,7 @@ sub process_task
$anvil->data->{cgi}{login}{value} = "" if not defined $anvil->data->{cgi}{login}{value};
$anvil->data->{cgi}{logout}{value} = "" if not defined $anvil->data->{cgi}{logout}{value};
$anvil->data->{cgi}{save}{value} = "" if not defined $anvil->data->{cgi}{save}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"cgi::login::value" => $anvil->data->{cgi}{login}{value},
"cgi::logout::value" => $anvil->data->{cgi}{logout}{value},
"cgi::save::value" => $anvil->data->{cgi}{save}{value},
@ -721,21 +721,25 @@ sub process_prep_host_page
{
my ($anvil) = @_;
my $host_ip_address = defined $anvil->data->{cgi}{host_ip_address}{value} ? $anvil->data->{cgi}{host_ip_address}{value} : "";
my $host_password = defined $anvil->data->{cgi}{host_password}{value} ? $anvil->data->{cgi}{host_password}{value} : "";
my $rh_user = defined $anvil->data->{cgi}{rh_user}{value} ? $anvil->data->{cgi}{rh_user}{value} : "";
my $rh_password = defined $anvil->data->{cgi}{rh_password}{value} ? $anvil->data->{cgi}{rh_password}{value} : "";
my $type = defined $anvil->data->{cgi}{type}{value} ? $anvil->data->{cgi}{type}{value} : "";
my $connect = defined $anvil->data->{cgi}{'connect'}{value} ? $anvil->data->{cgi}{'connect'}{value} : "";
my $confirm = defined $anvil->data->{cgi}{confirm}{value} ? $anvil->data->{cgi}{confirm}{value} : "";
my $host_name = defined $anvil->data->{cgi}{host_name}{value} ? $anvil->data->{cgi}{host_name}{value} : "";
my $default_host_name = defined $anvil->data->{cgi}{default_host_name}{value} ? $anvil->data->{cgi}{default_host_name}{value} : "";
my $host_ip_address = defined $anvil->data->{cgi}{host_ip_address}{value} ? $anvil->data->{cgi}{host_ip_address}{value} : "";
my $host_password = defined $anvil->data->{cgi}{host_password}{value} ? $anvil->data->{cgi}{host_password}{value} : "";
my $rh_user = defined $anvil->data->{cgi}{rh_user}{value} ? $anvil->data->{cgi}{rh_user}{value} : "";
my $rh_password = defined $anvil->data->{cgi}{rh_password}{value} ? $anvil->data->{cgi}{rh_password}{value} : "";
my $type = defined $anvil->data->{cgi}{type}{value} ? $anvil->data->{cgi}{type}{value} : "";
my $connect = defined $anvil->data->{cgi}{'connect'}{value} ? $anvil->data->{cgi}{'connect'}{value} : "";
my $confirm = defined $anvil->data->{cgi}{confirm}{value} ? $anvil->data->{cgi}{confirm}{value} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_ip_address => $host_ip_address,
host_password => $anvil->Log->is_secure($host_password),
rh_user => $rh_user,
rh_password => $anvil->Log->is_secure($rh_password),
type => $type,
'connect' => $connect,
confirm => $confirm,
host_name => $host_name,
default_host_name => $default_host_name,
host_ip_address => $host_ip_address,
host_password => $anvil->Log->is_secure($host_password),
rh_user => $rh_user,
rh_password => $anvil->Log->is_secure($rh_password),
type => $type,
'connect' => $connect,
confirm => $confirm,
}});
# Is the IP or hostname valid?
@ -760,6 +764,12 @@ sub process_prep_host_page
password => $anvil->Log->is_secure($host_password),
}});
my $say_host_name = "host_name=\n";
if (($host_name) && ($host_name ne $default_host_name))
{
$say_host_name = "host_name=".$host_name."\n";
}
# Store the peer's password as the job data
my $job_data = "password=".$host_password."\n";
$job_data .= "rh_password=".$rh_password."\n";
@ -767,6 +777,7 @@ sub process_prep_host_page
$job_data .= "host_ip_address=".$host_ip_address."\n";
$job_data .= "ssh_port=".$ssh_port."\n";
$job_data .= "type=".$type."\n";
$job_data .= $say_host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { job_data => $job_data }});
# Store the job
@ -912,11 +923,12 @@ sub process_prep_host_page
{
# Connected! Ask th euser to confirm.
$anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "confirm-initialize-host", variables => {
'package' => $type eq "dr" ? "anvil-dr" : "anvil-node",
redhat => $rh_template,
access => "root\@".$host_ip_address.":".$ssh_port,
host_name => $target_host_name,
host_uuid => $target_host_uuid,
'package' => $type eq "dr" ? "anvil-dr" : "anvil-node",
redhat => $rh_template,
access => "root\@".$host_ip_address.":".$ssh_port,
host_name => $target_host_name,
host_uuid => $target_host_uuid,
default_host_name => $default_host_name,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }});
}
@ -937,10 +949,25 @@ sub process_prep_host_page
dr_checked => $dr_checked,
}});
my $host_name = $anvil->_hostname;
$host_name =~ s/striker\d\d/xxx/;
my $default_host_name = $host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
default_host_name => $default_host_name,
host_name => $host_name,
}});
if ((exists $anvil->data->{cgi}{host_name}) && ($anvil->data->{cgi}{host_name}{value}))
{
$host_name = $anvil->data->{cgi}{host_name}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_name => $host_name }});
}
my $form_body = $anvil->Template->get({file => "anvil.html", name => "host-setup-menu1", variables => {
host_ip_address => $host_ip_address,
node_checked => $node_checked,
dr_checked => $dr_checked,
host_name => $host_name,
default_host_name => $default_host_name,
host_ip_address => $host_ip_address,
node_checked => $node_checked,
dr_checked => $dr_checked,
}});
$anvil->data->{form}{refresh_link} = "?anvil=true&task=prep-host";

@ -98,6 +98,22 @@
&nbsp;
</td>
</tr>
<tr>
<td colspan="3">
#!string!message_0150!#
</td>
</tr>
<tr>
<td colspan="3">
<input type="text" name="host_name" id="host_name" value="#!variable!host_name!#" placeholder="#!string!striker_0016!#" />
<input type="hidden" name="default_host_name" id="default_host_name" value="#!variable!default_host_name!#" />
</td>
</tr>
<tr>
<td colspan="3">
&nbsp;
</td>
</tr>
<tr>
<td colspan="3">
#!string!message_0147!#
@ -186,12 +202,14 @@
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0128!#">
</td>
</tr>
<input type="hidden" name="anvil" id="anvil" value="#!data!cgi::anvil::value!#">
<input type="hidden" name="connect" id="connect" value="#!data!cgi::connect::value!#">
<input type="hidden" name="host_ip_address" id="host_ip_address" value="#!data!cgi::host_ip_address::value!#">
<input type="hidden" name="host_password" id="host_password" value="#!data!cgi::host_password::value!#">
<input type="hidden" name="type" id="type" value="#!data!cgi::type::value!#">
<input type="hidden" name="task" id="task" value="#!data!cgi::task::value!#">
<input type="hidden" name="anvil" id="anvil" value="#!data!cgi::anvil::value!#">
<input type="hidden" name="connect" id="connect" value="#!data!cgi::connect::value!#">
<input type="hidden" name="host_ip_address" id="host_ip_address" value="#!data!cgi::host_ip_address::value!#">
<input type="hidden" name="host_password" id="host_password" value="#!data!cgi::host_password::value!#">
<input type="hidden" name="type" id="type" value="#!data!cgi::type::value!#">
<input type="hidden" name="task" id="task" value="#!data!cgi::task::value!#">
<input type="hidden" name="host_name" id="host_name" value="#!data!cgi::host_name::value!#">
<input type="hidden" name="default_host_name" id="default_host_name" value="#!data!cgi::default_host_name::value!#">
</div>
</table>
</td>

@ -254,6 +254,7 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t
<key name="message_0147"><![CDATA[What is the host's <b>current</b> IP address and password?]]></key>
<key name="message_0148"><![CDATA[This is a RHEL host and has not yet been subscribed.<br />You can enter your Red Hat subscription credentials below.<br />The host will be subscribed during setup.]]></key>
<key name="message_0149">The target's host key has changed. If the target has been rebuilt, or the target IP reused, the old key will need to be removed. If this is the case, remove line: [#!variable!line!#] from: [#!variable!file!#].</key>
<key name="message_0150">Set the new host name.</key>
<!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key>
@ -1028,6 +1029,9 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0058">The state UUID: [#!variable!state_uuid!#] is for the machine with the host UUID: [#!variable!host_uuid!#], which is not us. This is probably a progrem error, skipping this.</key>
<key name="job_0059">[ Error ] - There was a problem writing the file: [#!variable!file!#]. Details will be found in the logs.</key>
<key name="job_0060">Success! The file: [#!variable!file!#] has been updated.</key>
<key name="job_0061">Setting the host name to: [#!variable!host_name!#]...</key>
<key name="job_0062">[ Error ] - The host name: [#!variable!host_name!#] is invalid. Skipping host name setup.</key>
<key name="job_0063">[ Error ] - Something went wrong. The host name was set to: [#!variable!host_name!#], but the host name returned was: [#!variable!current_host_name!#].</key>
<!-- Warnings -->
<key name="striker_warning_0001">The IP address will change. You will need to reconnect after applying these changes.</key>

@ -110,7 +110,7 @@ then
fi;
";
my ($file_body, $error, $return_code) = $anvil->Remote->call({
debug => 2,
debug => 3,
shell_call => $shell_call,
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},
@ -139,7 +139,7 @@ fi;
# Is it subscribed? This isn't the best call to make, but it seems to be the one that returns
# the fastest. Return code of '0' is registered, return code of '1' is not or not verified.
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => 2,
debug => 3,
shell_call => $anvil->data->{path}{exe}{'subscription-manager'}." identity",
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},
@ -190,7 +190,7 @@ sub get_host_name
my ($anvil) = @_;
my ($host_name, $error, $return_code) = $anvil->Remote->call({
debug => 2,
debug => 3,
shell_call => $anvil->data->{path}{exe}{hostnamectl}." --static",
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},
@ -213,7 +213,7 @@ sub get_host_uuid
# This is the first thing called, so start by verifying we can talk to the target at all.
my $access = $anvil->Remote->test_access({
debug => 2,
debug => 3,
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},
port => $anvil->data->{target}{port},
@ -239,7 +239,7 @@ then
fi;
";
my ($file_body, $error, $return_code) = $anvil->Remote->call({
debug => 2,
debug => 3,
shell_call => $shell_call,
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},
@ -259,7 +259,7 @@ fi;
{
# No good, Try dmidecode.
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => 2,
debug => 3,
shell_call => $anvil->data->{path}{exe}{dmidecode}." --string system-uuid",
user => $anvil->data->{target}{user},
target => $anvil->data->{target}{host},

@ -50,8 +50,10 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->nice_exit({exit_code => 1});
}
$anvil->data->{job}{progress} = 0;
get_job_details($anvil);
wait_for_access($anvil);
set_host_name($anvil);
add_repos($anvil);
add_databases($anvil);
@ -62,6 +64,59 @@ $anvil->nice_exit({code => 0});
# Functions #
#############################################################################################################
# Set the host name, if needed.
sub set_host_name
{
my ($anvil) = @_;
### TODO: Left off here;
### - Validate host name
### - Update progress values
### - Set hostnamectl
if ((not defined $anvil->data->{data}{host_name}) or (not $anvil->data->{data}{host_name}))
{
return(0);
}
$anvil->data->{job}{progress} += 5;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0061", variables => { host_name => $anvil->data->{data}{host_name} }});
update_progress($anvil, $anvil->data->{job}{progress}, "job_0061,!!host_name!".$anvil->data->{data}{host_name}."!!");
if (not $anvil->Validate->is_domain_name({name => $anvil->data->{data}{host_name}}))
{
# Bad hostname.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0062", variables => { host_name => $anvil->data->{data}{host_name} }});
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0062,!!host_name!".$anvil->data->{data}{host_name}."!!");
return(1);
}
# Try to set the host name now.
my ($host_name, $descriptive_host_name) = $anvil->System->hostname({debug => 2, set => $anvil->data->{data}{host_name}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_name => $host_name,
descriptive_host_name => $descriptive_host_name,
}});
if ($host_name eq $anvil->data->{data}{host_name})
{
# Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0034"});
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0034");
}
else
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0063", variables => {
host_name => $anvil->data->{data}{host_name},
current_host_name => $host_name,
}});
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0063,!!host_name!".$anvil->data->{data}{host_name}."!!,!!current_host_name!".$host_name."!!");
return(1);
}
return(0);
}
# Add any databases we're using to the initialized host.
sub add_databases
{
@ -71,7 +126,8 @@ sub add_databases
# possible at this stage that the target doesn't have a BCN IP. So we need to figure out what IP it
# has and we have that are on the same subnet.
# Scan our network and the target's network, then compare them.
update_progress($anvil, 95, "job_0046");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0046");
my $target = $anvil->data->{data}{host_ip_address};
$anvil->Network->get_ips();
$anvil->Network->get_ips({
@ -112,6 +168,7 @@ sub add_databases
last if $db_host;
}
### TODO: Left off here. The password written to the target isn't right. Also, host.uuid is failing to be written.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { db_host => $db_host }});
if ($db_host)
{
@ -150,7 +207,8 @@ sub add_repos
my ($anvil) = @_;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0028"});
update_progress($anvil, 6, "job_0028");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0028");
# Add the local repo.
my $repo = $anvil->Striker->get_local_repo({debug => 3});
@ -180,7 +238,8 @@ EOF
return_code => $return_code,
}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0029"});
update_progress($anvil, 7, "job_0029");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0029");
}
# If I have a Red Hat user and password, try to subscribe this syste,.
@ -189,7 +248,8 @@ EOF
# If there's no internet, this will fail. If the network is up, we can see if the
# registration is still needed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0030"});
update_progress($anvil, 7, "job_0030");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0030");
# We'll attach subscriptions if this is set
my $subscribe = 1;
@ -210,13 +270,15 @@ EOF
{
# Already registered.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0031"});
update_progress($anvil, 10, "job_0031");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0031");
}
elsif ($return_code eq "1")
{
# Registration is needed. This can take a while, so we give it a generous timeout.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0033"});
update_progress($anvil, 8, "job_0033");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0033");
my $bash_password = $anvil->data->{data}{rh_password};
$bash_password =~ s/'/\\\'/g;
my ($output, $error, $return_code) = $anvil->Remote->call({
@ -237,7 +299,8 @@ EOF
{
# No Internet (or can't reach the subscriion servers)
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0032"});
update_progress($anvil, 10, "job_0032");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0032");
$subscribe = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { subscribe => $subscribe }});
}
@ -249,7 +312,8 @@ EOF
error => $error,
return_code => $return_code,
}});
update_progress($anvil, 10, "job_0035,!!return_code!".$return_code."!!,!!output!".$output."!!,!!error!".$error."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0035,!!return_code!".$return_code."!!,!!output!".$output."!!,!!error!".$error."!!");
$subscribe = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { subscribe => $subscribe }});
}
@ -257,14 +321,16 @@ EOF
{
# Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0034"});
update_progress($anvil, 9, "job_0034");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0034");
}
}
elsif ($return_code eq "70")
{
# No Internet (or can't reach the subscriion servers)
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0032"});
update_progress($anvil, 10, "job_0032");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0032");
$subscribe = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { subscribe => $subscribe }});
}
@ -282,7 +348,8 @@ EOF
# need 'rhel-8-for-x86_64-highavailability-rpms'
# We blindly subscribe, then we'll check that they're actually subscribed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0036", variables => { repo => 'codeready-builder-for-rhel-8-x86_64-rpms' }});
update_progress($anvil, 10, "job_0036,!!repo!codeready-builder-for-rhel-8-x86_64-rpms!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0036,!!repo!codeready-builder-for-rhel-8-x86_64-rpms!!");
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => 3,
shell_call => $anvil->data->{path}{exe}{'subscription-manager'}." repos --enable codeready-builder-for-rhel-8-x86_64-rpms",
@ -303,7 +370,8 @@ EOF
if ($anvil->data->{data}{type} eq "node")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0036", variables => { repo => 'rhel-8-for-x86_64-highavailability-rpms' }});
update_progress($anvil, 15, "job_0036,!!repo!rhel-8-for-x86_64-highavailability-rpms!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0036,!!repo!rhel-8-for-x86_64-highavailability-rpms!!");
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => 3,
shell_call => $anvil->data->{path}{exe}{'subscription-manager'}." repos --enable rhel-8-for-x86_64-highavailability-rpms",
@ -324,7 +392,8 @@ EOF
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0037"});
update_progress($anvil, 20, "job_0037");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0037");
undef $output;
undef $error;
undef $return_code;
@ -360,7 +429,8 @@ EOF
if (not $anvil->data->{repos}{$repo})
{
# Well this is a problem...
update_progress($anvil, 25, "job_0038,!!repo!".$repo."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0038,!!repo!".$repo."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0038", variables => { repo => $repo }});
}
}
@ -368,8 +438,10 @@ EOF
}
# Call an OS update.
update_progress($anvil, 29, "job_0039");
update_progress($anvil, 30, "job_0040");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0039");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0040");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0039"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0040"});
my ($output, $error, $return_code) = $anvil->Remote->call({
@ -388,7 +460,8 @@ EOF
}});
# Now remove biosdevname
update_progress($anvil, 50, "job_0041");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0041");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0041"});
undef $output;
undef $error;
@ -410,8 +483,10 @@ EOF
# Install the anvil package now.
my $package = $anvil->data->{data}{type} eq "dr" ? "anvil-dr" : "anvil-node";
update_progress($anvil, 70, "job_0042,!!package!".$package."!!");
update_progress($anvil, 75, "job_0040");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0042,!!package!".$package."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0040");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0042", variables => { 'package' => $package }});
undef $output;
undef $error;
@ -431,7 +506,8 @@ EOF
return_code => $return_code,
}});
update_progress($anvil, 80, "job_0043");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0043");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0043"});
undef $output;
undef $error;
@ -462,7 +538,8 @@ EOF
{
# Found it!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0045"});
update_progress($anvil, 90, "job_0045");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0045");
}
return(0);
@ -475,7 +552,8 @@ sub wait_for_access
# Test access
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0023", variables => { target => $anvil->data->{data}{say_target} }});
update_progress($anvil, 2, "job_0023,!!target!".$anvil->data->{data}{say_target}."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0023,!!target!".$anvil->data->{data}{say_target}."!!");
my $waiting = 1;
my $access = 0;
my $timeout = time + 600;
@ -493,7 +571,8 @@ sub wait_for_access
if ($access)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0024"});
update_progress($anvil, 5, "job_0024");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0024");
$waiting = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { waiting => $waiting }});
}
@ -508,10 +587,11 @@ sub wait_for_access
else
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "job_0025", variables => {
target => $anvil->data->{data}{say_target},
time_left => $time_left,
target => $anvil->data->{data}{say_target},
timeout => $time_left,
}});
update_progress($anvil, 3, "job_0025,!!timeout!".$time_left."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0025,!!target!".$anvil->data->{data}{say_target}."!!,!!timeout!".$time_left."!!");
sleep 5;
}
}
@ -602,7 +682,8 @@ sub get_job_details
# Update that we've picked the job up.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "job_0027", variables => { 'job-uuid' => $anvil->data->{switches}{'job-uuid'} }});
update_progress($anvil, 0, "clear");
update_progress($anvil, 1, "job_0027,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!");
$anvil->data->{job}{progress} += 5;
update_progress($anvil, $anvil->data->{job}{progress}, "job_0027,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!");
return(0);
}
@ -612,6 +693,7 @@ sub update_progress
{
my ($anvil, $progress, $message) = @_;
$progress = 95 if $progress > 100;
if (not $anvil->data->{switches}{'job-uuid'})
{
return(0);

@ -133,7 +133,7 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->nice_exit({exit_code => 8});
}
update_progress($anvil, 0, "clear");
update_progress($anvil, 1, "log_0239");
update_progress($anvil, 1, "log_0239,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!");
# If we're being asked to disable, just do so and exit.
if ($anvil->data->{switches}{disable})
@ -392,8 +392,8 @@ sub check_refresh
# It's been long enough (or it's the first time), refresh.
$anvil->data->{switches}{refresh} = 1;
my $variables = { seconds => $anvil->Convert->add_commas({number => $anvil->data->{'install-manifest'}{'refresh-period'}}) };
print $anvil->Words->string({key => "log_0239", variables => $variables})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0239", variables => $variables});
print $anvil->Words->string({key => "log_0238", variables => $variables})."\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0238", variables => $variables});
return(0);
}
elsif ($difference > 0)

Loading…
Cancel
Save