Merge pull request #127 from ClusterLabs/anvil-tools-dev

Anvil tools dev
main
digimer-bot 4 years ago committed by GitHub
commit 155c46e111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Anvil/Tools/Network.pm
  2. 178
      scancore-agents/scan-lvm/scan-lvm
  3. 4
      scancore-agents/scan-lvm/scan-lvm.sql
  4. 2
      scancore-agents/scan-lvm/scan-lvm.xml
  5. 1
      share/words.xml
  6. 18
      tools/anvil-configure-host

@ -1690,10 +1690,10 @@ sub get_ips
# address from there. If not, read the MAC address from
# '/sys/class/net/<nic>/address'.
my $shell_call = 'IFACE='.$in_iface.'
if [ -e "$IFACE" ];
if [ -e "/sys/class/net/${IFACE}/bridge" ];
then
echo bridge;
elif [ -e "/proc/net/bonding/$IFACE" ];
elif [ -e "/proc/net/bonding/${IFACE}" ];
then
echo bond;
elif [ -e "/sys/class/net/${IFACE}/bonding_slave/perm_hwaddr" ];

@ -639,36 +639,40 @@ sub find_changes_in_pvs
foreach my $scan_lvm_pv_internal_uuid (keys %{$anvil->data->{lvm}{scan_lvm_pv_internal_uuid}})
{
my $scan_lvm_pv_name = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{name};
my $scan_lvm_pv_used_by_vg = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{used_by_vg};
my $scan_lvm_pv_attributes = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{attributes};
my $scan_lvm_pv_size = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{size};
my $scan_lvm_pv_free = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{free_space};
my $scan_lvm_pv_name = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{name};
my $scan_lvm_pv_used_by_vg = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{used_by_vg};
my $scan_lvm_pv_attributes = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{attributes};
my $scan_lvm_pv_size = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{size};
my $scan_lvm_pv_free = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{free_space};
my $scan_lvm_pv_sector_size = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{sector_size};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
scan_lvm_pv_internal_uuid => $scan_lvm_pv_internal_uuid,
scan_lvm_pv_name => $scan_lvm_pv_name,
scan_lvm_pv_used_by_vg => $scan_lvm_pv_used_by_vg,
scan_lvm_pv_attributes => $scan_lvm_pv_attributes,
scan_lvm_pv_size => $anvil->Convert->add_commas({number => $scan_lvm_pv_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_size}),
scan_lvm_pv_free => $anvil->Convert->add_commas({number => $scan_lvm_pv_free})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_free}),
scan_lvm_pv_name => $scan_lvm_pv_name,
scan_lvm_pv_used_by_vg => $scan_lvm_pv_used_by_vg,
scan_lvm_pv_attributes => $scan_lvm_pv_attributes,
scan_lvm_pv_size => $anvil->Convert->add_commas({number => $scan_lvm_pv_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_size}),
scan_lvm_pv_free => $anvil->Convert->add_commas({number => $scan_lvm_pv_free})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_free}),
scan_lvm_pv_sector_size => $anvil->Convert->add_commas({number => $scan_lvm_pv_sector_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_sector_size}),
}});
# Have we seen this before?
if (exists $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid})
{
# Yup, anything changed?
my $scan_lvm_pv_uuid = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid};
my $old_scan_lvm_pv_name = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name};
my $old_scan_lvm_pv_used_by_vg = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg};
my $old_scan_lvm_pv_attributes = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes};
my $old_scan_lvm_pv_size = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size};
my $old_scan_lvm_pv_free = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free};
my $scan_lvm_pv_uuid = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid};
my $old_scan_lvm_pv_name = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name};
my $old_scan_lvm_pv_used_by_vg = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg};
my $old_scan_lvm_pv_attributes = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes};
my $old_scan_lvm_pv_size = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size};
my $old_scan_lvm_pv_free = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free};
my $old_scan_lvm_pv_sector_size = $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_sector_size};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
old_scan_lvm_pv_name => $old_scan_lvm_pv_name,
old_scan_lvm_pv_used_by_vg => $old_scan_lvm_pv_used_by_vg,
old_scan_lvm_pv_attributes => $old_scan_lvm_pv_attributes,
old_scan_lvm_pv_size => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_size}),
old_scan_lvm_pv_free => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_free})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_free}),
old_scan_lvm_pv_name => $old_scan_lvm_pv_name,
old_scan_lvm_pv_used_by_vg => $old_scan_lvm_pv_used_by_vg,
old_scan_lvm_pv_attributes => $old_scan_lvm_pv_attributes,
old_scan_lvm_pv_size => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_size}),
old_scan_lvm_pv_free => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_free})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_free}),
old_scan_lvm_pv_sector_size => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_sector_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_sector_size}),
}});
my $update = 0;
@ -793,6 +797,22 @@ sub find_changes_in_pvs
$anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0010", variables => $variables, set_by => $THIS_FILE});
}
}
if ($scan_lvm_pv_sector_size ne $old_scan_lvm_pv_sector_size)
{
# This is always a warning as the sector size should never change.
$update = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }});
my $variables = {
pv_uuid => $scan_lvm_pv_internal_uuid,
pv_name => $scan_lvm_pv_name,
new_pv_sector_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_sector_size}),
new_pv_sector_size_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_sector_size}),
old_pv_sector_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $old_scan_lvm_pv_sector_size}),
old_pv_sector_size_bytes => $anvil->Convert->add_commas({number => $old_scan_lvm_pv_sector_size}),
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0032", variables => $variables});
$anvil->Alert->register({alert_level => "warning", message => "scan_lvm_alert_0032", variables => $variables, set_by => $THIS_FILE});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update => $update }});
if ($update)
@ -801,14 +821,15 @@ sub find_changes_in_pvs
UPDATE
scan_lvm_pvs
SET
scan_lvm_pv_name = ".$anvil->Database->quote($scan_lvm_pv_name).",
scan_lvm_pv_used_by_vg = ".$anvil->Database->quote($scan_lvm_pv_used_by_vg).",
scan_lvm_pv_attributes = ".$anvil->Database->quote($scan_lvm_pv_attributes).",
scan_lvm_pv_size = ".$anvil->Database->quote($scan_lvm_pv_size).",
scan_lvm_pv_free = ".$anvil->Database->quote($scan_lvm_pv_free).",
modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
scan_lvm_pv_name = ".$anvil->Database->quote($scan_lvm_pv_name).",
scan_lvm_pv_used_by_vg = ".$anvil->Database->quote($scan_lvm_pv_used_by_vg).",
scan_lvm_pv_attributes = ".$anvil->Database->quote($scan_lvm_pv_attributes).",
scan_lvm_pv_size = ".$anvil->Database->quote($scan_lvm_pv_size).",
scan_lvm_pv_free = ".$anvil->Database->quote($scan_lvm_pv_free).",
scan_lvm_pv_sector_size = ".$anvil->Database->quote($scan_lvm_pv_sector_size).",
modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
WHERE
scan_lvm_pv_uuid = ".$anvil->Database->quote($scan_lvm_pv_uuid)."
scan_lvm_pv_uuid = ".$anvil->Database->quote($scan_lvm_pv_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
@ -821,14 +842,16 @@ WHERE
{
# New PV
my $variables = {
pv_uuid => $scan_lvm_pv_internal_uuid,
pv_name => $scan_lvm_pv_name,
vg_name => $scan_lvm_pv_used_by_vg ? $scan_lvm_pv_used_by_vg : "--",
attributes => $scan_lvm_pv_attributes,
pv_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_size}),
pv_size_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_size}),
pv_free => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_free}),
pv_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_free}),
pv_uuid => $scan_lvm_pv_internal_uuid,
pv_name => $scan_lvm_pv_name,
vg_name => $scan_lvm_pv_used_by_vg ? $scan_lvm_pv_used_by_vg : "--",
attributes => $scan_lvm_pv_attributes,
pv_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_size}),
pv_size_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_size}),
pv_free => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_free}),
pv_free_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_free}),
pv_sector_size => $anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_sector_size}),
pv_sector_size_bytes => $anvil->Convert->add_commas({number => $scan_lvm_pv_sector_size}),
};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_lvm_alert_0019", variables => $variables});
$anvil->Alert->register({alert_level => "notice", message => "scan_lvm_alert_0019", variables => $variables, set_by => $THIS_FILE});
@ -846,6 +869,7 @@ INSERT INTO
scan_lvm_pv_attributes,
scan_lvm_pv_size,
scan_lvm_pv_free,
scan_lvm_pv_sector_size,
modified_date
) VALUES (
".$anvil->Database->quote($scan_lvm_pv_uuid).",
@ -856,6 +880,7 @@ INSERT INTO
".$anvil->Database->quote($scan_lvm_pv_attributes).",
".$anvil->Database->quote($scan_lvm_pv_size).",
".$anvil->Database->quote($scan_lvm_pv_free).",
".$anvil->Database->quote($scan_lvm_pv_sector_size).",
".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
);";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
@ -915,7 +940,8 @@ SELECT
scan_lvm_pv_used_by_vg,
scan_lvm_pv_attributes,
scan_lvm_pv_size,
scan_lvm_pv_free
scan_lvm_pv_free,
scan_lvm_pv_sector_size
FROM
scan_lvm_pvs
WHERE
@ -933,21 +959,23 @@ WHERE
{
# We've got an entry in the 'scan_lvm_pv' table, so now we'll look for data in the node and
# services tables.
my $scan_lvm_pv_internal_uuid = $row->[1];
my $scan_lvm_pv_name = $row->[2];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid} = $row->[0];;
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name} = $scan_lvm_pv_name;
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg} = $row->[3];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes} = $row->[4];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size} = $row->[5];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free} = $row->[6];
my $scan_lvm_pv_internal_uuid = $row->[1];
my $scan_lvm_pv_name = $row->[2];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid} = $row->[0];;
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name} = $scan_lvm_pv_name;
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg} = $row->[3];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes} = $row->[4];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size} = $row->[5];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free} = $row->[6];
$anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_sector_size} = $row->[7];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_uuid" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_name" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_used_by_vg" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_attributes" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_size" => $anvil->Convert->add_commas({number => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size}}),
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_free" => $anvil->Convert->add_commas({number => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free}}),
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_uuid" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_uuid},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_name" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_name},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_used_by_vg" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_used_by_vg},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_attributes" => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_attributes},
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_size" => $anvil->Convert->add_commas({number => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_size}}),
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_free" => $anvil->Convert->add_commas({number => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_free}}),
"sql::scan_lvm_pvs::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::scan_lvm_pv_sector_size" => $anvil->Convert->add_commas({number => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_sector_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{sql}{scan_lvm_pvs}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{scan_lvm_pv_sector_size}}),
}});
}
undef $count;
@ -1077,7 +1105,7 @@ sub collect_pvs_data
my $pvs_data = $json->decode($output);
foreach my $hash_ref (@{$pvs_data->{report}->[0]->{pv}})
{
my $scan_lvm_pv_internal_uuid = $hash_ref->{pv_uuid};
my $scan_lvm_pv_internal_uuid = $hash_ref->{pv_uuid};
$anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{name} = $hash_ref->{pv_name};
$anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{used_by_vg} = $hash_ref->{vg_name};
$anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{attributes} = $hash_ref->{pv_attr}; # TODO: Parse this out
@ -1090,6 +1118,52 @@ sub collect_pvs_data
"lvm::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{size}}).")",
"lvm::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::free_space" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{free_space}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{free_space}}).")",
}});
# We need to find the sector size of this PV.
my $partition = $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{name};
$partition =~ s/^.*\///;
my $directory = "/sys/class/block/".$partition."/subsystem";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
partition => $partition,
directory => $directory,
}});
# Look for the parent device. For partitions like 'sda1', this is 'sda'. For 'nvmen0p1', this is 'nvmen0', etc.
my $sector_size = 0;
until ($sector_size)
{
chop $partition;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { partition => $partition }});
if (not $partition)
{
# Weird... Default to 512.
$sector_size = 512;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sector_size => $sector_size }});
die;
}
my $sector_size_file = $directory."/".$partition."/queue/hw_sector_size";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sector_size_file => $sector_size_file }});
if (-e $sector_size_file)
{
$sector_size = $anvil->Storage->read_file({file => $sector_size_file });
chomp $sector_size;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sector_size => $sector_size }});
if ((not $sector_size) or ($sector_size =~ /\D/))
{
# Something went wrong, default to 512.
$sector_size = 512;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sector_size => $sector_size }});
die;
}
}
}
$anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{sector_size} = $sector_size;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"lvm::scan_lvm_pv_internal_uuid::${scan_lvm_pv_internal_uuid}::sector_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{sector_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{scan_lvm_pv_internal_uuid}{$scan_lvm_pv_internal_uuid}{sector_size}}).")",
}});
}
return(0);

