Added '--list' to anvil-manage-dr

* Updated Database->get_hosts() to store hosts in a host_type hash.
* Updated Database->get_servers() to store servers by name, regardless
  of host Anvil! node.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent d9aa8aee74
commit ef0f04117f
  1. 12
      Anvil/Tools/Database.pm
  2. 8
      man/anvil-manage-dr.8
  3. 16
      share/words.xml
  4. 4
      tools/anvil-manage-alerts
  5. 115
      tools/anvil-manage-dr

@ -4203,6 +4203,14 @@ WHERE
"sys::hosts::by_uuid::${host_uuid}" => $anvil->data->{sys}{hosts}{by_uuid}{$host_uuid},
"sys::hosts::by_name::${host_name}" => $anvil->data->{sys}{hosts}{by_name}{$host_name},
}});
# Record hosts by type.
$anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}{$host_name}{host_uuid} = $host_uuid;
$anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}{$host_name}{short_host_name} = $short_host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::hosts::by_type::${host_type}::host_name::${host_name}::host_uuid" => $anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}{$host_name}{host_uuid},
"sys::hosts::by_type::${host_type}::host_name::${host_name}::short_host_name" => $anvil->data->{sys}{hosts}{by_type}{$host_type}{host_name}{$host_name}{short_host_name},
}});
}
my $return_count = @{$return};
@ -5898,10 +5906,12 @@ WHERE
"servers::server_uuid::${server_uuid}::server_definition_xml" => $anvil->data->{servers}{server_uuid}{$server_uuid}{server_definition_xml},
}});
# Store the servers in a hash under each Anvil!, sortable.
# Store the servers in a hash by name and under each Anvil!, sortable.
$anvil->data->{servers}{anvil_uuid}{$server_anvil_uuid}{server_name}{$server_name}{server_uuid} = $server_uuid;
$anvil->data->{servers}{server_name}{$server_name}{server_uuid} = $server_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"servers::anvil_uuid::${server_anvil_uuid}::server_name::${server_name}::server_uuid" => $anvil->data->{servers}{anvil_uuid}{$server_anvil_uuid}{server_name}{$server_name}{server_uuid},
"servers::server_name::${server_name}::server_uuid" => $anvil->data->{servers}{server_name}{$server_name}{server_uuid},
}});
}

@ -21,6 +21,9 @@ When logging, record sensitive data, like passwords.
Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a significant amount of log data.
.SS "Commands:"
.TP
\fB\-\-anvil\fR
When linking or unlinking a DR host to an Anvil! node, this switch indicates the Anvil! being linked or unlinked to.
.TP
\fB\-\-connect\fR
Connect a server already on DR to it's DR copy, update the data there if needed and begin streaming replication.
.TP
@ -28,7 +31,7 @@ Connect a server already on DR to it's DR copy, update the data there if needed
Disconnect a server from the DR image. This will end streaming replication.
.TP
\fB\-\-dr\-host\fR
This is the host name or host UUID for the DR to use. It is optional if only one DR host is connected to this Anvil! node, but required if two or more are defined.
This is the host name or host UUID for the DR to use. It is optional if only one DR host is connected to this Anvil! node, but required if two or more are defined. It is also use when linking or unlinking DR hosts to Anvil! nodes.
.TP
\fB\-\-license\-file\fR
This is the path to the license file, needed when setting up "long-throw" DR for the first time.
@ -36,6 +39,9 @@ This is the path to the license file, needed when setting up "long-throw" DR for
\fB\-\-link\fR
This takes an --anvil and a --dr-host to enable using the DR host as a target for the Anvil! node.
.TP
\fB\-\-list\fR
This will show the list of available Anvil! nodes, DR hosts and servers.
.TP
\fB\-\-protect\fR
The sets up the server to be imaged on DR, if it isn't already protected.
.TP

