diff --git a/Anvil/Tools.pm b/Anvil/Tools.pm index 879dcfbbc..bac33be90 100644 --- a/Anvil/Tools.pm +++ b/Anvil/Tools.pm @@ -925,6 +925,9 @@ sub _set_defaults timestamp => "", use_handle => "", }, + firewall => { + 'default-zone' => "IFN1", + }, host_type => "", host_uuid => "", language => "en_CA", @@ -1076,6 +1079,18 @@ sub _set_defaults }, }, }; + $anvil->data->{network} = { + ntp => { + servers => "", + manage => 1, + }, + wait_for_network => { + timeout => 300, + }, + wait_on_network => { + timeout => 180, + }, + }; return(0); } @@ -1097,6 +1112,7 @@ sub _set_paths 'anvil.debug' => "/etc/anvil/anvil.debug", 'anvil.version' => "/etc/anvil/anvil.version", 'autoindex.conf' => "/etc/httpd/conf.d/autoindex.conf", + 'chrony.conf' => "/etc/chrony.conf", 'cib.xml' => "/var/lib/pacemaker/cib/cib.xml", 'corosync.conf' => "/etc/corosync/corosync.conf", 'corosync-authkey' => "/etc/corosync/authkey", diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index d50363420..c065eca39 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -5256,6 +5256,8 @@ SELECT scan_lvm_pv_sector_size FROM scan_lvm_pvs +WHERE + scan_lvm_pv_name != 'DELETED' ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); @@ -5340,7 +5342,9 @@ SELECT scan_lvm_vg_size, scan_lvm_vg_free FROM - scan_lvm_vgs + scan_lvm_vgs +WHERE + scan_lvm_vg_name != 'DELETED' ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); @@ -5426,7 +5430,9 @@ SELECT scan_lvm_lv_path, scan_lvm_lv_on_pvs FROM - scan_lvm_lvs + scan_lvm_lvs +WHERE + scan_lvm_lv_name != 'DELETED' ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); @@ -5728,7 +5734,7 @@ And, to allow for lookup by name; If the hash was already populated, it is cleared before repopulating to ensure no stale data remains. -B<>: Deleted devices (ones where C<< manifest_note >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. +B<>: Deleted manifests (ones where C<< manifest_note >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them. Parameters; diff --git a/Anvil/Tools/Network.pm b/Anvil/Tools/Network.pm index a5f928c67..293d825ed 100644 --- a/Anvil/Tools/Network.pm +++ b/Anvil/Tools/Network.pm @@ -3870,7 +3870,7 @@ sub manage_firewall # Set defaults that the user can override in anvil.conf if (not exists $anvil->data->{sys}{firewall}{'default-zone'}) { - $anvil->data->{sys}{firewall}{'default-zone'} = ""; + $anvil->data->{sys}{firewall}{'default-zone'} = "IFN1"; } # What we do next depends on what we're doing. @@ -3898,6 +3898,32 @@ sub manage_firewall # Get a list of zones and the interfaces already in them. $anvil->Network->_get_existing_zone_interfaces({debug => $debug}); + # Change the default zone, if needed. + my $wanted_default_zone = $anvil->data->{sys}{firewall}{'default-zone'}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + wanted_default_zone => $wanted_default_zone, + "firewalld::default_zone" => $anvil->data->{firewalld}{default_zone}, + "exists firewall::zone::${wanted_default_zone}" => exists $anvil->data->{firewall}{zone}{$wanted_default_zone} ? 1 : 0, + }}); + if (($anvil->data->{firewalld}{default_zone} eq "public") && + (exists $anvil->data->{firewall}{zone}{$wanted_default_zone})) + { + # Change the default zone. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "warning_0021"}); + + my $shell_call = $anvil->data->{path}{exe}{'firewall-cmd'}." --set-default-zone=".$wanted_default_zone; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + output => $output, + return_code => $return_code, + }}); + + # Mark that we need to reload + $reload = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { reload => $reload }}); + } + # What zones do we need, and what zones do we have? foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$host_name}{interface}}) { @@ -4044,7 +4070,6 @@ sub manage_firewall # Do any interfaces need to be added to this zone? foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$host_name}{interface}}) { - next if not $anvil->data->{network}{$host_name}{interface}{$interface}{ip}; my $interface_zone = uc(($interface =~ /^(.*?)_/)[0]); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface, @@ -4183,6 +4208,10 @@ sub manage_firewall } } + # Check the default zone. If it's 'default', change it either to 'IFN1' or whatever zone the user specified in + $anvil->data->{sys}{firewall}{'current-default-zone'} = "" if not exists $anvil->data->{sys}{firewall}{'current-default-zone'}; + + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { reload => $reload }}); if ($reload) { @@ -5259,7 +5288,7 @@ sub _check_firewalld_conf file => $anvil->data->{path}{configs}{'firewalld.conf'}, force_read => 1, }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { old_firewalld_conf => $old_firewalld_conf }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { old_firewalld_conf => $old_firewalld_conf }}); ### NOTE: This is ignored in EL9+ # For now, the only thing we want to change is to disable 'AllowZoneDrifting' @@ -5268,7 +5297,7 @@ sub _check_firewalld_conf my $allowzonedrifting_seen = 0; foreach my $line (split/\n/, $old_firewalld_conf) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); if ($line =~ /^AllowZoneDrifting=(.*)$/) { my $old_value = $1; @@ -5286,6 +5315,14 @@ sub _check_firewalld_conf next; } } + if ($line =~ /^DefaultZone=(.*)$/) + { + $anvil->data->{firewalld}{default_zone} = $1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "firewalld::default_zone" => $anvil->data->{firewalld}{default_zone}, + }}); + } + $new_firewalld_conf .= $line."\n"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { new_firewalld_conf => $new_firewalld_conf }}); } @@ -6189,4 +6226,126 @@ sub _manage_striker_firewall return($changes); } +# Read in the current firewall config +sub _parse_firewall_config +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->_parse_firewall_config()" }}); + + # Show live or permanent rules? Permanent is default + my $permanent = defined $parameter->{permanent} ? $parameter->{permanent} : 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + permanent => $permanent, + }}); + + my $say_permanent = $permanent ? " --permanent" : ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { say_permanent => $say_permanent }}); + + + # What's the default zone? + my $shell_call = $anvil->data->{path}{exe}{'firewall-cmd'}.$say_permanent." --get-default-zone"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); + + ($anvil->data->{sys}{firewall}{'current-default-zone'}, my $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "sys::firewall::current-default-zone" => $anvil->data->{sys}{firewall}{'current-default-zone'}, + return_code => $return_code, + }}); + + # Now load the zone data. + $shell_call = $anvil->data->{path}{exe}{'firewall-cmd'}.$say_permanent." --list-all-zones"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); + + my $zone = ""; + my $active_state = ""; + my ($firewall_data, undef) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); + foreach my $line (split/\n/, $firewall_data) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + 's1:zone' => $zone, + 's2:line' => $line, + }}); + + if ($line =~ /^(\w.*)$/) + { + $zone = $1; + $active_state = "inactive"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { zone => $zone }}); + if ($line =~ /^(\w+) \((.*?)\)/) + { + $zone = $1; + $active_state = $2; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + zone => $zone, + active_state => $active_state, + }}); + } + + $anvil->data->{firewall}{zone}{$zone}{active} = $active_state; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "firewall::zone::${zone}::active" => $anvil->data->{firewall}{zone}{$zone}{active}, + }}); + } + elsif ($zone) + { + if ((not $line) or ($line =~ /^\s+$/)) + { + # Done reading this zone, record. + my $interfaces = defined $anvil->data->{firewall}{zone}{$zone}{variable}{interfaces} ? $anvil->data->{firewall}{zone}{$zone}{variable}{interfaces} : ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + zone => $zone, + interfaces => $interfaces, + }}); + foreach my $interface (split/ /, $interfaces) + { + $anvil->data->{firewall}{interface}{$interface}{zone} = $zone; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "firewall::interface::${interface}::zone" => $anvil->data->{firewall}{interface}{$interface}{zone}, + }}); + } + + $zone = ""; + $active_state = ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + zone => $zone, + active_state => $active_state, + }}); + } + elsif (($active_state) && ($line =~ /(\S.*?):(.*)$/)) + { + my $variable = $1; + my $value = $2; + $variable =~ s/^\s+//; + $variable =~ s/\s+$//; + $value =~ s/^\s+//; + $value =~ s/\s+$//; + $anvil->data->{firewall}{zone}{$zone}{variable}{$variable} = $value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "s1:line" => $line, + "s2:firewall::zone::${zone}::variable::${variable}" => $anvil->data->{firewall}{zone}{$zone}{variable}{$variable}, + }}); + } + } + } + + foreach my $zone (sort {$a cmp $b} keys %{$anvil->data->{firewall}{zone}}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + 's1:zone' => $zone, + 's2:active' => $anvil->data->{firewall}{zone}{$zone}{active}, + }}); + foreach my $variable (sort {$a cmp $b} keys %{$anvil->data->{firewall}{zone}{$zone}{variable}}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + $variable => $anvil->data->{firewall}{zone}{$zone}{variable}{$variable}, + }}); + } + } + + return(0); +} + 1; diff --git a/Anvil/Tools/Server.pm b/Anvil/Tools/Server.pm index 269037b98..268a59264 100644 --- a/Anvil/Tools/Server.pm +++ b/Anvil/Tools/Server.pm @@ -1554,14 +1554,25 @@ sub locate my $host_uuid = $anvil->data->{sys}{hosts}{by_name}{$host_name}; my $host_type = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_type}; my $short_host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{short_host_name}; + my $host_status = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_status}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 's1:host_name' => $host_name, 's2:host_uuid' => $host_uuid, 's3:host_type' => $host_type, 's4:short_host_name' => $short_host_name, + 's5:host_status' => $host_status, }}); next if $host_type eq "striker"; + if (($host_status eq "powered off") or + ($host_status eq "rebooting") or + ($host_status eq "stopping") or + ($host_status eq "booting")) + { + # Connections would likely timeout, so skip. + next; + } + if ($anvil_uuid) { # Skip if this isn't a host we're searching. @@ -2869,7 +2880,7 @@ sub shutdown_virsh { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0425", variables => { server => $server }}); } - if ($status eq "shut off") + if (($status eq "shut off") or ($status eq "")) { # Already off. $success = 1; diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index f30d082ce..4b3fe3235 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -1591,6 +1591,261 @@ sub check_network_type } +=head2 check_ntp + +This checks to see if the NTP needs to be updated. If the NTP congig is updated, C<< 1 >> is returned. Otherwise, C<< 0 >> is returned. + +This method looks for the NTP server(s) to use in this order; +* Install Manifest (if a subnode) +* variables -> variable_name = network::ntp::servers +* /etc/anvil/anvil.con -> network::ntp::servers = X + +If multiple are set, the last one is ues. Values are NOT merged. + +This method takes no parameters. + +=cut +sub check_ntp +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_ntp()" }}); + + # If management is disabled, just return. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "network::ntp::manage" => $anvil->data->{network}{ntp}{manage}, + }}); + if (not $anvil->data->{network}{ntp}{manage}) + { + return(0); + } + + my $updated = 0; + my $ntp = ""; + + if (not exists $anvil->data->{hosts}{host_uuid}) + { + $anvil->Database->get_hosts({debug => $debug}); + } + my $host_uuid = $anvil->Get->host_uuid(); + my $host_type = $anvil->Get->host_type(); + my $anvil_uuid = $anvil->data->{hosts}{host_uuid}{$host_uuid}{anvil_uuid}; + my $anvil_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{anvil_name}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + host_uuid => $host_uuid, + host_type => $host_type, + anvil_uuid => $anvil_uuid, + anvil_name => $anvil_name, + }}); + + if ($anvil_name) + { + # Look for the NTP in the manifest. + $anvil->Database->get_manifests({debug => $debug}); + if (exists $anvil->data->{manifests}{manifest_name}{$anvil_name}) + { + # NOTE: Deleted manifests aren't returned so we don't need to check if this + # is deleted. + my $manifest_uuid = $anvil->data->{manifests}{manifest_name}{$anvil_name}{manifest_uuid}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_uuid => $manifest_uuid }}); + + $anvil->Striker->load_manifest({ + debug => $debug, + manifest_uuid => $manifest_uuid, + }); + + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "manifests::manifest_uuid::${manifest_uuid}::parsed::networks::ntp" => $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp}, + }}); + if ($anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp}) + { + $ntp = $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ntp => $ntp }}); + } + } + } + + # If there's a database variable for this host, use it over the manifest value. + my $query = " +SELECT + variable_value +FROM + variables +WHERE + variable_name = 'network::ntp::servers' +AND + variable_source_table = 'hosts' +AND + variable_source_uuid = ".$anvil->Database->quote($host_uuid)." +;"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, 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 => $debug, list => { + results => $results, + count => $count, + }}); + if ($count) + { + my $variable_value = $results->[0]->[0]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_value => $variable_value }}); + + if ($variable_value) + { + $ntp = $variable_value; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ntp => $ntp }}); + } + } + + # Whether we loaded an NTP from the manifest or database, override if set in anvil.conf. + $anvil->data->{network}{ntp}{servers} = "" if not defined $anvil->data->{network}{ntp}{servers}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "network::ntp::servers" => $anvil->data->{network}{ntp}{servers}, + }}); + if ($anvil->data->{network}{ntp}{servers}) + { + $ntp = $anvil->data->{network}{ntp}{servers}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ntp => $ntp }}); + } + + if (not $ntp) + { + # Nothing to do + return($updated); + } + + # If the chrony.conf file doesn't exist for some reason, skip. + if ((not $anvil->data->{path}{configs}{'chrony.conf'}) or (not -f $anvil->data->{path}{configs}{'chrony.conf'})) + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0346", variables => { file => $anvil->data->{path}{configs}{'chrony.conf'} }}); + return($updated); + } + + # Read in the NTP config file + my $new_body = ""; + my $old_body = $anvil->Storage->read_file({ + debug => $debug, + file => $anvil->data->{path}{configs}{'chrony.conf'}, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { old_body => $old_body }}); + + # Loop through the file and update. + delete $anvil->data->{ntp}{seen} if exists $anvil->data->{ntp}{seen}; + foreach my $line (split/\n/, $old_body) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }}); + if ($line =~ /^pool (.*)$/) + { + my $pool = $1; + $pool =~ s/\s.*//; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { pool => $pool }}); + + # Is this a server or pool we want? + my $seen = 0; + foreach my $ntp_server (split/,/, $ntp) + { + next if $seen; + $ntp_server = $anvil->Words->clean_spaces({string => $ntp_server}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ntp_server => $ntp_server }}); + + if ($pool eq $ntp_server) + { + # Yup, we want this one. + $seen = 1; + $anvil->data->{ntp}{seen}{$pool} = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + seen => $seen, + "ntp::seen::${pool}" => $anvil->data->{ntp}{seen}{$pool}, + }}); + } + } + + if (not $seen) + { + # Comment out this pool + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0345", variables => { ntp => $pool }}); + $line = "# ".$line; + next; + } + } + if ($line =~ /^Server (.*)$/) + { + my $server = $1; + $server =~ s/\s.*//; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { server => $server }}); + + # Is this a server we want? + my $seen = 0; + foreach my $ntp_server (split/,/, $ntp) + { + next if $seen; + $ntp_server = $anvil->Words->clean_spaces({string => $ntp_server}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ntp_server => $ntp_server }}); + + if ($server eq $ntp_server) + { + # Yup, we want this one. + $seen = 1; + $anvil->data->{ntp}{seen}{$server} = 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + seen => $seen, + "ntp::seen::${server}" => $anvil->data->{ntp}{seen}{$server}, + }}); + } + } + + if (not $seen) + { + # Comment this server out + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0345", variables => { ntp => $server }}); + $line = "# ".$line; + next; + } + } + $new_body .= $line."\n"; + } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { new_body => $new_body }}); + + # Are there servers not yet added? + foreach my $ntp_server (split/,/, $ntp) + { + $ntp_server = $anvil->Words->clean_spaces({string => $ntp_server}); + next if not $ntp_server; + if ((exists $anvil->data->{ntp}{seen}{$ntp_server}) && ($anvil->data->{ntp}{seen}{$ntp_server})) + { + next; + } + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0343", variables => { ntp => $ntp_server }}); + $new_body .= "pool ".$ntp_server." iburst\n"; + } + + my $difference = diff \$old_body, \$new_body, { STYLE => 'Unified' }; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { difference => $difference }}); + + if ($difference) + { + # Write out the new config. + $anvil->Storage->write_file({ + debug => $debug, + body => $new_body, + file => $anvil->data->{path}{configs}{'chrony.conf'}, + backup => 1, + overwrite => 1, + }); + + # Restart chronyd + $anvil->System->restart_daemon({ + debug => $debug, + daemon => "chronyd.service", + }); + } + + return($updated); +} + + =head2 check_storage Thic gathers LVM data from the local system. @@ -3926,134 +4181,6 @@ sub maintenance_mode return($maintenance_mode); } -### TODO: Move and document. -### NOTE: This only works if the firewall is enabled. -sub check_firewall -{ - my $self = shift; - my $parameter = shift; - my $anvil = $self->parent; - my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_firewall()" }}); - - # Show live or permanent rules? Permanent is default - my $permanent = defined $parameter->{permanent} ? $parameter->{permanent} : 1; - my $start = defined $parameter->{start} ? $parameter->{start} : 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { permanent => $permanent }}); - - # Read in /etc/firewalld/firewalld.conf and parse the 'DefaultZone' variable. - my $firewall_conf = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'firewalld.conf'}}); - foreach my $line (split/\n/, $firewall_conf) - { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }}); - if ($line =~ /^DefaultZone=(.*?)$/) - { - $anvil->data->{firewall}{default_zone} = $1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "firewall::default_zone" => $anvil->data->{firewall}{default_zone} }}); - last; - } - } - $anvil->data->{firewall}{default_zone} = "" if not defined $anvil->data->{firewall}{default_zone}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "firewall::default_zone" => $anvil->data->{firewall}{default_zone} }}); - - ### NOTE: 'iptables-save' doesn't seem to show the loaded firewall in RHEL8. Slower or not, we seem - ### to have to use 'firewall-cmd' - my $shell_call = $anvil->data->{path}{exe}{'firewall-cmd'}." --permanent --list-all-zones"; - if (not $permanent) - { - $shell_call = $anvil->data->{path}{exe}{'firewall-cmd'}." --list-all-zones"; - } - - my $zone = ""; - my $active_state = ""; - my ($firewall_data, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call}); - foreach my $line (split/\n/, $firewall_data) - { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - 's1:zone' => $zone, - 's2:line' => $line, - }}); - - if ($line =~ /^(\w.*)$/) - { - $zone = $1; - $active_state = ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { zone => $zone }}); - if ($line =~ /^(\w+) \((.*?)\)/) - { - $zone = $1; - $active_state = $2; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - zone => $zone, - active_state => $active_state - }}); - } - $anvil->data->{firewall}{zone}{$zone}{file} = ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "firewall::zone::${zone}::file" => $anvil->data->{firewall}{zone}{$zone}{file} }}); - } - elsif ($zone) - { - if ((not $line) or ($line =~ /^\s+$/)) - { - # Done reading this zone, record. - my $interfaces = defined $anvil->data->{firewall}{zone}{$zone}{variable}{interfaces} ? $anvil->data->{firewall}{zone}{$zone}{variable}{interfaces} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - zone => $zone, - interfaces => $interfaces, - }}); - foreach my $interface (split/ /, $interfaces) - { - $anvil->data->{firewall}{interface}{$interface}{zone} = $zone; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "firewall::interface::${interface}::zone" => $anvil->data->{firewall}{interface}{$interface}{zone}, - }}); - } - - $zone = ""; - $active_state = ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - zone => $zone, - active_state => $active_state, - }}); - } - elsif (($active_state) && ($line =~ /(\S.*?):(.*)$/)) - { - my $variable = $1; - my $value = $2; - $variable =~ s/^\s+//; - $variable =~ s/\s+$//; - $value =~ s/^\s+//; - $value =~ s/\s+$//; - $anvil->data->{firewall}{zone}{$zone}{variable}{$variable} = $value; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "s1:line" => $line, - "s2:firewall::zone::${zone}::variable::${variable}" => $anvil->data->{firewall}{zone}{$zone}{variable}{$variable}, - }}); - } - } - } - - # Make sure, for each zone, we've got a zone file. We should, so we'll read it in. - foreach my $zone (sort {$a cmp $b} keys %{$anvil->data->{firewall}{zone}}) - { - $anvil->data->{firewall}{zone}{$zone}{file} = $anvil->data->{path}{directories}{firewalld_zones}."/".$zone.".xml"; - $anvil->data->{firewall}{zone}{$zone}{file} =~ s/\/\//\//g; - $anvil->data->{firewall}{zone}{$zone}{body} = ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "firewall::zone::${zone}::file" => $anvil->data->{firewall}{zone}{$zone}{file}, - }}); - if (-e $anvil->data->{firewall}{zone}{$zone}{file}) - { - $anvil->data->{firewall}{zone}{$zone}{body} = $anvil->Storage->read_file({file => $anvil->data->{firewall}{zone}{$zone}{file}}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "firewall::zone::${zone}::body" => $anvil->data->{firewall}{zone}{$zone}{body}, - }}); - } - } - - return(0); -} - =head2 manage_authorized_keys This takes a host's UUID and will adds or removes their ssh public key to the target host user (or users). On success, C<< 0 >> is returned. Otherwise, C<< 1 >> is returned. @@ -5810,6 +5937,34 @@ sub wait_on_dnf ############################################################################################################# +=head2 _abort_if_ci + +If the c<< --ci-test >> switch is used, this method will close any running job and exit. It's meant to be used before a user prompt, preventing tests from hanging. + +=cut +sub _abort_if_ci +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->_abort_if_ci" }}); + + if ($anvil->data->{switches}{'ci-test'}) + { + $anvil->Job->update_progress({ + progress => 100, + message => "error_0216", + log_level => 1, + 'print' => 1, + priority => "err", + }); + $anvil->nice_exit({exit_code => 0}); + } + + return(0); +} + =head2 _check_anvil_conf This looks for anvil.conf and, if it's missing, regenerates it. diff --git a/anvil.conf b/anvil.conf index e0b4b823c..b07c8a3f4 100644 --- a/anvil.conf +++ b/anvil.conf @@ -1,4 +1,4 @@ -### This is the main Anvil! configuration file. + ### This is the main Anvil! configuration file. # To help understand how the Anvil! is used, some features will "call home" to record anonymous information # about a machine participating in an Anvil! system. An example is DRBD's 'usage-count' option. If you wish @@ -179,6 +179,11 @@ install-manifest::refresh-period = 86400 # Setting this to '0' will disable auto-management of the firewall. #sys::manage::firewall = 1 +# By default, 'IFN1' is set as the default zone. If you'd like to override this, set it here. This must match +# one of the zones shown in 'firewall-cmd --get-active-zones'. If the value here doesn't match, it will be +# ignored. +#sys::firewall::default-zone = IFN1 + # By default, the Anvil! will detect and configure the IPMI BMC (iDRAC, iLO, RSA, etc). To disable this, set # this to '0'. Note that if you do this, you will need to ensure that IPMI-based fencing is configured # properly! @@ -230,3 +235,12 @@ install-manifest::refresh-period = 86400 # default, Network->wait_for_network waits for five minutes. During the initial config, we keep this shorter. # This value will be updated by anvil-configure-host when the initial configuration completes. network::wait_for_network::timeout = 300 + +# If you want to specify one or more NTP servers, you can specify them here. To specify multiple servers, +# separate them with commas. IPs and host names can be used. +# NOTE: This overrides the value set in an Install Manifest and the database's variables -> +# variable_name = 'network::cgi'! +#network::ntp::servers = tick.redhat.com,10.255.6.1 + +# To disable Anvil! management of NTP entirely, set this to '0'. +#network::ntp::manage = 0 diff --git a/man/anvil-manage-server-storage.8 b/man/anvil-manage-server-storage.8 index 7cae34dab..3da0f6a31 100644 --- a/man/anvil-manage-server-storage.8 +++ b/man/anvil-manage-server-storage.8 @@ -32,6 +32,9 @@ Also, base2 vs base10 notation! Ie: '1GiB' = 1,073,741,824 bytes', '1GB' = '1,00 \fB\-\-anvil\fR This is the Anvil! node name or UUID to be used. If not specified, the Anvil! the command or job runs on will be used. .TP +\fB\-\-ci\-test\fR +This is used by CI/CD tests, and not meant for normal use. This disables all prompts can causes the program to exit out / close a job as failed if it would otherwise have prompted for input. Note that this sets \fB\-\-confirm\fR. +.TP \fB\-\-confirm\fR Using this prevents the prompts to confirm given actions. When using \fB\-\-job\-uuid\fR, this is ignored as all commands are considered confirmed. .TP diff --git a/scancore-agents/scan-apc-ups/scan-apc-ups b/scancore-agents/scan-apc-ups/scan-apc-ups index 2ace200ed..947aacc2e 100755 --- a/scancore-agents/scan-apc-ups/scan-apc-ups +++ b/scancore-agents/scan-apc-ups/scan-apc-ups @@ -3043,8 +3043,10 @@ FROM upses WHERE ups_agent = ".$anvil->Database->quote($THIS_FILE)." +AND + ups_ip_address != 'DELETED' ORDER BY - ups_name ASC + ups_name ASC ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); diff --git a/share/words.xml b/share/words.xml index 2eb4809c6..545c6c92f 100644 --- a/share/words.xml +++ b/share/words.xml @@ -136,7 +136,7 @@ Failed to generate an RSA public key for the user: [#!variable!user!#]. The outp Unable to connect to the database, unable to read the details of the key to remove. Asked to plug in an interface from: [#!variable!server!#] but there was a problem parsing the definition file. More details are likely in the logs. Job data not found for job_uuid: [#!variable!job_uuid!#]. - #!free!# + [ Warning ] - The server: [#!variable!server!#] does not appear to exist on the cluster, aborting. The job_uuid: [#!variable!job_uuid!#] appears valid, but there was no job_data. The state UUID: [#!variable!state_uuid!#] does not appear to be a valid UUID. No (good) state UUIDs found, unable to run this job. @@ -324,13 +324,13 @@ Output (if any): ==== #!variable!shell_call!# ==== - The call to create the new server appears to have failed. It hasn't shown up as running after 10 seconds. The status, if any, was last seen as: [#!variable!status!#]. + The call to create the new server appears to have failed. It hasn't shown up as running after: [#!variable!timeout!#] seconds. The status, if any, was last seen as: [#!variable!status!#]. Failed to add the server: [#!variable!server_name!#] because we failed to parse the CIB. Is the cluster running? Failed to add the server: [#!variable!server_name!#] because we are not a full cluster member? Failed to add the server: [#!variable!server_name!#] because it appears to already exist in the cluster. Failed to add the server: [#!variable!server_name!#]. After the commands to add it ran, it was still not found in the cluster. It looks like something went wrong while adding the server to the cluster. There should be more information in the logs. - #!free!# + User input needed, but --ci-test used, aborting. This host is not an Anvil! node or DR host, unable to delete servers. Unable to connect to any databases, unable to continue. Unable to find the server uuid to delete from the job UUID: [#!variable!job_uuid!#]. @@ -792,7 +792,8 @@ The XML that failed sanity check was: [ Error ] - The requested size: [#!variable!requested_ram!#] is greater than the maximum RAM: [#!variable!max_ram!#]. [ Error ] - The requested size: [#!variable!requested_ram!#] is less than 640 KiB, this must be a mistake. [ Error ] - The requested CPU: [#!variable!requested_cpu!#] is not valid. Valid options are '--cpu X', '--cpu Y,X' or '--cpu 'Y,X,Z' where 'X' is the number of cores per socket, 'Y' is the number of sockets and 'Z' is the number of threads per core. - [ Error ] - The requested number of cores: [#!variable!requested_cores!#] (sockets: [#!variable!new_sockets!#], cores per socket: [#!variable!new_cores!#], threads per core: [#!variable!new_threads!#]). + [ Error ] - The requested number of cores: [#!variable!requested_cores!#] (sockets: [#!variable!new_sockets!#], cores per socket: [#!variable!new_cores!#], threads per core: [#!variable!new_threads!#]) is invalid! +[ Error ] - The maximum cores that can be allocated to this server is: [#!variable!max_cores!#] (Real cores - #!variable!recommended_max!#). [ Error ] - This program must be run on a subnode. [ Error ] - This subnode is not in the cluster (failed to parse the CIB). Exiting. [ Error ] - The wanted interface: [#!variable!interface_name!#] which should have the MAC address: [#!variable!mac_address!#] was not found in Network Manager. Unable to proceed. @@ -2261,13 +2262,19 @@ Will now try with: [#!variable!count!#] known password(s). [ Warning ] - Not all hosts are online, but '--force' was used! [ Warning ] - You will need to manually update the passwords using this tool with '--local' later. Updating the VNC user: [#!variable!vncuser!#] password. - #!free!# + Adding the NTP server: [#!variable!ntp!#] as a time source for this machine. The server: [#!variable!server!#] wasn't found on this machine. - #!free!# - #!free!# + Removing the NTP server: [#!variable!ntp!#]. + The NTP crony.conf file: [#!variable!file!#] wasn't found, skipping NTP config. The migration of the server: [#!variable!server!#] to here was successful! It looks like we were called to verify that the: [#!variable!server!#] migrated here, but it isn't here yet. We'll proceed with an attempt to pull the server over. - #!free!# + The server is not running here, would you like to assign the job to: [#!variable!host!#]? +Job Details; +* job_data: ...... [#!variable!job_data!#] +* job_name: ...... [#!variable!job_name!#] +* job_title: ..... [#!variable!job_title!#] +* job_description: [#!variable!job_description!#] +[ Warning ] - Confirmation of action will be assumed if you answer Yes! Temporarily enabling dual primary for the resource: [#!variable!resource!#] to the node: [#!variable!target_name!# (#!variable!target_node_id!#)]. #!free!# #!free!# @@ -2998,7 +3005,7 @@ About to try to download approximately: [#!variable!packages!#] packages needed [ Note ] - Asked to unplug an interface from: [#!variable!server!#] but the server is not running here. It's running on: [#!variable!host_name!#] (#!variable!host_uuid!#). Creating a job for that host to unplug the interface. [ Note ] - Asked to plug in an interface from: [#!variable!server!#] but the server is not running here. It's running on: [#!variable!host_name!#] (#!variable!host_uuid!#). Creating a job for that host to plug in the interface. The target: [#!variable!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!#]. - #!free!# + The '--confirm' switch was used, proceeding. #!free!# #!free!# Local repository @@ -3559,7 +3566,7 @@ proceeding. When set to '1', the server will not start automatically when a (sub)node boots, or when 'anvil-boot-server --server all' is used. - #!free!# + If you want to specify an NTP server (or servers) to use, specify them here. Note that any existing NTP servers will be removed. Multiple servers (IPs or host names) can be specified as a comma-separated list. #!free!# This is the name of the company, organization or division that owns or maintains this #!string!brand_0006!#. This is a descriptive field and you can enter whatever makes most sense to you. #!free!# @@ -4078,12 +4085,12 @@ The duplicate will be removed. ==== [ Warning ] - Updating passwords on all systems, please do NOT interrupt this process! - #!free!# - #!free!# - #!free!# + [ Warning ] - The server: [#!variable!server!#] is marked as deleted, aborting. + [ Warning ] - The server: [#!variable!server!#] is not shown to be running on any host in the cluster, aborting. + [ Warning ] - The server: [#!variable!server!#] is shown as already being off, aborting. [ Warning ] - The passed in parameter '#!variable!parameter!#': [#!variable!ip_address!#] is not a valid IPv4 address. [ Warning ] - The passed in parameter '#!variable!parameter!#': [#!variable!subnet_mask!#] is not a valid IPv4 subnet mask. - #!free!# + [ Warning ] - Changing the default zone to IFN1. #!free!# #!free!# #!free!# diff --git a/tools/anvil-configure-host b/tools/anvil-configure-host index 6c66a6e4a..9383b4b4b 100755 --- a/tools/anvil-configure-host +++ b/tools/anvil-configure-host @@ -115,11 +115,10 @@ $anvil->Database->insert_or_update_variables({ }); update_passwords($anvil); -$anvil->Job->update_progress({ - progress => 100, - message => "", - job_uuid => $anvil->data->{job}{uuid}, -}); + +# Update NTP, if needed. +my $ntp_updated = $anvil->System->check_ntp({debug => 2}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ntp_updated => $ntp_updated }}); # Make sure that we set the network->wait_on_network() timeout back to 180. $anvil->Storage->update_config({ @@ -132,6 +131,13 @@ $anvil->Storage->update_config({ $anvil->System->maintenance_mode({set => 0}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0467"}); +# We're done +$anvil->Job->update_progress({ + progress => 100, + message => "", + job_uuid => $anvil->data->{job}{uuid}, +}); + $anvil->nice_exit({exit_code => 0}); diff --git a/tools/anvil-daemon b/tools/anvil-daemon index fbbbab63d..25279be2b 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -640,6 +640,10 @@ sub handle_periodic_tasks } } + # Check if the NTP servers need to be updated. + my $ntp_updated = $anvil->System->check_ntp({debug => 2}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ntp_updated => $ntp_updated }}); + # Reap old db_in_use states over 6 hours old. my $query = "DELETE FROM states WHERE state_name LIKE 'db_in_use%' AND modified_date < (SELECT now() - interval '6 hour');\n"; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0124", variables => { query => $query }}); diff --git a/tools/anvil-join-anvil b/tools/anvil-join-anvil index 61889c8b7..e45dac0f3 100755 --- a/tools/anvil-join-anvil +++ b/tools/anvil-join-anvil @@ -112,6 +112,10 @@ if (1) $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0094", variables => { daemon => "anvil-safe-start.service" }}); } +# Update NTP, if needed. +my $ntp_updated = $anvil->System->check_ntp({debug => 2}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ntp_updated => $ntp_updated }}); + update_progress($anvil, 100, "job_0129"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0129"}); @@ -3858,65 +3862,8 @@ sub check_local_network # Break up the NTP servers into a list, we'll set to '1' the ones we find. update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0089"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0089"}); - my $new_ntp = {}; - foreach my $ntp_server (split/,/, $ntp) - { - $ntp_server = $anvil->Words->clean_spaces({ string => $ntp_server }); - $new_ntp->{$ntp_server} = 0; - } - - # Call chrony to see what servers are setup already. - my $change = 0; - my $new_config = ""; - my $old_config = $anvil->Storage->read_file({file => $anvil->data->{path}{data}{'chrony.conf'}}); - foreach my $line (split/\n/, $old_config) - { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); - $new_config .= $line."\n"; - if ($line =~ /^Server (.*)$/) - { - # This is a source. - my $source = $1; - $new_ntp->{$source} = 1; - } - } - - # Are any sources not enabled? - foreach my $source (sort {$a cmp $b} keys %{$new_ntp}) - { - if (not $new_ntp->{$source}) - { - update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0090,!!server!".$source."!!"); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0090", variables => { server => $source }}); - $change = 1; - $new_config .= "Server ".$source."\n"; - } - } - - if ($change) - { - # Write out the updated file. - update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0055,!!file!".$anvil->data->{path}{data}{'chrony.conf'}."!!"); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0055", variables => { file => $anvil->data->{path}{data}{'chrony.conf'} }}); - $anvil->Storage->write_file({ - debug => 2, - file => $anvil->data->{path}{data}{'chrony.conf'}, - body => $new_config, - user => "root", - group => "root", - mode => "0644", - overwrite => 1, - }); - - # Restart the daemon. - my $daemon = "chronyd"; - update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0091,!!daemon!".$daemon."!!"); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0091", variables => { daemon => $daemon }}); - $anvil->System->restart_daemon({ - debug => 3, - daemon => $daemon, - }) - } + my $updated = $anvil->System->check_ntp({debug => 2}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { updated => $updated }}); } # Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts diff --git a/tools/anvil-manage-host b/tools/anvil-manage-host index 252c51227..e040343d7 100755 --- a/tools/anvil-manage-host +++ b/tools/anvil-manage-host @@ -88,7 +88,7 @@ sub auto_grow_pv if ($anvil->data->{switches}{confirm}) { # Already confirmed. - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0359"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0150"}); } else { diff --git a/tools/anvil-manage-server-storage b/tools/anvil-manage-server-storage index 97ee736ba..155a933a1 100755 --- a/tools/anvil-manage-server-storage +++ b/tools/anvil-manage-server-storage @@ -42,6 +42,7 @@ my $anvil = Anvil::Tools->new(); $anvil->Get->switches({list => [ "add", "anvil", + "ci-test", "confirm", "disk", "eject", @@ -74,6 +75,14 @@ if ($anvil->data->{switches}{'job-uuid'}) load_job($anvil); } +if ($anvil->data->{switches}{'ci-test'}) +{ + $anvil->data->{switches}{confirm} = "#!SET!#"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "switches::confirm" => $anvil->data->{switches}{confirm}, + }}); +} + $anvil->Database->get_hosts(); $anvil->Database->get_anvils(); $anvil->Database->get_servers(); @@ -93,16 +102,13 @@ if (not $anvil->data->{switches}{server}) { # Show the list of servers. show_server_list($anvil); - if (not $anvil->data->{switches}{machine}) - { - $anvil->Job->update_progress({ - progress => 100, - message => "error_0456", - log_level => 1, - 'print' => 1, - priority => "err", - }); - } + $anvil->Job->update_progress({ + progress => 100, + message => "error_0456", + log_level => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, + priority => "err", + }); $anvil->nice_exit({exit_code => 0}); } @@ -133,7 +139,7 @@ if (exists $anvil->data->{connected_resource}) progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0092", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $peer_name, }, @@ -266,7 +272,7 @@ sub manage_disk progress => 100, message => "error_0457", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -291,7 +297,7 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0427", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); foreach my $short_host_name (sort {$a cmp $b} keys %{$anvil->data->{peer}}) @@ -302,7 +308,7 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0428", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { host_name => $short_host_name, @@ -335,6 +341,7 @@ sub manage_disk foreach my $volume_number (sort {$a cmp $b} keys %{$anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}}) { + next if not defined $volume_number or $volume_number eq ""; my $device_path = $anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{device_path}; next if $device_path eq "DELETED"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -408,7 +415,7 @@ sub manage_disk progress => 100, message => "error_0458", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -421,7 +428,7 @@ sub manage_disk progress => 100, message => "error_0459", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { device_target => $device_target, @@ -474,7 +481,7 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 10}), message => "log_0749", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { device_target => $device_target, say_boot => $say_boot, @@ -504,12 +511,16 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0113", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_name => $server_name, server_state => $server_state, }, }); + + # If this is a CI test, abort. + $anvil->System->_abort_if_ci(); + my $is_off = 0; my $update_period = 120; my $next_update = time + $update_period; @@ -533,7 +544,7 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 3}), message => "log_0114", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_name => $server_name, }, @@ -551,7 +562,7 @@ sub manage_disk progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0121", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { timestamp => $anvil->Get->date_and_time({time_only => 1}), server_name => $server_name, @@ -617,7 +628,7 @@ sub manage_disk_add progress => 100, message => "warning_0168", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "alert", }); show_storage_groups($anvil); @@ -659,7 +670,7 @@ sub manage_disk_add progress => 100, message => "error_0437", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { storage_group => $storage_group_switch @@ -688,7 +699,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0423", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { free_space => $anvil->Convert->bytes_to_human_readable({'bytes' => $free_space}), @@ -698,7 +709,7 @@ sub manage_disk_add progress => 100, message => "message_0330", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -722,7 +733,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0424", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { add_size => $add_size @@ -732,7 +743,7 @@ sub manage_disk_add progress => 100, message => "message_0330", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -801,7 +812,7 @@ sub manage_disk_add progress => 100, message => "error_0425", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -842,7 +853,7 @@ sub manage_disk_add progress => 100, message => "error_0426", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -854,7 +865,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "message_0333", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { new_device_target => $new_device_target, hr_size => $hr_size, @@ -868,6 +879,7 @@ sub manage_disk_add }); if ((not $anvil->data->{switches}{confirm}) && (not $anvil->data->{switches}{'job-uuid'})) { + $anvil->System->_abort_if_ci(); print $anvil->Words->string({key => "message_0021"})." "; my $answer = ; chomp($answer); @@ -888,7 +900,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0429", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); foreach my $short_host_name (sort {$a cmp $b} keys %{$anvil->data->{peer}}) @@ -899,7 +911,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 1}), message => "error_0428", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { host_name => $short_host_name, @@ -911,7 +923,7 @@ sub manage_disk_add progress => 100, message => "job_0471", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -977,7 +989,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0748", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { backing_disk => $backing_disk }, @@ -993,7 +1005,7 @@ sub manage_disk_add progress => 100, message => "error_0460", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { backing_disk => $backing_disk, @@ -1011,7 +1023,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -1023,7 +1035,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0756", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, backing_disk => $backing_disk, @@ -1046,7 +1058,7 @@ sub manage_disk_add progress => 100, message => "error_0461", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { host_name => $short_host_name, @@ -1066,7 +1078,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -1167,7 +1179,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0751", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $shell_call = $anvil->data->{path}{exe}{drbdadm}." --config-to-test ".$test_file." --config-to-exclude ".$drbd_res_file." sh-nop"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); @@ -1183,7 +1195,7 @@ sub manage_disk_add progress => 100, message => "error_0430", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { test_file => $test_file, @@ -1198,7 +1210,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0752", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); # Remove the test file. @@ -1210,7 +1222,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0757", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my ($backup_file) = $anvil->Storage->backup({file => $drbd_res_file}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { backup_file => $backup_file }}); @@ -1233,7 +1245,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0753", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); foreach my $host_type ("node", "dr") { @@ -1261,7 +1273,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0754", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { resource_file => $drbd_res_file, host_name => $short_host_name, @@ -1288,7 +1300,7 @@ sub manage_disk_add progress => 100, message => "error_0431", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -1300,7 +1312,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0755", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); foreach my $host_type ("node", "dr") { @@ -1331,7 +1343,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0758", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { next_drbd_volume => $next_drbd_volume }, @@ -1352,7 +1364,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "warning_0160", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "alert", variables => { drbd_resource => $drbd_resource, @@ -1370,7 +1382,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -1383,7 +1395,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0759", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, drbd_resource => $drbd_resource, @@ -1407,7 +1419,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "warning_0161", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "alert", variables => { host_name => $short_host_name, @@ -1427,7 +1439,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -1477,7 +1489,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0760", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, job_uuid => $job_uuid, @@ -1491,7 +1503,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0761", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { drbd_resource => $drbd_resource }, @@ -1513,7 +1525,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "job_0110", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $peer_count = 0; my $scan_drbd_call = $anvil->data->{path}{directories}{'scan_agents'}."/scan-drbd".$anvil->Log->switches; @@ -1543,7 +1555,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "job_0111", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, use_ip => $use_ip, @@ -1567,7 +1579,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0762", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $waiting = 1; my $wait_until = time + 300; @@ -1682,7 +1694,7 @@ sub manage_disk_add progress => 100, message => "error_0432", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -1696,7 +1708,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0763", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $all_inconsistent = 1; my $primary_on_host = ""; @@ -1728,7 +1740,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0764", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $shell_call = $anvil->data->{path}{exe}{drbdadm}." new-current-uuid --force-resync ".$drbd_resource."/".$next_drbd_volume; @@ -1756,7 +1768,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0765", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -1771,7 +1783,7 @@ sub manage_disk_add progress => 100, message => "error_0430", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { drbd_resource => $drbd_resource, @@ -1798,7 +1810,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0752", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } else @@ -1814,7 +1826,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0766", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, use_ip => $use_ip, @@ -1836,7 +1848,7 @@ sub manage_disk_add progress => 100, message => "error_0430", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { drbd_resource => $drbd_resource, @@ -1866,7 +1878,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0752", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -1877,7 +1889,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0767", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } @@ -1886,7 +1898,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0768", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $server_host = ""; foreach my $host_type ("node", "dr") @@ -1941,7 +1953,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0769", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } else @@ -1951,7 +1963,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0770", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_host => $server_host, }, @@ -1971,7 +1983,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0771", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $server_host = $short_host_name; $offline = 1; @@ -1998,7 +2010,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0772", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_name => $server_name, }, @@ -2010,7 +2022,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0773", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -2042,7 +2054,7 @@ sub manage_disk_add progress => 100, message => "error_0434", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -2053,7 +2065,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0774", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); update_definition($anvil, "undefine", $virsh_definition); @@ -2062,7 +2074,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0808", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->Server->update_definition({ debug => 2, @@ -2075,7 +2087,7 @@ sub manage_disk_add progress => 100, message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 0}); } @@ -2092,7 +2104,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0775", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); ($output, $return_code) = $anvil->System->call({shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -2106,7 +2118,7 @@ sub manage_disk_add progress => 100, message => "error_0138", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { shell_call => $shell_call, @@ -2122,7 +2134,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0776", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $shell_call = $anvil->data->{path}{exe}{setsid}." --wait ".$anvil->data->{path}{exe}{virsh}." dumpxml --inactive ".$server_name; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); @@ -2138,7 +2150,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0777", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $problem = $anvil->Server->parse_definition({ server => $server_name, @@ -2154,7 +2166,7 @@ sub manage_disk_add progress => 100, message => "error_0434", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -2165,7 +2177,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0778", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); update_definition($anvil, "undefine", $virsh_definition); @@ -2174,7 +2186,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0808", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->Server->update_definition({ debug => 2, @@ -2187,7 +2199,7 @@ sub manage_disk_add progress => 100, message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 0}); } @@ -2199,7 +2211,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0779", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_host => $server_host, use_ip => $use_ip, @@ -2243,7 +2255,7 @@ sub manage_disk_add progress => 100, message => "error_0435", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -2259,7 +2271,7 @@ sub manage_disk_add progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0780", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); update_definition($anvil, "undefine", $virsh_definition); @@ -2268,7 +2280,7 @@ sub manage_disk_add progress => 100, message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 0}); } @@ -2296,7 +2308,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0781", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { peer_name => $peer_name, }, @@ -2322,7 +2334,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0782", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); sleep 1; $shell_call = $anvil->data->{path}{exe}{drbdadm}." connect ".$drbd_resource; @@ -2343,7 +2355,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); # Now wait @@ -2351,7 +2363,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0783", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $waiting = 1; my $wait_until = time + 300; @@ -2369,7 +2381,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0784", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { drbd_resource => $drbd_resource, next_drbd_volume => $next_drbd_volume, @@ -2390,7 +2402,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0785", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $disks_ready = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disks_ready => $disks_ready }}); @@ -2401,7 +2413,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0786", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $disks_ready = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disks_ready => $disks_ready }}); @@ -2413,7 +2425,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0787", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { peer_disk_state => $peer_disk_state, }, @@ -2439,7 +2451,7 @@ sub reconnect_resource progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0788", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); return($peer_disk_state, $role); } @@ -2497,7 +2509,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0436", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { max_free_space => $anvil->Convert->bytes_to_human_readable({'bytes' => $max_free_space}), @@ -2507,7 +2519,7 @@ sub manage_disk_grow progress => 100, message => "log_0789", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2531,14 +2543,14 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0424", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->Job->update_progress({ progress => 100, message => "log_0789", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2552,7 +2564,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0438", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { add_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $add_size}), @@ -2562,7 +2574,7 @@ sub manage_disk_grow progress => 100, message => "log_0789", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2573,7 +2585,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0439", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { add_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $add_size}), @@ -2584,7 +2596,7 @@ sub manage_disk_grow progress => 100, message => "log_0789", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2606,7 +2618,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 10}), message => "error_0440", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); foreach my $short_host_name (sort {$a cmp $b} keys %{$anvil->data->{peer}}) @@ -2616,7 +2628,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 1}), message => "error_0428", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { host_name => $short_host_name, @@ -2628,7 +2640,7 @@ sub manage_disk_grow progress => 100, message => "job_0471", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2655,13 +2667,14 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0790", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { size => $hr_size, }, }); if ((not $anvil->data->{switches}{confirm}) && (not $anvil->data->{switches}{'job-uuid'})) { + $anvil->System->_abort_if_ci(); print $anvil->Words->string({key => "message_0021"})." "; my $answer = ; chomp($answer); @@ -2672,7 +2685,7 @@ sub manage_disk_grow progress => 100, message => "message_0022", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 0}); } @@ -2687,7 +2700,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 5}), message => "error_0441", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); foreach my $short_host_name (sort {$a cmp $b} keys %{$anvil->data->{peer}}) { @@ -2696,7 +2709,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 1}), message => "error_0428", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { host_name => $short_host_name, @@ -2708,7 +2721,7 @@ sub manage_disk_grow progress => 100, message => "job_0471", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); $anvil->nice_exit({exit_code => 1}); } @@ -2744,7 +2757,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 1}), message => "log_0791", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { backing_disk => $backing_disk, }, @@ -2760,7 +2773,7 @@ sub manage_disk_grow progress => 100, message => "error_0442", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { backing_disk => $backing_disk, @@ -2778,7 +2791,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -2790,7 +2803,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0792", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, backing_disk => $backing_disk, @@ -2813,7 +2826,7 @@ sub manage_disk_grow progress => 100, message => "error_0443", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { backing_disk => $backing_disk, @@ -2832,7 +2845,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -2844,7 +2857,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0793", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $shell_call = $anvil->data->{path}{exe}{drbdadm}." resize ".$drbd_resource."/".$drbd_volume; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); @@ -2860,7 +2873,7 @@ sub manage_disk_grow progress => 100, message => "error_0444", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { drbd_resource => $drbd_resource, @@ -2879,7 +2892,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } @@ -2888,7 +2901,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0794", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); foreach my $agent ("scan-drbd", "scan-lvm") { @@ -2896,7 +2909,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0740", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { agent => $agent, }, @@ -2928,7 +2941,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0795", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { agent => $agent, }, @@ -2944,7 +2957,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } else @@ -2955,7 +2968,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0796", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { agent => $agent, host_name => $short_host_name, @@ -2978,7 +2991,7 @@ sub manage_disk_grow progress => $anvil->Job->bump_progress({steps => 2}), message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); } } @@ -2990,7 +3003,7 @@ sub manage_disk_grow progress => 100, message => "log_0797", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); return(0); @@ -3048,7 +3061,7 @@ sub manage_optical progress => 100, message => "error_0445", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); show_server_details($anvil, 1); @@ -3126,7 +3139,7 @@ sub manage_optical progress => 100, message => "error_0446", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", }); $anvil->nice_exit({exit_code => 1}); @@ -3140,7 +3153,7 @@ sub manage_optical progress => 100, message => "error_0447", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { device_target => $device_target, @@ -3194,7 +3207,7 @@ sub manage_optical progress => 100, message => "error_0448", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { iso => $iso, @@ -3214,7 +3227,7 @@ sub manage_optical progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0798", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server_name => $server_name, }, @@ -3229,7 +3242,7 @@ sub manage_optical progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0799", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { insert => $anvil->data->{switches}{insert}, device_target => $device_target, @@ -3243,7 +3256,7 @@ sub manage_optical progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0800", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { device_path => $device_path, device_target => $device_target, @@ -3260,7 +3273,7 @@ sub manage_optical progress => 100, message => "error_0449", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { device_target => $device_target, @@ -3275,7 +3288,7 @@ sub manage_optical progress => 100, message => "error_0450", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { device_target => $device_target, @@ -3295,7 +3308,7 @@ sub manage_optical progress => $anvil->Job->bump_progress({steps => 5}), message => "log_0801", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); update_definition($anvil, "undefine", ""); @@ -3304,7 +3317,7 @@ sub manage_optical progress => 100, message => "log_0750", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); return(0); @@ -3431,6 +3444,7 @@ sub show_server_details my $on_lv = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{on_lv}; my $drbd_resource = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{resource}; my $drbd_volume = $anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$on_lv}{drbd}{volume}; + next if not defined $drbd_volume or $drbd_volume eq ""; my $resource_size = $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$drbd_resource}{volume}{$drbd_volume}{volume_size}; my $lv_name = $anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$on_lv}{scan_lvm_lv_name}; my $lv_size = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$lv_name}{scan_lvm_lv_size}; @@ -3455,7 +3469,13 @@ sub show_server_details if ($anvil->data->{switches}{machine}) { - $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $device_target})." boot-order=\"".$anvil->Words->escape_xml({string => $say_boot})."\" drbd-resource=\"".$anvil->Words->escape_xml({string => $drbd_resource})."\" drbd-volume=\"".$anvil->Words->escape_xml({string => $drbd_volume})."\" resource-size=\"".$anvil->Words->escape_xml({string => $resource_size})."B\" lv-size=\"".$anvil->Words->escape_xml({string => $lv_size})."B\"metadata-size=\"".$anvil->Words->escape_xml({string => $metadata_size})."B\" />\n"; + $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $device_target})."\" "; + $anvil->data->{xml}{body} .= "boot-order=\"".$anvil->Words->escape_xml({string => $say_boot})."\" "; + $anvil->data->{xml}{body} .= "drbd-resource=\"".$anvil->Words->escape_xml({string => $drbd_resource})."\" "; + $anvil->data->{xml}{body} .= "drbd-volume=\"".$anvil->Words->escape_xml({string => $drbd_volume})."\" "; + $anvil->data->{xml}{body} .= "resource-size=\"".$anvil->Words->escape_xml({string => $resource_size})."B\" "; + $anvil->data->{xml}{body} .= "lv-size=\"".$anvil->Words->escape_xml({string => $lv_size})."B\" "; + $anvil->data->{xml}{body} .= "metadata-size=\"".$anvil->Words->escape_xml({string => $metadata_size})."B\" />\n"; } else { @@ -3491,7 +3511,9 @@ sub show_server_details }}); if ($anvil->data->{switches}{machine}) { - $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $device_target})." boot-order=\"".$anvil->Words->escape_xml({string => $say_boot})."\" iso=\"".$anvil->Words->escape_xml({string => $device_path})."\"/>\n"; + $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $device_target})."\" "; + $anvil->data->{xml}{body} .= "boot-order=\"".$anvil->Words->escape_xml({string => $say_boot})."\" "; + $anvil->data->{xml}{body} .= "iso=\"".$anvil->Words->escape_xml({string => $device_path})."\" />\n"; } else { @@ -3546,7 +3568,7 @@ sub check_drbd_peer_access progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0016", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, }); my $all_online = 1; @@ -3565,7 +3587,7 @@ sub check_drbd_peer_access progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0018", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, }, @@ -3608,7 +3630,7 @@ sub check_drbd_peer_access progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0019", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, target_ip => $target_ip, @@ -3624,7 +3646,7 @@ sub check_drbd_peer_access progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0058", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $short_host_name, }, @@ -3657,7 +3679,7 @@ sub check_drbd_peer_access progress => $anvil->Job->bump_progress({steps => 1}), message => "job_0053", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { host_name => $peer_name, }, @@ -3817,6 +3839,10 @@ sub show_volume $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }}); } + if ($anvil->data->{switches}{machine}) + { + $anvil->data->{xml}{body} .= "\t\n"; + } foreach my $short_host_name (sort {$a cmp $b} keys %{$anvil->data->{drbd_resource}{$drbd_resource}{host_type}{$host_type}{short_host_name}}) { my $host_uuid = $anvil->data->{drbd_resource}{$drbd_resource}{host_type}{$host_type}{short_host_name}{$short_host_name}{host_uuid}; @@ -3827,7 +3853,9 @@ sub show_volume if ($anvil->data->{switches}{machine}) { my $host_type = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_type}; - $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $short_host_name})." type=\"".$anvil->Words->escape_xml({string => $host_type})."\" uuid=\"".$anvil->Words->escape_xml({string => $host_uuid})."\"/>\n"; + $anvil->data->{xml}{body} .= "\t\tWords->escape_xml({string => $short_host_name})."\" "; + $anvil->data->{xml}{body} .= "type=\"".$anvil->Words->escape_xml({string => $host_type})."\" "; + $anvil->data->{xml}{body} .= "uuid=\"".$anvil->Words->escape_xml({string => $host_uuid})."\">\n"; } else { @@ -3838,10 +3866,12 @@ sub show_volume } foreach my $volume_number (sort {$a cmp $b} keys %{$anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}}) { + next if $anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{device_path} eq "DELETED"; my $device_path = $anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{device_path}; my $device_minor = $anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{device_minor}; my $volume_size = $anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{volume_size}; my $backing_disk = $anvil->data->{new}{resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{backing_disk}; + next if not defined $backing_disk or $backing_disk eq ""; my $meta_disk = $anvil->data->{new}{resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{meta_disk}; my $storage_group_uuid = $anvil->data->{new}{resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{storage_group_uuid}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -3853,6 +3883,7 @@ sub show_volume 's6:meta_disk' => $meta_disk, 's7:storage_group_uuid' => $storage_group_uuid, }}); + my $storage_group_name = ""; my $storage_group_size = 0; my $storage_group_free_space = 0; @@ -3868,7 +3899,11 @@ sub show_volume }}); if ($anvil->data->{switches}{machine}) { - $anvil->data->{xml}{body} .= "\t\tWords->escape_xml({string => $volume_number})." backing-lv=\"".$anvil->Words->escape_xml({string => $backing_disk})."\" lv-size=\"".$anvil->Words->escape_xml({string => $volume_size})."B\" sg-name=\"".$anvil->Words->escape_xml({string => $storage_group_name})."\" sg-uuid=\"".$anvil->Words->escape_xml({string => $storage_group_uuid})."\"/>\n"; + $anvil->data->{xml}{body} .= "\t\t\tWords->escape_xml({string => $volume_number})."\" "; + $anvil->data->{xml}{body} .= "backing-lv=\"".$anvil->Words->escape_xml({string => $backing_disk})."\" "; + $anvil->data->{xml}{body} .= "lv-size=\"".$anvil->Words->escape_xml({string => $volume_size})."B\" "; + $anvil->data->{xml}{body} .= "sg-name=\"".$anvil->Words->escape_xml({string => $storage_group_name})."\" "; + $anvil->data->{xml}{body} .= "sg-uuid=\"".$anvil->Words->escape_xml({string => $storage_group_uuid})."\" />\n"; } else { @@ -3923,9 +3958,13 @@ sub show_volume } if ($anvil->data->{switches}{machine}) { - $anvil->data->{xml}{body} .= "\t\n"; + $anvil->data->{xml}{body} .= "\t\t\n"; } } + if ($anvil->data->{switches}{machine}) + { + $anvil->data->{xml}{body} .= "\t\n"; + } return(0); } @@ -3962,7 +4001,7 @@ sub validate_server progress => 100, message => $key, log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { server => $anvil->data->{switches}{server}, @@ -3975,7 +4014,8 @@ sub validate_server if ($anvil->data->{switches}{machine}) { $anvil->data->{xml}{body} = "\n"; - $anvil->data->{xml}{body} .= "Words->escape_xml({string => $anvil->data->{switches}{server_name}})."\" uuid=\"".$anvil->Words->escape_xml({string => $anvil->data->{switches}{server_uuid}})."\">\n"; + $anvil->data->{xml}{body} .= "Words->escape_xml({string => $anvil->data->{switches}{server_name}})."\" "; + $anvil->data->{xml}{body} .= "uuid=\"".$anvil->Words->escape_xml({string => $anvil->data->{switches}{server_uuid}})."\" >\n"; } $anvil->Job->update_progress({ progress => $anvil->Job->bump_progress({steps => 1}), @@ -4018,7 +4058,7 @@ sub validate_server progress => 100, message => "error_0453", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { server => $server_name, @@ -4045,8 +4085,14 @@ sub validate_server if (not $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}{xml}) { - # The server isn't actually running... Not here anyway. - if ($server_state eq "running") + # The server isn't actually running... Not here anyway, or the database data is stale. If + # we're just displaying info, proceed, but if we're doing something, reassign. + if (($server_state eq "running") && + ($server_host_uuid ne $anvil->Get->host_uuid) && + (($anvil->data->{switches}{add}) or + ($anvil->data->{switches}{eject}) or + ($anvil->data->{switches}{grow}) or + ($anvil->data->{switches}{insert}))) { my $server_host_name = $anvil->Database->get_host_from_uuid({ short => 1, @@ -4074,19 +4120,55 @@ sub validate_server $job_description = "job_0502"; $job_name = "server::".$anvil->data->{switches}{server_uuid}."::change_iso"; } + # Reassign the job. - my $job_data = "add=".$anvil->data->{switches}{add}."\n"; - $job_data .= "anvil=".$anvil->data->{switches}{add}."\n"; - $job_data .= "confirm=true\n"; - $job_data .= "disk=".$anvil->data->{switches}{disk}."\n"; - $job_data .= "eject=".$anvil->data->{switches}{eject}."\n"; - $job_data .= "grow=".$anvil->data->{switches}{grow}."\n"; - $job_data .= "insert=".$anvil->data->{switches}{insert}."\n"; - $job_data .= "machine=".$anvil->data->{switches}{machine}."\n"; - $job_data .= "optical=".$anvil->data->{switches}{optical}."\n"; - $job_data .= "server=".$anvil->data->{switches}{server}."\n"; - $job_data .= "storage-group=".$anvil->data->{switches}{'storage-group'}."\n"; + my $job_data = "add=".$anvil->data->{switches}{add}."\n"; + $job_data .= "anvil=".$anvil->data->{switches}{anvil}."\n"; + $job_data .= "confirm=true\n"; + $job_data .= "disk=".$anvil->data->{switches}{disk}."\n"; + $job_data .= "eject=".$anvil->data->{switches}{eject}."\n"; + $job_data .= "grow=".$anvil->data->{switches}{grow}."\n"; + $job_data .= "insert=".$anvil->data->{switches}{insert}."\n"; + $job_data .= "machine=".$anvil->data->{switches}{machine}."\n"; + $job_data .= "optical=".$anvil->data->{switches}{optical}."\n"; + $job_data .= "server=".$anvil->data->{switches}{server}."\n"; + $job_data .= "storage-group=".$anvil->data->{switches}{'storage-group'}."\n"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_data => $job_data }}); + + # If this is a grow, add or delete job, ask the user to confirm. + $anvil->Job->update_progress({ + progress => $anvil->Job->bump_progress({steps => 2}), + message => "log_0349", + log_level => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, + variables => { + host => $server_host_name, + job_data => $job_data, + job_name => $job_name, + job_title => "#!string!".$job_title."!#", + job_description => "#!string!".$job_description."!#", + }, + }); + + # Confirmation set by '--ci-test' so don't abort if --ci-test in use, just re-assign. + if ((not $anvil->data->{switches}{confirm}) && (not $anvil->data->{switches}{'job-uuid'})) + { + print $anvil->Words->string({key => "message_0021"})." "; + my $answer = ; + chomp($answer); + if ($answer !~ /^y/i) + { + # Abort + $anvil->Job->update_progress({ + progress => 100, + message => "message_0022", + log_level => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, + }); + $anvil->nice_exit({exit_code => 0}); + } + } + my ($job_uuid) = $anvil->Database->insert_or_update_jobs({ debug => 2, job_command => $anvil->data->{path}{exe}{$THIS_FILE}.$anvil->Log->switches, @@ -4104,7 +4186,7 @@ sub validate_server progress => 100, message => "job_0136", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, variables => { server => $server_name, host_name => $server_host_name, @@ -4119,7 +4201,7 @@ sub validate_server progress => 100, message => "error_0454", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { server => $server_name, @@ -4286,7 +4368,7 @@ sub update_definition progress => 100, message => "error_0455", log_level => 1, - 'print' => 1, + 'print' => $anvil->data->{switches}{machine} ? 0 : 1, priority => "err", variables => { server => $server_name, @@ -4379,7 +4461,9 @@ sub show_server_list if ($anvil->data->{switches}{machine}) { $anvil_description =~ s/"/\"/g; - $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $anvil_name})."\" uuid=\"".$anvil->Words->escape_xml({string => $anvil_uuid})."\" description=\"".$anvil->Words->escape_xml({string => $anvil_description})."\">\n"; + $anvil->data->{xml}{body} .= "\tWords->escape_xml({string => $anvil_name})."\" "; + $anvil->data->{xml}{body} .= "uuid=\"".$anvil->Words->escape_xml({string => $anvil_uuid})."\" "; + $anvil->data->{xml}{body} .= "description=\"".$anvil->Words->escape_xml({string => $anvil_description})."\" >\n"; } else { @@ -4393,7 +4477,21 @@ sub show_server_list my $server_count = 0; if (exists $anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}) { - $server_count = keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}; + foreach my $server_name (sort {$a cmp $b} keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}) + { + my $server_uuid = $anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}{$server_name}{server_uuid}; + my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 's1:server_name' => $server_name, + 's2:server_uuid' => $server_uuid, + 's3:server_state' => $server_state, + }}); + if ($server_state ne "DELETED") + { + $server_count++; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_count => $server_count }}); + } + } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_count => $server_count }}); } if (not $server_count) @@ -4411,7 +4509,6 @@ sub show_server_list { if ($anvil->data->{switches}{machine}) { - my $server_count = keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}; $anvil->data->{xml}{body} .= "\t\t\n"; } foreach my $server_name (sort {$a cmp $b} keys %{$anvil->data->{servers}{anvil_uuid}{$anvil_uuid}{server_name}}) diff --git a/tools/anvil-manage-server-system b/tools/anvil-manage-server-system index e7a4b53a8..400097cdb 100755 --- a/tools/anvil-manage-server-system +++ b/tools/anvil-manage-server-system @@ -200,6 +200,7 @@ sub manage_cpu }}); } + # Max cores already accounts for 1 or 2 less than real cores. my $host_cores = $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{cores}; my $host_threads = $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{threads}; my $max_cores = $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{available}; @@ -211,7 +212,7 @@ sub manage_cpu my $recommended_max = $host_cores - 2; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { recommended_max => $recommended_max }}); - if ($host_cores <= 2) + if ($host_cores <= 4) { $recommended_max = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { recommended_max => $recommended_max }}); @@ -292,6 +293,8 @@ sub manage_cpu new_sockets => $new_sockets, new_cores => $new_cores, new_threads => $new_threads, + max_cores => $max_cores, + recommended_max => $recommended_max, }; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0477", variables => $variables}); $anvil->Job->update_progress({ @@ -389,7 +392,7 @@ sub manage_cpu elsif ($anvil->data->{switches}{confirm}) { # User confirmed - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0359"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0150"}); } else { @@ -645,7 +648,7 @@ sub manage_ram elsif ($anvil->data->{switches}{confirm}) { # User confirmed - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0359"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0150"}); } else { @@ -960,7 +963,7 @@ sub manage_boot_order elsif ($anvil->data->{switches}{confirm}) { # User confirmed - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0359"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0150"}); } else { diff --git a/tools/anvil-provision-server b/tools/anvil-provision-server index a9a47ea30..cafc89901 100755 --- a/tools/anvil-provision-server +++ b/tools/anvil-provision-server @@ -795,7 +795,8 @@ sub provision_server $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0200"}); # Loop for up to 10 seconds waiting to see the server start running. - my $wait_until = time + 60; + my $timeout = 120; + my $wait_until = time + $timeout; $waiting = 1; my $status = ""; while($waiting) @@ -834,10 +835,16 @@ sub provision_server $waiting = 0; $anvil->Job->update_progress({ progress => 100, - message => "error_0210,!!status!".$status."!!", + message => "error_0210", job_status => "failed", + 'print' => 1, + level => 0, + priority => 'err', + variables => { + timeout => $timeout, + status => $status, + }, }); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => 'err', key => "error_0210", variables => { status => $status }}); $anvil->nice_exit({exit_code => 1}); } sleep 1; @@ -1536,15 +1543,18 @@ sub create_lv my $say_storage_group = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{group_name}; $anvil->Job->update_progress({ progress => 100, - message => "error_0194,!!server_name!".$anvil->data->{job}{server_name}."!!,!!available_size!".$say_available_size."!!,!!requested_size!".$say_requested_size."!!,!!storage_group!".$say_storage_group."!!", + message => "error_0194", job_status => "failed", + 'print' => 1, + log_level => 0, + priority => 'err', + variables => { + server_name => $anvil->data->{job}{server_name}, + available_size => $say_available_size, + requested_size => $say_requested_size, + storage_group => $say_storage_group, + }, }); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => 'err', key => "error_0194", variables => { - server_name => $anvil->data->{job}{server_name}, - available_size => $say_available_size, - requested_size => $say_requested_size, - storage_group => $say_storage_group, - }}); $anvil->nice_exit({exit_code => 1}); } } diff --git a/tools/anvil-shutdown-server b/tools/anvil-shutdown-server index d65ccaf3f..ffa3aaff5 100755 --- a/tools/anvil-shutdown-server +++ b/tools/anvil-shutdown-server @@ -167,6 +167,20 @@ else "switches::server_name" => $anvil->data->{switches}{server_name}, "switches::server_uuid" => $anvil->data->{switches}{server_uuid}, }}); + + if ((not $anvil->data->{switches}{server_name}) or (not $anvil->data->{switches}{server_uuid})) + { + $anvil->Job->update_progress({ + progress => 100, + 'print' => 1, + log_level => 1, + message => "error_0080", + variables => { + server => $anvil->data->{switches}{server}, + }, + }); + $anvil->nice_exit({exit_code => 1}); + } } # If the server isn't all, check to see if the server is running elsewhere. If it is, reassign the job to that host. @@ -187,6 +201,20 @@ if (($anvil->data->{switches}{server} !~ /all/i) && ($anvil->data->{sys}{databas 's5:server_state' => $server_state, }}); + if ((not $server_host_uuid) or ($server_host_uuid eq "NULL")) + { + $anvil->Job->update_progress({ + progress => 100, + 'print' => 1, + log_level => 1, + message => "warning_0017", + variables => { + server => $anvil->data->{switches}{server_name}, + }, + }); + $anvil->nice_exit({exit_code => 1}); + } + if (($server_state eq "running") && ($server_host_uuid ne $anvil->Get->host_uuid)) { # Re-assign the job. @@ -278,6 +306,47 @@ if ($anvil->data->{switches}{server} !~ /all/i) 's4:server_state' => $server_state, }}); + # Is the server deleted? + if ($server_state eq "DELETED") + { + $anvil->Job->update_progress({ + progress => 100, + 'print' => 1, + log_level => 1, + message => "warning_0016", + variables => { + server => $anvil->data->{switches}{server_name}, + }, + }); + $anvil->nice_exit({exit_code => 1}); + } + if ($server_state eq "shut off") + { + $anvil->Job->update_progress({ + progress => 100, + 'print' => 1, + log_level => 1, + message => "warning_0018", + variables => { + server => $anvil->data->{switches}{server_name}, + }, + }); + $anvil->nice_exit({exit_code => 1}); + } + if ((not $server_host_uuid) or ($server_host_uuid eq "NULL")) + { + $anvil->Job->update_progress({ + progress => 100, + 'print' => 1, + log_level => 1, + message => "warning_0017", + variables => { + server => $anvil->data->{switches}{server_name}, + }, + }); + $anvil->nice_exit({exit_code => 1}); + } + if (($server_host_uuid) && ($server_state)) { # Re-assign the job. diff --git a/tools/striker-auto-initialize-all b/tools/striker-auto-initialize-all index 89351670f..ad429460a 100755 --- a/tools/striker-auto-initialize-all +++ b/tools/striker-auto-initialize-all @@ -139,6 +139,46 @@ sub striker_stage2 # Run the manifest(s). run_manifests($anvil); + # Update NTP if needed + update_ntp($anvil); + + return(0); +} + +sub update_ntp +{ + my ($anvil) = @_; + + # If NTP is set, add a DB entry for all hosts to use the requested NTP server. + $anvil->Database->get_hosts({debug => 2}); + my $network_ntp = $anvil->data->{base}{ntp}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_ntp => $network_ntp }}); + if ($network_ntp) + { + foreach my $host_type (sort {$a cmp $b} keys %{$anvil->data->{sys}{hosts}{by_type}}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }}); + foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}}) + { + my $host_uuid = $anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}{$host_name}{host_uuid}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + host_name => $host_name, + host_uuid => $host_uuid, + }}); + + $anvil->Database->insert_or_update_variables({ + variable_name => "network::ntp::servers", + variable_value => $network_ntp, + variable_default => "", + variable_description => "striker_0002", + variable_section => "network", + variable_source_uuid => $host_uuid, + variable_source_table => "hosts", + }); + } + } + } + return(0); } @@ -1098,6 +1138,7 @@ sub create_manifest "process::anvil::${anvil_number}::manifest_uuid" => $anvil->data->{process}{anvil}{$anvil_number}{manifest_uuid}, }}); } + update_progress($anvil, 55, "job_0245"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0245"});