diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm index 02b11cde..f0e114d4 100644 --- a/Anvil/Tools/Striker.pm +++ b/Anvil/Tools/Striker.pm @@ -920,15 +920,6 @@ WHERE }}); } - foreach my $hash_ref (@{$parsed_xml->{fences}{fence}}) - { - my $fence_name = $hash_ref->{name}; - $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{fences}{$fence_name} = $hash_ref->{uuid}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "manifests::manifest_uuid::${manifest_uuid}::parsed::fences::${fence_name}" => $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{fences}{$fence_name}, - }}); - } - $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{dns} = $parsed_xml->{networks}{dns}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp} = $parsed_xml->{networks}{ntp}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{mtu} = $parsed_xml->{networks}{mtu}; diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index c4734eef..e1c628d9 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -641,7 +641,7 @@ This method does several things; 1. This makes sure the users on this system have SSH keys, and creates the keys if needed. 2. It records the user's keys in the C<< ssh_keys >> table. -3. For the dashboard machines it uses, it adds their host machine public key (SSH fingerprint) to C<< ~/.ssh/known_hosts >>. +3. For the dashboard machines whose databases this host uses, it adds their host machine public key (SSH fingerprint) to C<< ~/.ssh/known_hosts >>. 4. If this machine is a node or DR host, it sets up passwordless SSH between the other machines in the same Anvil! system. This works on the C<< admin >> and C<< root >> users. If the host is a node, it will also work on the c<< hacluster >> user. @@ -660,16 +660,16 @@ sub check_ssh_keys $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_memory()" }}); # We do a couple things here. First we make sure our user's keys are up to date and stored in the - # 'ssh_keys' table. Then we look through the 'trusts' table for any other users@hosts we're supposed - # to trust. For each, we make sure that they're in the appropriate local user's authorized_keys file. - my $users = $anvil->Get->host_type eq "node" ? ["root", "admin", "hacluster"] : ["root", "admin"]; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { users => \@{$users} }}); + # 'ssh_keys' table. Then we look through the 'Get->trusted_hosts' array any other users@hosts we're + # supposed to trust. For each, we make sure that they're in the appropriate local user's + # authorized_keys file. # Load the host keys and the SSH keys $anvil->Database->get_hosts({debug => $debug}); $anvil->Database->get_ssh_keys({debug => $debug}); # Users to check: + my $users = ["root", "admin"]; foreach my $user (@{$users}) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { user => $user }}); @@ -3967,7 +3967,7 @@ sub update_hosts # Get the list of hosts we trust. my $trusted_host_uuids = $anvil->Get->trusted_hosts({debug => $debug}); - $anvil->Database->get_ip_addresses({debug => 2}); + $anvil->Database->get_ip_addresses({debug => $debug}); foreach my $host_uuid (keys %{$anvil->data->{hosts}{host_uuid}}) { diff --git a/cgi-bin/striker b/cgi-bin/striker index 34fff277..21eee4dd 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -1694,6 +1694,53 @@ sub run_manifest dr1_anvil => $dr1_anvil, }}); + # Make sure the three options are unique. + if ($node1_host_uuid eq $node2_host_uuid) + { + my $message = $anvil->Words->string({key => "warning_0054"}); + $problem = 1; + $anvil->data->{cgi}{node1_host}{alert} = 1; + $anvil->data->{cgi}{node2_host}{alert} = 1; + $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + problem => $problem, + "cgi::node1_host::alert" => $anvil->data->{cgi}{node1_host}{alert}, + "cgi::node2_host::alert" => $anvil->data->{cgi}{node2_host}{alert}, + "form::error_massage" => $anvil->data->{form}{error_massage}, + }}); + } + if ($dr1_host_uuid) + { + if ($dr1_host_uuid eq $node1_host_uuid) + { + my $message = $anvil->Words->string({key => "warning_0055"}); + $problem = 1; + $anvil->data->{cgi}{dr1_host}{alert} = 1; + $anvil->data->{cgi}{node1_host}{alert} = 1; + $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + problem => $problem, + "cgi::dr1_host::alert" => $anvil->data->{cgi}{dr1_host}{alert}, + "cgi::node1_host::alert" => $anvil->data->{cgi}{node1_host}{alert}, + "form::error_massage" => $anvil->data->{form}{error_massage}, + }}); + } + elsif ($dr1_host_uuid eq $node2_host_uuid) + { + my $message = $anvil->Words->string({key => "warning_0056"}); + $problem = 1; + $anvil->data->{cgi}{dr1_host}{alert} = 1; + $anvil->data->{cgi}{node2_host}{alert} = 1; + $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + problem => $problem, + "cgi::dr1_host::alert" => $anvil->data->{cgi}{dr1_host}{alert}, + "cgi::node2_host::alert" => $anvil->data->{cgi}{node2_host}{alert}, + "form::error_massage" => $anvil->data->{form}{error_massage}, + }}); + } + } + if (($node1_anvil) && ($node1_anvil ne $anvil_name)) { # The server belongs to another Anvil! system. @@ -2540,15 +2587,12 @@ sub handle_manifest "cgi::${gateway_key}::alert" => $anvil->data->{cgi}{$gateway_key}{alert}, }}); - $network_form .= $anvil->Template->get({file => "anvil.html", name => "manifest-step2-network-entry-gateway", variables => { + $network_form .= $anvil->Template->get({file => "anvil.html", name => "manifest-step2-network-entry", variables => { network => $say_bcn, network_name => $network_key, network_class => $anvil->data->{cgi}{$network_key}{alert} ? "input_alert" : "", network_value => $anvil->data->{cgi}{$network_key}{value}, subnet => '255.255.0.0 ', - gateway_name => $gateway_key, - gateway_class => $anvil->data->{cgi}{$gateway_key}{alert} ? "input_alert" : "", - gateway_value => $anvil->data->{cgi}{$gateway_key}{value}, }}); } diff --git a/rpm/SPECS/anvil.spec b/rpm/SPECS/anvil.spec index 874d0a9c..d7f09bd0 100644 --- a/rpm/SPECS/anvil.spec +++ b/rpm/SPECS/anvil.spec @@ -24,6 +24,7 @@ WARNING: This is an alpha-stage project. Many features are missing and this %package core Summary: Alteeve's Anvil! Core package Requires: bash-completion +Requires: binutils Requires: chrony Requires: bind-utils Requires: dmidecode diff --git a/share/words.xml b/share/words.xml index 144b3509..904fdcdd 100644 --- a/share/words.xml +++ b/share/words.xml @@ -341,7 +341,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec Enabled and started the daemon: [#!variable!daemon!#]. Disable and stop the daemon: [#!variable!daemon!#]. This is a DR host, skipping pacemaker configuration. - + Successfully authorized using 'pcsd' on both nodes. No existing cluster found, will run initial setup. The corosync.conf file does not exist locally, but it does exist on the peer. Copying the file to here. @@ -354,6 +354,11 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec Corosync is not yet configured, waiting. It will be created when node 1 initializes the cluster. Corosync is configured. Will wait for the cluster to start. If it hasn't started in two minutes, we'll try to join it. We will now wait for the cluster to start. + The interface: [#!variable!interface!#] has a DNS entry: [#!variable!dns_line!#], but it is not the default gateway. Removing the line. + The interface: [#!variable!interface!#] has a GATEWAY entry: [#!variable!gateway_line!#], but it is not the default gateway. Removing the line. + Updating the '/etc/hosts' file. + Checking the SSH configuration. + Configuring the IPMI BMC. Please be patient, this could take a minute. Starting: [#!variable!program!#]. @@ -1715,6 +1720,9 @@ The error was: #!variable!error!# ======== + [ Warning ] - Node 1 and Node 2 are set to the same machine. + [ Warning ] - The DR Host is set to the same machine as Node 1. + [ Warning ] - The DR Host is set to the same machine as Node 2. diff --git a/tools/anvil-join-anvil b/tools/anvil-join-anvil index c901d395..c7ab6d3c 100755 --- a/tools/anvil-join-anvil +++ b/tools/anvil-join-anvil @@ -258,6 +258,7 @@ sub configure_pacemaker { # Try to authenticate against the peer. my $auth_shell_call = $anvil->data->{path}{exe}{pcs}." host auth ".$node1_host_name." ".$node2_host_name." -u hacluster -p ".$escaped_password; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { auth_shell_call => $auth_shell_call }}); my ($output, $return_code) = $anvil->System->call({debug => 3, secure => 1, shell_call => $auth_shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, @@ -369,171 +370,9 @@ sub configure_pacemaker } } - - die; + # Setup fencing! =cut $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}; -$VAR1 = { - 'fences' => { - 'pulsar' => 'c2be8d2e-045e-45d0-80e7-7443f2314fb1', - 'el8-pdu02' => '2681049b-1ae7-444a-890b-39aca262e79e', - 'el8-pdu01' => 'bad1fc5c-5342-4385-8d0d-a87a342dd87d', - 'an-nas02' => '4117a862-f58f-4676-991a-9ca257a3c612' - }, - 'domain' => 'digimer.ca', - 'networks' => { - 'count' => { - 'ifn' => 1, - 'bcn' => 1, - 'sn' => 1 - }, - 'dns' => '8.8.8.8,8.8.4.4', - 'mtu' => '1500', - 'ntp' => '10.201.14.1,10.201.14.2', - 'name' => { - 'ifn1' => { - 'subnet' => '255.255.255.0', - 'gateway' => '192.168.122.1', - 'network' => '192.168.122.0' - }, - 'bcn1' => { - 'network' => '10.201.0.0', - 'gateway' => '', - 'subnet' => '255.255.0.0' - }, - 'sn1' => { - 'gateway' => '', - 'network' => '10.101.0.0', - 'subnet' => '255.255.0.0' - } - } - }, - 'upses' => { - 'el8-ups01' => { - 'uuid' => '7ebecdda-782d-4624-841d-98d912ed3d50' - }, - 'el8-ups02' => { - 'uuid' => '7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f' - } - }, - 'machine' => { - 'node2' => { - 'network' => { - 'bcn1' => { - 'ip' => '10.201.10.2' - }, - 'sn1' => { - 'ip' => '10.101.10.2' - }, - 'ifn1' => { - 'ip' => '192.168.122.12' - } - }, - 'ups' => { - 'el8-ups01' => { - 'used' => '0' - }, - 'el8-ups02' => { - 'used' => '0' - } - }, - 'fence' => { - 'pulsar' => { - 'port' => '' - }, - 'el8-pdu02' => { - 'port' => '' - }, - 'el8-pdu01' => { - 'port' => '' - }, - 'an-nas02' => { - 'port' => 'el8-a01n02' - } - }, - 'name' => 'el8-a01n02', - 'ipmi_ip' => '' - }, - 'node1' => { - 'ipmi_ip' => '', - 'name' => 'el8-a01n01', - 'ups' => { - 'el8-ups02' => { - 'used' => '0' - }, - 'el8-ups01' => { - 'used' => '0' - } - }, - 'network' => { - 'ifn1' => { - 'ip' => '192.168.122.11' - }, - 'bcn1' => { - 'ip' => '10.201.10.1' - }, - 'sn1' => { - 'ip' => '10.101.10.1' - } - }, - 'fence' => { - 'el8-pdu02' => { - 'port' => '' - }, - 'pulsar' => { - 'port' => '' - }, - 'an-nas02' => { - 'port' => 'el8-a01n01' - }, - 'el8-pdu01' => { - 'port' => '' - } - } - }, - 'dr1' => { - 'fence' => { - 'pulsar' => { - 'port' => '' - }, - 'el8-pdu02' => { - 'port' => '' - }, - 'el8-pdu01' => { - 'port' => '' - }, - 'an-nas02' => { - 'port' => '' - } - }, - 'network' => { - 'bcn1' => { - 'ip' => '10.201.10.3' - }, - 'sn1' => { - 'ip' => '10.101.10.3' - }, - 'ifn1' => { - 'ip' => '192.168.122.13' - } - }, - 'ups' => { - 'el8-ups02' => { - 'used' => '0' - }, - 'el8-ups01' => { - 'used' => '0' - } - }, - 'name' => 'el8-a01dr01', - 'ipmi_ip' => '' - } - }, - 'sequence' => '01', - 'name' => 'el8-anvil-01', - 'prefix' => 'el8' - }; - 909; xxx::upses::el8-ups01::uuid: [7ebecdda-782d-4624-841d-98d912ed3d50] 909; xxx::upses::el8-ups02::uuid: [7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f] @@ -679,7 +518,6 @@ sub check_local_network }}); foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) { - ### BUG: DNS gets replicated, but updated. # Only one interface will start with the network name and have an IP address. next if $in_iface !~ /^${network}_/; next if not $anvil->data->{network}{'local'}{interface}{$in_iface}{ip}; @@ -709,6 +547,7 @@ sub check_local_network $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { default_gateway_interface => $default_gateway_interface }}); } + my $change = 0; my $cleaned_current_dns = ""; my @current_dns_array = split/,/, $current_dns; foreach my $this_current_dns (sort {$a cmp $b} @current_dns_array) @@ -719,7 +558,6 @@ sub check_local_network $cleaned_current_dns =~ s/,$//; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cleaned_current_dns => $cleaned_current_dns }}); - my $change = 0; if (($current_ip ne $ip) or ($current_subnet ne $subnet)) { # IP / subnet changed. @@ -737,22 +575,30 @@ sub check_local_network $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); } - # Check DNS only if gateway is set. - if ($gateway) + # Check DNS only if this is the default gateway interface. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + in_iface => $in_iface, + default_gateway_interface => $default_gateway_interface, + cleaned_current_dns => $cleaned_current_dns, + }}); + if ($in_iface eq $default_gateway_interface) { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + cleaned_current_dns => $cleaned_current_dns, + cleaned_dns => $cleaned_dns, + }}); if ($cleaned_dns ne $cleaned_current_dns) { #print "DNS: ... [".$cleaned_current_dns."] -> [".$cleaned_dns."]\n"; $change = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); } - elsif (($in_iface eq $default_gateway_interface) && (not $anvil->data->{network}{'local'}{interface}{$in_iface}{default_gateway})) - { - # This isn't the default gateway yet, but we'll make it so. - #print "Will set as default gateway\n"; - $change = 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); - } + } + elsif ($cleaned_current_dns) + { + # Remove the old DNS entries. + $change = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); } if (not $change) @@ -907,6 +753,15 @@ sub check_local_network elsif ($line =~ /^GATEWAY=".*"/) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }}); + if ($in_iface ne $default_gateway_interface) + { + # This interface shouldn't have DNS. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0111", variables => { + interface => $in_iface, + gateway_line => $line, + }}); + next; + } if (not $gateway_seen) { $gateway_seen = 1; @@ -918,13 +773,23 @@ sub check_local_network } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }}); } - elsif ($line =~ /^DNS=".*"/) + elsif ($line =~ /^DNS\d+=".*"/) { # The first time we see a DNS entry, we inject the DNS we've # got and then ignore the rest. $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dns_seen => $dns_seen }}); + if ($in_iface ne $default_gateway_interface) + { + # This interface shouldn't have DNS. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0110", variables => { + interface => $in_iface, + dns_line => $line, + }}); + next; + } if (not $dns_seen) { + # If there's no DNS, this will do nothing. my $i = 1; foreach my $this_dns (split/,/, $cleaned_dns) @@ -932,7 +797,6 @@ sub check_local_network $new_config .= "DNS".$i."=\"".$this_dns."\"\n"; $i++; } - $dns_seen = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 's1:dns_seen' => $dns_seen, @@ -1001,21 +865,24 @@ sub check_local_network } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); } - if (not $gateway_seen) + if ($in_iface eq $default_gateway_interface) { - $new_config .= "GATEWAY=\"".$gateway."\"\n"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); - } - if (not $dns_seen) - { - # If there's no DNS, this will do nothing. - my $i = 1; - foreach my $this_dns (split/,/, $cleaned_dns) + if (not $gateway_seen) { - $new_config .= "DNS".$i."=\"".$this_dns."\"\n"; - $i++; + $new_config .= "GATEWAY=\"".$gateway."\"\n"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); + } + if (not $dns_seen) + { + # If there's no DNS, this will do nothing. + my $i = 1; + foreach my $this_dns (split/,/, $cleaned_dns) + { + $new_config .= "DNS".$i."=\"".$this_dns."\"\n"; + $i++; + } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); } - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); } if (not $mtu_seen) { @@ -1031,11 +898,6 @@ sub check_local_network # Write out the new file. update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }}); -# print "File about to write: [".$filename."]\n"; -# print "============================\n"; -# print $new_config."\n"; -# print "============================\n"; -# die "There's a bug here that is re-writting the config with duplicate DNS and something the wrong IP for this host.\n"; $anvil->Storage->write_file({ debug => 3, file => $filename, @@ -1062,7 +924,7 @@ sub check_local_network # Tell nmcli to re-read the config files. $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0463"}); - my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -1071,10 +933,10 @@ sub check_local_network foreach my $interface_name (sort {$a cmp $b} @{$restart_interfaces}) { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $interface_name }}); - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down \"".$interface_name."\""}); + $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down \"".$interface_name."\""}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0464", variables => { interface => $interface_name }}); - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection up \"".$interface_name."\""}); + $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection up \"".$interface_name."\""}); } # Wait for a DB connection. We'll wait up to 130 seconds (updelay is 120 seconds, plus a small buffer). @@ -1109,8 +971,8 @@ sub check_local_network $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0085"}); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0085"); - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{virsh}." net-destroy default"}); - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{virsh}." net-undefine default "}); + $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{virsh}." net-destroy default"}); + $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{virsh}." net-undefine default "}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0034"}); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0034"); @@ -1153,7 +1015,7 @@ sub check_local_network }}); # Change the live MTU. - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu}); + $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu}); # Now update the config file. my $interface_uuid = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$in_iface}; @@ -1191,11 +1053,6 @@ sub check_local_network # Write out the new file. update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }}); -# print "File about to write: [".$filename."]\n"; -# print "============================\n"; -# print $new_config."\n"; -# print "============================\n"; -# die "There's a bug here that is re-writting the config with duplicate DNS and something the wrong IP for this host.\n"; $anvil->Storage->write_file({ debug => 2, file => $filename, @@ -1272,24 +1129,26 @@ sub check_local_network update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0091,!!daemon!".$daemon."!!"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0091", variables => { daemon => $daemon }}); $anvil->System->restart_daemon({ - debug => 2, + debug => 3, daemon => $daemon, }) } } - # Make sure the IPs of the dashboard(s) and our peers are in the hosts file. - + # Update the hosts file. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0112"}); + update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0112"); + $anvil->System->update_hosts({debug => 3}); - ### TODO: Do we really need passwordless SSH anymore? # Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0113"}); + update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0113"); $anvil->System->check_ssh_keys({debug => 3}); - # Update the hosts file. - $anvil->System->update_hosts({debug => 3}); - # Setup IPMI, if needed. - ### TODO: Do this when on real hardware + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0114"}); + update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0114"); + $anvil->System->configure_ipmi({debug => 3, manifest_uuid => $manifest_uuid}); return(0); } diff --git a/tools/anvil-update-states b/tools/anvil-update-states index 9ecc5a08..92ae5b67 100755 --- a/tools/anvil-update-states +++ b/tools/anvil-update-states @@ -21,6 +21,7 @@ my $anvil = Anvil::Tools->new(); $anvil->Log->level({set => 2}); $anvil->Log->secure({set => 0}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }}); +$anvil->Get->switches; # If there's no DB (or cached data isn't recorded to the database yet), this will store those records. $anvil->data->{cache}{new_file} = "# interface,timestamp,mac_address,speed,link_state,operational\n"; @@ -121,7 +122,7 @@ sub update_network my ($anvil) = @_; # Run 'ip addr' to see what IPs are in use. - $anvil->Network->get_ips({debug => 3}); + $anvil->Network->get_ips(); # We'll read through '/sys/class/net' looking for network interfaces. # * 'network::local::interface::::ip' - If an IP address is set @@ -457,7 +458,7 @@ sub update_network # recording interfaces. foreach my $processing ("bridge", "bond", "interface") { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { processing => $processing }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { processing => $processing }}); foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) { # Skip if this isn't the device type we're working on. @@ -492,7 +493,7 @@ sub update_network my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}; my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway}; my $dns = $anvil->data->{network}{'local'}{interface}{$interface}{dns}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { active_interface => $active_interface, bond_mode => $bond_mode, bond_master => $bond_master, diff --git a/tools/test.pl b/tools/test.pl index 5d6a39ec..a4bbd752 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -29,7 +29,4 @@ $anvil->Database->connect(); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"}); $anvil->Get->switches; -$anvil->System->configure_ipmi({ - debug => 2, - manifest_uuid => "6115d040-bdc4-4c76-9514-15870d88fb43", -}); +$anvil->System->check_ssh_keys({debug => 2});