@ -11,6 +11,7 @@ CREATE TABLE scan_lvm_pvs (
scan_lvm_pv_attributes text not null, -- This is the short 3-character attribute of the PV
scan_lvm_pv_size numeric not null, -- The size of the PV in bytes
scan_lvm_pv_free numeric not null, -- The free space, in bytes.
scan_lvm_pv_sector_size numeric not null, -- This is the size of the sectors on this disk. Genreally it is 512 or 4096. This is important for calculating how much space to add to LVs built on this PV.
modified_date timestamp with time zone not null,
FOREIGN KEY(scan_lvm_pv_host_uuid) REFERENCES hosts(host_uuid)
@ -27,6 +28,7 @@ CREATE TABLE history.scan_lvm_pvs (
scan_lvm_pv_attributes text,
scan_lvm_pv_size numeric,
scan_lvm_pv_free numeric,
scan_lvm_pv_sector_size numeric,
modified_date timestamp with time zone not null
);
ALTER TABLE history.scan_lvm_pvs OWNER TO admin;
@ -46,6 +48,7 @@ BEGIN
scan_lvm_pv_attributes,
scan_lvm_pv_size,
scan_lvm_pv_free,
scan_lvm_pv_sector_size,
modified_date)
VALUES
(history_scan_lvm_pvs.scan_lvm_pv_uuid,
@ -56,6 +59,7 @@ BEGIN
history_scan_lvm_pvs.scan_lvm_pv_attributes,
history_scan_lvm_pvs.scan_lvm_pv_size,
history_scan_lvm_pvs.scan_lvm_pv_free,
history_scan_lvm_pvs.scan_lvm_pv_sector_size,
history_scan_lvm_pvs.modified_date);
RETURN NULL;
END;