@ -1129,7 +1129,7 @@ resource #!variable!server!# {
<key name="header_0078">#!free!#</key>
<key name="header_0079">Used</key>
<key name="header_0080">Free</key>
<key name="header_0081">Anvil! Node</key>
<key name="header_0081">Anvil! Nodes</key>
<key name="header_0082">Interface</key>
<key name="header_0083">Gateway (*DG)</key>
<key name="header_0084">Transmitted</key>
@ -1149,7 +1149,7 @@ resource #!variable!server!# {
<key name="header_0098">Recipient UUID</key>
<key name="header_0099">Alert Overrides</key>
<key name="header_0100">Recipient</key>
<key name="header_0101">Anvil! Node</key>
<key name="header_0101">-=] Anvil! Node</key>
<key name="header_0102">Alert Override UUID</key>
<key name="header_0103">Host Type</key>
<key name="header_0104">Host UUID</key>
@ -1163,6 +1163,8 @@ resource #!variable!server!# {
<key name="header_0112">Queued Jobs</key>
<key name="header_0113">Jobs In Progress</key>
<key name="header_0114">Completed Jobs</key>
<key name="header_0115">-=] DR Hosts</key>
<key name="header_0116">-=] Servers</key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -3226,6 +3228,14 @@ proceeding.
<key name="message_0362">Bad SSH key target: [#!variable!target!#], file:line with the bad entry: [#!variable!file!#:#!variable!line!#].</key>
<key name="message_0363">[ Warning ] - Only proceed if you know the target has been rebuily!
- Do you want to remove these bad keys? [y/N]</key>
<key name="message_0364">- Node Name: [#!variable!anvil_name!#], Description: [#!variable!description!#]</key>
<key name="message_0365"> - Linked: [#!variable!host_name!#], link UUID: [#!variable!link_uuid!#]</key>
<key name="message_0366"> - No linked DR hosts yet.</key>
<key name="message_0367">- No Anvil! nodes exist yet.</key>
<key name="message_0368">- Name: [#!variable!host_name!#]</key>
<key name="message_0369">- No DR hosts exist yet</key>
<key name="message_0370">- Server name: [#!variable!server_name!#] on Anvil! Node: [#!variable!anvil_name!#]</key>
<key name="message_0371">- No servers yet installed</key>
<!-- Translate names (protocols, etc) -->
<key name="name_0001">Normal Password</key> <!-- none in mail-server -->
@ -3576,7 +3586,7 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0303">This indicates when, in unix time, the database was last archived.</key>
<key name="striker_0304">This indicates when, in unix time, the local install target data was updated.</key>
<key name="striker_0305">This indicates when, in unix time, the OUI data was last update. The OUI data is a list of MAC address prefixes and which companies they've been assigned to.</key>
<key name="striker_0306">This indicates when, in unix time, the network was last scanned. This is done to determine what IPs are used by servers on the Anvil! cluster, and to try to identify foundation pack devices on the network. These scans are simple ping sweeps used to get the MAC addresses of devices with IPs.</key>
<key name="striker_0306">This indicates when, in unix time, the network was last scanned. This is done to determine what IPs are used by servers on the Anvil! node, and to try to identify foundation pack devices on the network. These scans are simple ping sweeps used to get the MAC addresses of devices with IPs.</key>
<!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key>

@ -827,7 +827,7 @@ sub show_existing
$anvil->data->{longest}{recipient_uuid} = length($anvil->Words->string({key => "header_0098"}));
$anvil->data->{longest}{alert_override_recipient_name} = length($anvil->Words->string({key => "header_0100"}));
$anvil->data->{longest}{alert_override_host_name} = length($anvil->Words->string({key => "header_0026"}));
$anvil->data->{longest}{alert_override_anvil_name} = length($anvil->Words->string({key => "header_0101"}));
$anvil->data->{longest}{alert_override_anvil_name} = length($anvil->Words->string({key => "header_0081"}));
$anvil->data->{longest}{alert_override_alert_level} = length($anvil->Words->string({key => "header_0096"}));
$anvil->data->{longest}{alert_override_uuid} = length($anvil->Words->string({key => "header_0102"}));
$anvil->data->{longest}{host_name} = length($anvil->Words->string({key => "header_0026"}));
@ -1333,7 +1333,7 @@ sub show_existing
my $header_line = "| ".sprintf("%-${longest_alert_override_recipient_name}s", $anvil->Words->string({key => "header_0100"}))." ";
$header_line .= "| ".sprintf("%-${longest_alert_override_host_name}s", $anvil->Words->string({key => "header_0026"}))." ";
$header_line .= "| ".sprintf("%-${longest_alert_override_anvil_name}s", $anvil->Words->string({key => "header_0101"}))." ";
$header_line .= "| ".sprintf("%-${longest_alert_override_anvil_name}s", $anvil->Words->string({key => "header_0081"}))." ";
$header_line .= "| ".sprintf("%-${longest_alert_override_alert_level}s", $anvil->Words->string({key => "header_0096"}))." ";
$header_line .= "| ".sprintf("%-${longest_alert_override_uuid}s", $anvil->Words->string({key => "header_0102"}))." |";

@ -42,6 +42,7 @@ $anvil->Get->switches({list => [
"job-uuid",
"license-file",
"link",
"list",
"protect",
"protocol",
"remove",
@ -74,6 +75,11 @@ if ($anvil->data->{switches}{'job-uuid'})
{
load_job($anvil);
}
elsif ($anvil->data->{switches}{list})
{
# If '--list' was used, show all Nodes, DR hosts and servers.
show_list($anvil);
}
my $terminal = "";
if (not $anvil->data->{switches}{'job-uuid'})
@ -98,6 +104,115 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub show_list
{
my ($anvil) = @_;
# Show Anvil! nodes
$anvil->Database->get_hosts();
$anvil->Database->get_storage_group_data({debug => 2});
$anvil->Database->get_dr_links({debug => 2});
$anvil->Database->get_servers();
# Show Anvil! nodes.
print $anvil->Words->string({key => "header_0081"})."\n";
my $anvil_count = keys %{$anvil->data->{anvils}{anvil_name}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_count => $anvil_count }});
if ($anvil_count)
{
foreach my $anvil_name (sort {$a cmp $b} keys %{$anvil->data->{anvils}{anvil_name}})
{
my $anvil_uuid = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_uuid};
my $anvil_description = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_description};
my $dr_link_count = keys %{$anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid}{dr_link_host_name}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
anvil_name => $anvil_name,
anvil_uuid => $anvil_uuid,
anvil_description => $anvil_description,
dr_link_count => $dr_link_count,
}});
print $anvil->Words->string({key => "message_0364", variables => {
anvil_name => $anvil_name,
description => $anvil_description,
}})."\n";
if ($dr_link_count)
{
foreach my $dr_link_host_name (sort {$a cmp $b} keys %{$anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid}{dr_link_host_name}})
{
my $dr_link_uuid = $anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid}{dr_link_host_name}{$dr_link_host_name}{dr_link_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
dr_link_host_name => $dr_link_host_name,
dr_link_uuid => $dr_link_uuid,
}});
print $anvil->Words->string({key => "message_0365", variables => {
host_name => $dr_link_host_name,
link_uuid => $dr_link_uuid,
}})."\n";
}
}
else
{
# No DR hosts yet
print $anvil->Words->string({key => "message_0366"})."\n";
}
}
}
else
{
# No nodes yet
print $anvil->Words->string({key => "message_0367"})."\n";
}
# DR Hosts
print "\n".$anvil->Words->string({key => "header_0115"})."\n";
my $dr_host_count = keys %{$anvil->data->{sys}{hosts}{by_type}{dr}{host_name}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dr_host_count => $dr_host_count }});
if ($dr_host_count)
{
# TODO: Show free space of VGs, available RAM and CPU core count and type/speed
foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{sys}{hosts}{by_type}{dr}{host_name}})
{
print $anvil->Words->string({key => "message_0368", variables => { host_name => $host_name }})."\n";
}
}
else
{
# No DR hosts yet
print $anvil->Words->string({key => "message_0366"})."\n";
}
# DR Hosts
print "\n".$anvil->Words->string({key => "header_0116"})."\n";
my $server_count = keys %{$anvil->data->{servers}{server_uuid}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_count => $server_count }});
if ($server_count)
{
# If there's servers, there has to be Anvil! nodes.
foreach my $anvil_name (sort {$a cmp $b} keys %{$anvil->data->{anvils}{anvil_name}})
{
# TODO: Show each server's disk(s) size, RAM and CPU core count
my $anvil_uuid = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_uuid};
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_name = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_name};
print $anvil->Words->string({key => "message_0370", variables => {
server_name => $server_name,
anvil_name => $anvil_name,
}})."\n";
}
}
}
else
{
# No servers yet exist
print $anvil->Words->string({key => "message_0371"})."\n";
}
$anvil->nice_exit({exit_code => 0});
return(0);
}
sub handle_links
{
my ($anvil) = @_;

Loading…
Cancel
Save