* Fixed a bug where, when DRBD->gather_data() calls 'drbdadm dump-xml' and the output includes usage data, it breaks XML parsing.

* Fixed a bug in Get->available_resources() where DELETED servers were being counted in the used resources math.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 2 years ago
parent cc32d5b606
commit e7537b0ca3
  1. 18
      Anvil/Tools/DRBD.pm
  2. 12
      Anvil/Tools/Get.pm
  3. 1
      notes

@ -738,6 +738,24 @@ sub gather_data
local_short_host_name => $local_short_host_name, local_short_host_name => $local_short_host_name,
}}); }});
# Often, annoyingly, DRBD reports a message about usage before showing the XML. We need to detect and
# strip that off.
my $new_xml = "";
my $in_xml = 0;
foreach my $line (split/\n/, $xml)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
if ($line =~ /<config/)
{
$in_xml = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_xml => $in_xml }});
}
next if not $in_xml;
$new_xml .= $line."\n";
}
$xml = $new_xml;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { xml => $xml }});
local $@; local $@;
my $dom = eval { XML::LibXML->load_xml(string => $xml); }; my $dom = eval { XML::LibXML->load_xml(string => $xml); };
if ($@) if ($@)

@ -601,7 +601,7 @@ WHERE
scan_hardware_cpu_cores => $scan_hardware_cpu_cores, scan_hardware_cpu_cores => $scan_hardware_cpu_cores,
scan_hardware_cpu_threads => $scan_hardware_cpu_threads, scan_hardware_cpu_threads => $scan_hardware_cpu_threads,
scan_hardware_cpu_model => $scan_hardware_cpu_model, scan_hardware_cpu_model => $scan_hardware_cpu_model,
scan_hardware_ram_total => $scan_hardware_ram_total, scan_hardware_ram_total => $scan_hardware_ram_total." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_hardware_ram_total}).")",
}}); }});
$anvil->data->{anvil_resources}{$anvil_uuid}{host_uuid}{$host_uuid}{cpu}{cores} = $scan_hardware_cpu_cores; $anvil->data->{anvil_resources}{$anvil_uuid}{host_uuid}{$host_uuid}{cpu}{cores} = $scan_hardware_cpu_cores;
@ -663,7 +663,9 @@ SELECT
FROM FROM
servers servers
WHERE WHERE
server_anvil_uuid = ".$anvil->Database->quote($anvil_uuid)." server_anvil_uuid = ".$anvil->Database->quote($anvil_uuid)."
AND
server_state != 'DELETED'
ORDER BY ORDER BY
server_name ASC;"; server_name ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
@ -693,9 +695,13 @@ ORDER BY
if (not exists $anvil->data->{anvil_resources}{ram}{reserved}) if (not exists $anvil->data->{anvil_resources}{ram}{reserved})
{ {
$anvil->data->{anvil_resources}{ram}{reserved} = $default_reserved; $anvil->data->{anvil_resources}{ram}{reserved} = $default_reserved;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
default_reserved => $default_reserved,
"anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved},
}});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{ram}{reserved}}).")", "anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved},
}}); }});
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/,//g; $anvil->data->{anvil_resources}{ram}{reserved} =~ s/,//g;

@ -17,6 +17,7 @@ Common queries;
* SELECT a.host_name, b.file_name, c.file_location_active FROM hosts a, files b, file_locations c WHERE a.host_uuid = c.file_location_host_uuid AND b.file_uuid = c.file_location_file_uuid ORDER BY b.file_name ASC, a.host_name ASC; * SELECT a.host_name, b.file_name, c.file_location_active FROM hosts a, files b, file_locations c WHERE a.host_uuid = c.file_location_host_uuid AND b.file_uuid = c.file_location_file_uuid ORDER BY b.file_name ASC, a.host_name ASC;
* SELECT a.dr_link_uuid, b.host_name, c.anvil_name, a.dr_link_note FROM dr_links a, hosts b, anvils c WHERE a.dr_link_host_uuid = b.host_uuid AND a.dr_link_anvil_uuid = c.anvil_uuid ORDER BY c.anvil_name ASC, b.host_name ASC; * SELECT a.dr_link_uuid, b.host_name, c.anvil_name, a.dr_link_note FROM dr_links a, hosts b, anvils c WHERE a.dr_link_host_uuid = b.host_uuid AND a.dr_link_anvil_uuid = c.anvil_uuid ORDER BY c.anvil_name ASC, b.host_name ASC;
* SELECT a.storage_group_uuid, d.storage_group_member_uuid, b.anvil_name, a.storage_group_name, c.host_name, d.storage_group_member_vg_uuid, d.storage_group_member_note FROM storage_groups a, anvils b, hosts c, storage_group_members d WHERE a.storage_group_uuid = d.storage_group_member_storage_group_uuid AND a.storage_group_anvil_uuid = b.anvil_uuid AND c.host_uuid = d.storage_group_member_host_uuid ORDER BY a.storage_group_name ASC, c.host_name ASC; * SELECT a.storage_group_uuid, d.storage_group_member_uuid, b.anvil_name, a.storage_group_name, c.host_name, d.storage_group_member_vg_uuid, d.storage_group_member_note FROM storage_groups a, anvils b, hosts c, storage_group_members d WHERE a.storage_group_uuid = d.storage_group_member_storage_group_uuid AND a.storage_group_anvil_uuid = b.anvil_uuid AND c.host_uuid = d.storage_group_member_host_uuid ORDER BY a.storage_group_name ASC, c.host_name ASC;
* SELECT a.scan_hardware_uuid, b.host_name, a.scan_hardware_cpu_cores AS cores, a.scan_hardware_cpu_threads AS threads, pg_size_pretty(a.scan_hardware_ram_total) AS ram_total, pg_size_pretty(a.scan_hardware_memory_total) AS memory_total, pg_size_pretty(a.scan_hardware_memory_free) AS memory_free FROM scan_hardware a, hosts b WHERE a.scan_hardware_host_uuid = b.host_uuid ORDER BY b.host_name ASC;
# Fail a resource for testing purposes. # Fail a resource for testing purposes.

Loading…
Cancel
Save