@ -54,6 +54,7 @@ Assigned to VG: [#!variable!vg_name!#]
Attribute bits: [#!variable!attributes!#]
PV Size: ...... [#!variable!pv_size!#] (#!variable!pv_size_bytes!# bytes)
Free Space: ... [#!variable!pv_free!#] (#!variable!pv_free_bytes!# bytes)
Sector Size: .. [#!variable!pv_sector_size!#] (#!variable!pv_sector_size_bytes!# bytes)
====
The attribute bits are:
1 - (d)uplicate, (a)llocatable, (u)sed
@ -218,6 +219,7 @@ The attribute bits are:
</key>
<key name="scan_lvm_alert_0030">The volume group: [#!variable!vg_name!#] (UUID: [#!variable!vg_uuid!#]) has vanished! If this is a removable device, like a USB drive, this is OK. Otherwise, it could be the sign of a disk failure.</key>
<key name="scan_lvm_alert_0031">The logical volume: [#!variable!lv_name!#] (UUID: [#!variable!lv_uuid!#]) has been lost. This is normal if the LV is on a removable medium like a USB disk. Otherwise, it could be the sign of a disk failure.</key>
<key name="scan_lvm_alert_0032">The physical volume: [#!variable!pv_name!#] (UUID: [#!variable!pv_uuid!#]) sector size changed from: [#!variable!old_pv_sector_size!#] (#!variable!old_pv_sector_size_bytes!# bytes) to: [#!variable!new_pv_sector_size!#] (#!variable!new_pv_sector_size_bytes!# bytes). This should not happen, unless the storage behind the PV was somehow rebuilt without recreating the LVM metadata.</key>
<!-- Log entries -->
<key name="scan_lvm_log_0001">Starting: [#!variable!program!#].</key>

@ -1816,6 +1816,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
#!variable!difference!#
====
</key>
<key name="log_0626">This system will reboot in: [#!variable!seconds!#] seconds...</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

@ -91,7 +91,16 @@ $anvil->Job->update_progress({
$anvil->System->maintenance_mode({set => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, secure => 0, key => "log_0467"});
### TODO: As of now, the network doesn't come up reliably, so reboot.
### TODO: As of now, the network doesn't come up reliably, so reboot. We add a 60 second delay to make it
### easier to log in and disable anvil-daemon in case of reboot loops caused by this program thinking
### it needs to reconfigure the system every run.
my $time_left = 60;
while ($time_left)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, secure => 0, key => "log_0626", variables => { seconds => $time_left }});
sleep 10;
$time_left -= 10;
}
my $shell_call = $anvil->data->{path}{exe}{systemctl}." reboot";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});
@ -1215,9 +1224,10 @@ AND
# If we're in a cluster, abort.
if (-e $anvil->data->{path}{exe}{pcs})
{
my ($problem) = $anvil->Cluster->parse_cib();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }});
if ((not $problem) && ($anvil->data->{cib}{parsed}{'local'}{ready}))
# To make logs more sensible, we'll call 'problem' as 'out_of_cluster'.
my ($out_of_cluster) = $anvil->Cluster->parse_cib();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { out_of_cluster => $out_of_cluster }});
if ((not $out_of_cluster) && ($anvil->data->{cib}{parsed}{'local'}{ready}))
{
# We're in a cluster, abort.
$anvil->Job->update_progress({

Loading…
Cancel
Save