From a5cee52153a034aed4beb60e1c8e0e71ef3c7964 Mon Sep 17 00:00:00 2001 From: digimer Date: Wed, 4 Jan 2023 22:58:28 -0500 Subject: [PATCH] * Fixed a bug in DRBD->get_devices() where old test host UUIDs were left hard-coded. * Fixed a duplicate header in words.xml * Fixed display bugs in anvil-report-usage and removed the old DR host display info. Signed-off-by: digimer --- Anvil/Tools/DRBD.pm | 4 +-- share/words.xml | 2 +- tools/anvil-report-usage | 56 +++++++--------------------------------- 3 files changed, 13 insertions(+), 49 deletions(-) diff --git a/Anvil/Tools/DRBD.pm b/Anvil/Tools/DRBD.pm index db158afe..af991b65 100644 --- a/Anvil/Tools/DRBD.pm +++ b/Anvil/Tools/DRBD.pm @@ -1396,9 +1396,9 @@ SELECT FROM scan_drbd WHERE - scan_drbd_host_uuid = '618e8007-3a0b-4bbf-a616-a64fd7d2dc30' + scan_drbd_host_uuid = ".$anvil->Database->quote($node1_host_uuid)." OR - scan_drbd_host_uuid = '75070e21-a0e3-4ba5-b4f7-476bf5d08107' + scan_drbd_host_uuid = ".$anvil->Database->quote($node2_host_uuid)." ORDER BY modified_date DESC LIMIT 1 ;"; diff --git a/share/words.xml b/share/words.xml index 073bb9f2..17434e2a 100644 --- a/share/words.xml +++ b/share/words.xml @@ -961,7 +961,7 @@ resource #!variable!server!# { RAM Used RAM Free Bridges - Storage Group + #!free!# Used Free Anvil! Node diff --git a/tools/anvil-report-usage b/tools/anvil-report-usage index e62a2896..da21c6e5 100755 --- a/tools/anvil-report-usage +++ b/tools/anvil-report-usage @@ -73,12 +73,10 @@ sub collect_anvil_data $anvil->data->{anvil_data}{$anvil_name}{description} = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_description}; $anvil->data->{anvil_data}{$anvil_name}{node1_host_uuid} = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_node1_host_uuid}; $anvil->data->{anvil_data}{$anvil_name}{node2_host_uuid} = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_node2_host_uuid}; - $anvil->data->{anvil_data}{$anvil_name}{dr1_host_uuid} = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_dr1_host_uuid}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "s1:anvil_data::${anvil_name}::anvil_description" => $anvil->data->{anvil_data}{$anvil_name}{description}, "s2:anvil_data::${anvil_name}::node1_host_uuid" => $anvil->data->{anvil_data}{$anvil_name}{node1_host_uuid}, "s3:anvil_data::${anvil_name}::node2_host_uuid" => $anvil->data->{anvil_data}{$anvil_name}{node2_host_uuid}, - "s4:anvil_data::${anvil_name}::dr1_host_uuid" => $anvil->data->{anvil_data}{$anvil_name}{dr1_host_uuid}, }}); if (length($anvil_name) > $anvil->data->{longest}{anvil_name}) @@ -99,34 +97,22 @@ sub collect_anvil_data my $node1_host_uuid = $anvil->data->{anvil_data}{$anvil_name}{node1_host_uuid}; my $node2_host_uuid = $anvil->data->{anvil_data}{$anvil_name}{node2_host_uuid}; - my $dr1_host_uuid = $anvil->data->{anvil_data}{$anvil_name}{dr1_host_uuid}; if ($anvil->data->{switches}{detailed}) { $anvil->data->{anvil_data}{$anvil_name}{node1_host_name} = $anvil->data->{hosts}{host_uuid}{$node1_host_uuid}{host_name}; $anvil->data->{anvil_data}{$anvil_name}{node2_host_name} = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{host_name}; - $anvil->data->{anvil_data}{$anvil_name}{dr1_host_name} = ""; - if ($dr1_host_uuid) - { - $anvil->data->{anvil_data}{$anvil_name}{dr1_host_name} = $anvil->data->{hosts}{host_uuid}{$dr1_host_uuid}{host_name}; - } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "s1:anvil_data::${anvil_name}::node1_host_name" => $anvil->data->{anvil_data}{$anvil_name}{node1_host_name}, "s2:anvil_data::${anvil_name}::node2_host_name" => $anvil->data->{anvil_data}{$anvil_name}{node2_host_name}, - "s3:anvil_data::${anvil_name}::dr1_host_name" => $anvil->data->{anvil_data}{$anvil_name}{dr1_host_name}, }}); } else { $anvil->data->{anvil_data}{$anvil_name}{node1_host_name} = $anvil->data->{hosts}{host_uuid}{$node1_host_uuid}{short_host_name}; $anvil->data->{anvil_data}{$anvil_name}{node2_host_name} = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{short_host_name}; - if ($dr1_host_uuid) - { - $anvil->data->{anvil_data}{$anvil_name}{dr1_host_name} = $anvil->data->{hosts}{host_uuid}{$dr1_host_uuid}{short_host_name}; - } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "s1:anvil_data::${anvil_name}::node1_host_name" => $anvil->data->{anvil_data}{$anvil_name}{node1_host_name}, "s2:anvil_data::${anvil_name}::node2_host_name" => $anvil->data->{anvil_data}{$anvil_name}{node2_host_name}, - "s3:anvil_data::${anvil_name}::dr1_host_name" => $anvil->data->{anvil_data}{$anvil_name}{dr1_host_name}, }}); } @@ -202,18 +188,12 @@ sub collect_anvil_data my $vg_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{vg_size}; my $free_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}; my $sg_used = $vg_size - $free_size; - my $vg_size_on_dr = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{vg_size_on_dr}; - my $free_size_on_dr = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{available_on_dr}; - my $sg_used_on_dr = $vg_size_on_dr - $free_size_on_dr; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 's1:storage_group_name' => $storage_group_name, 's2:storage_group_uuid' => $storage_group_uuid, 's3:vg_size' => $anvil->Convert->add_commas({number => $vg_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size}).")", 's4:free_size' => $anvil->Convert->add_commas({number => $free_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $free_size}).")", 's5:sg_used' => $anvil->Convert->add_commas({number => $sg_used})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $sg_used}).")", - 's6:vg_size_on_dr' => $anvil->Convert->add_commas({number => $vg_size_on_dr})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size_on_dr}).")", - 's7:free_size_on_dr' => $anvil->Convert->add_commas({number => $free_size_on_dr})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $free_size_on_dr}).")", - 's8:sg_used_on_dr' => $anvil->Convert->add_commas({number => $sg_used_on_dr})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $sg_used_on_dr}).")", }}); $anvil->data->{anvil_data}{$anvil_name}{storage_group}{$storage_group_name}{say_used_size} = $anvil->Convert->bytes_to_human_readable({'bytes' => $sg_used}); @@ -266,7 +246,7 @@ sub show_anvils my $longest_ram_free = length($ram_free_header) > $anvil->data->{longest}{ram_free} ? length($ram_free_header) : $anvil->data->{longest}{ram_free}; my $bridge_header = $anvil->Words->string({key => "header_0077"}); my $longest_bridge_string = length($bridge_header) > $anvil->data->{longest}{bridge_string} ? length($bridge_header) : $anvil->data->{longest}{bridge_string}; - my $storage_group_header = $anvil->Words->string({key => "header_0078"}); + my $storage_group_header = $anvil->Words->string({key => "header_0070"}); my $longest_storage_group = length($storage_group_header) > $anvil->data->{longest}{storage_group} ? length($storage_group_header) : $anvil->data->{longest}{storage_group}; my $sg_used_header = $anvil->Words->string({key => "header_0079"}); my $longest_sg_used = length($sg_used_header) > $anvil->data->{longest}{sg_used} ? length($sg_used_header) : $anvil->data->{longest}{sg_used}; @@ -287,37 +267,37 @@ sub show_anvils # Anvil! my $break_line = "+-".sprintf("%0${longest_anvil_name}d", 0); my $header_line = "| ".sprintf("%-${longest_anvil_name}s", $anvil_header)." "; - my $blank_lead = "| ".sprintf("%-${longest_anvil_name}s", $anvil_header)." "; + my $blank_lead = "| ".sprintf("%-${longest_anvil_name}s", "")." "; if ($anvil->data->{switches}{detailed}) { # Description $break_line .= "-+-".sprintf("%0${longest_description}d", 0); $header_line .= "| ".sprintf("%-${longest_description}s", $description_header)." "; - $blank_lead .= " ".sprintf("%-${longest_description}s", $description_header)." "; + $blank_lead .= "| ".sprintf("%-${longest_description}s", "")." "; } # CPU String $break_line .= "-+-".sprintf("%0${longest_cpu_string}d", 0); $header_line .= "| ".sprintf("%-${longest_cpu_string}s", $cpu_header)." "; - $blank_lead .= " ".sprintf("%-${longest_cpu_string}s", $cpu_header)." "; + $blank_lead .= "| ".sprintf("%-${longest_cpu_string}s", "")." "; if ($anvil->data->{switches}{detailed}) { # RAM used $break_line .= "-+-".sprintf("%0${longest_ram_used}d", 0); $header_line .= "| ".sprintf("%-${longest_ram_used}s", $ram_used_header)." "; - $blank_lead .= " ".sprintf("%-${longest_ram_used}s", $ram_used_header)." "; + $blank_lead .= "| ".sprintf("%-${longest_ram_used}s", "")." "; } # RAM Free $break_line .= "-+-".sprintf("%0${longest_ram_free}d", 0); $header_line .= "| ".sprintf("%-${longest_ram_free}s", $ram_free_header)." "; - $blank_lead .= " ".sprintf("%-${longest_ram_free}s", $ram_free_header)." "; + $blank_lead .= "| ".sprintf("%-${longest_ram_free}s", "")." "; # Bridges $break_line .= "-+-".sprintf("%0${longest_bridge_string}d", 0); $header_line .= "| ".sprintf("%-${longest_bridge_string}s", $bridge_header)." "; - $blank_lead .= " ".sprintf("%-${longest_bridge_string}s", $bridge_header)." "; + $blank_lead .= "| ".sprintf("%-${longest_bridge_string}s", ""); # Storage Group $break_line .= "-+-".sprintf("%0${longest_storage_group}d", 0); @@ -379,7 +359,8 @@ sub show_anvils $storage_line .= " | ".sprintf("%-${longest_sg_used}s", $say_used_size); } $storage_line .= " | ".sprintf("%-${longest_sg_free}s", $say_free_size)." |"; - + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { storage_line => $storage_line }}); + push @{$storage_groups}, $storage_line; } @@ -741,27 +722,17 @@ sub collect_server_data # have a matching node name. my $node1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid}; my $node2_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node2_host_uuid}; - my $dr1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_dr1_host_uuid}; # Get names. my $node1_host_name = $anvil->data->{hosts}{host_uuid}{$node1_host_uuid}{host_name}; my $node1_short_host_name = $anvil->data->{hosts}{host_uuid}{$node1_host_uuid}{short_host_name}; my $node2_host_name = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{host_name}; my $node2_short_host_name = $anvil->data->{hosts}{host_uuid}{$node2_host_uuid}{short_host_name}; - my $dr1_host_name = ""; - my $dr1_short_host_name = ""; - if (($dr1_host_uuid) && (exists $anvil->data->{hosts}{host_uuid}{$dr1_host_uuid})) - { - $dr1_host_name = $anvil->data->{hosts}{host_uuid}{$dr1_host_uuid}{host_name}; - $dr1_short_host_name = $anvil->data->{hosts}{host_uuid}{$dr1_host_uuid}{short_host_name}; - } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 's1:node1_host_name' => $node1_host_name, 's2:node1_short_host_name' => $node1_short_host_name, 's3:node2_host_name' => $node2_host_name, 's4:node2_short_host_name' => $node2_short_host_name, - 's5:dr1_host_name' => $dr1_host_name, - 's6:dr1_short_host_name' => $dr1_short_host_name, }}); # Storage info. @@ -806,9 +777,7 @@ sub collect_server_data if (($drbd_node eq $node1_host_name) or ($drbd_node eq $node1_short_host_name) or ($drbd_node eq $node2_host_name) or - ($drbd_node eq $node2_short_host_name) or - (($dr1_host_name) && ($drbd_node eq $dr1_host_name)) or - (($dr1_short_host_name) && ($drbd_node eq $dr1_short_host_name))) + ($drbd_node eq $node2_short_host_name)) { $anvil->data->{server_data}{$server_name}{server_uuid}{$server_uuid}{disk}{$resource}{$volume}{node}{$drbd_node}{drbd_path} = $anvil->data->{drbd}{drbd_node}{$drbd_node}{config}{resource}{$resource}{volume}{$volume}{drbd_path}; $anvil->data->{server_data}{$server_name}{server_uuid}{$server_uuid}{disk}{$resource}{$volume}{node}{$drbd_node}{drbd_path_by_res} = $anvil->data->{drbd}{drbd_node}{$drbd_node}{config}{resource}{$resource}{volume}{$volume}{drbd_path_by_res}; @@ -835,11 +804,6 @@ sub collect_server_data $node_host_uuid = $node2_host_uuid; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node_host_uuid => $node_host_uuid }}); } - elsif (($drbd_node eq $dr1_host_name) or ($drbd_node eq $dr1_short_host_name)) - { - $node_host_uuid = $dr1_host_uuid; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { node_host_uuid => $node_host_uuid }}); - } # How big is this LV? my $backing_lv = $anvil->data->{server_data}{$server_name}{server_uuid}{$server_uuid}{disk}{$resource}{$volume}{node}{$drbd_node}{backing_lv};