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

Anvil tools dev
main
Digimer 2 years ago committed by GitHub
commit e49145efe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 163
      Anvil/Tools/DRBD.pm
  2. 591
      Anvil/Tools/Database.pm
  3. 48
      Anvil/Tools/Get.pm
  4. 4
      man/anvil-manage-dr.8
  5. 61
      man/anvil-manage-storage-groups.8
  6. 1
      notes
  7. 301
      tools/anvil-manage-server-storage

@ -2405,86 +2405,12 @@ sub parse_resource
}
else
{
if (not exists $anvil->data->{lvm}{host_name})
{
$anvil->Database->get_lvm_data({debug => $debug});
}
# Successful parse!
=cut
<resource name="srv01-fs37" conf-file-line="/etc/drbd.d/srv01-fs37.res:2">
<host name="vm-a01n01">
<volume vnr="0">
<device minor="0">/dev/drbd_srv01-fs37_0</device>
<disk>/dev/cs_vm-a01n01/srv01-fs37_0</disk>
<meta-disk>internal</meta-disk>
</volume>
<volume vnr="1">
<device minor="1">/dev/drbd_srv01-fs37_1</device>
<disk>/dev/cs_vm-a01n01/srv01-fs37_1</disk>
<meta-disk>internal</meta-disk>
</volume>
<address family="(null)" port="(null)">(null)</address>
</host>
<host name="vm-a01n02">
<volume vnr="0">
<device minor="0">/dev/drbd_srv01-fs37_0</device>
<disk>/dev/cs_vm-a01n02/srv01-fs37_0</disk>
<meta-disk>internal</meta-disk>
</volume>
<volume vnr="1">
<device minor="1">/dev/drbd_srv01-fs37_1</device>
<disk>/dev/cs_vm-a01n02/srv01-fs37_1</disk>
<meta-disk>internal</meta-disk>
</volume>
<address family="(null)" port="(null)">(null)</address>
</host>
<host name="vm-a01dr01">
<volume vnr="0">
<device minor="0">/dev/drbd_srv01-fs37_0</device>
<disk>/dev/cs_vm-a01dr01/srv01-fs37_0</disk>
<meta-disk>internal</meta-disk>
</volume>
<volume vnr="1">
<device minor="1">/dev/drbd_srv01-fs37_1</device>
<disk>/dev/cs_vm-a01dr01/srv01-fs37_1</disk>
<meta-disk>internal</meta-disk>
</volume>
<address family="(null)" port="(null)">(null)</address>
</host>
<connection>
<host name="vm-a01n01"><address family="ipv4" port="7788">10.101.10.1</address></host>
<host name="vm-a01n02"><address family="ipv4" port="7788">10.101.10.2</address></host>
<section name="net">
<option name="protocol" value="C"/>
<option name="verify-alg" value="md5"/>
<option name="fencing" value="resource-and-stonith"/>
</section>
<section name="disk">
<option name="c-max-rate" value="500M"/>
</section>
</connection>
<connection>
<host name="vm-a01n01"><address family="ipv4" port="7789">10.201.10.1</address></host>
<host name="vm-a01dr01"><address family="ipv4" port="7789">10.201.10.3</address></host>
<section name="net">
<option name="protocol" value="A"/>
<option name="verify-alg" value="md5"/>
<option name="fencing" value="dont-care"/>
</section>
<section name="disk">
<option name="c-max-rate" value="500M"/>
</section>
</connection>
<connection>
<host name="vm-a01n02"><address family="ipv4" port="7790">10.201.10.2</address></host>
<host name="vm-a01dr01"><address family="ipv4" port="7790">10.201.10.3</address></host>
<section name="net">
<option name="protocol" value="A"/>
<option name="verify-alg" value="md5"/>
<option name="fencing" value="dont-care"/>
</section>
<section name="disk">
<option name="c-max-rate" value="500M"/>
</section>
</connection>
</resource>
=cut
foreach my $name ($dom->findnodes('/resource'))
{
my $resource = $name->{name};
@ -2505,22 +2431,77 @@ sub parse_resource
's2:meta_disk' => $meta_disk,
}});
my $host_uuid = $anvil->Get->host_uuid_from_name({host_name => $this_host_name});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_uuid => $host_uuid }});
my $host_uuid = $anvil->Get->host_uuid_from_name({host_name => $this_host_name});
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$host_uuid}{short_host_name};
my $backing_disk = $volume_vnr->findvalue('./disk');
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_uuid => $host_uuid,
short_host_name => $short_host_name,
backing_disk => $backing_disk,
}});
$anvil->data->{new}{resource}{$resource}{host_name}{$this_host_name}{host_uuid} = $host_uuid;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_path} = $volume_vnr->findvalue('./device');
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{backing_disk} = $volume_vnr->findvalue('./disk');
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_minor} = $volume_vnr->findvalue('./device/@minor');
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{meta_disk} = $meta_disk;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{size} = 0;
$anvil->data->{new}{resource}{$resource}{host_name}{$this_host_name}{host_uuid} = $host_uuid;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_path} = $volume_vnr->findvalue('./device');
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{backing_disk} = $backing_disk;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_minor} = $volume_vnr->findvalue('./device/@minor');
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{meta_disk} = $meta_disk;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{size} = 0;
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{storage_group_uuid} = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:new::resource::${resource}::host_name::${this_host_name}::host_uuid" => $anvil->data->{new}{resource}{$resource}{host_name}{$this_host_name}{host_uuid},
"s2:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::device_path" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_path},
"s3:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::backing_disk" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{backing_disk},
"s4:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::device_minor" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_minor},
"s5:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::meta_disk" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{meta_disk},
"s2:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::device_path" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_path},
"s3:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::backing_disk" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{backing_disk},
"s4:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::device_minor" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{device_minor},
"s5:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::meta_disk" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{meta_disk},
"s6:new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::storage_group_uuid" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{storage_group_uuid},
}});
# What Storage Group is this in?
foreach my $this_scan_lvm_lv_name (sort {$a cmp $b} keys %{$anvil->data->{lvm}{host_name}{$short_host_name}{lv}})
{
my $this_scan_lvm_lv_path = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_path};
my $this_scan_lvm_lv_on_vg = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_on_vg};
my $this_scan_lvm_lv_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:this_scan_lvm_lv_name' => $this_scan_lvm_lv_name,
's2:this_scan_lvm_lv_path' => $this_scan_lvm_lv_path,
's3:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
's4:this_scan_lvm_lv_uuid' => $this_scan_lvm_lv_uuid,
}});
if ($anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{backing_disk} eq $this_scan_lvm_lv_path)
{
# While we're here, make it easy to go from LV -> DRBD resource and volume.
$anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$backing_disk}{drbd}{resource} = $resource;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$backing_disk}{drbd}{volume} = $volume;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:lvm::host_name::${short_host_name}::lv_path::${backing_disk}::drbd::resource" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$backing_disk}{drbd}{resource},
"s2:lvm::host_name::${short_host_name}::lv_path::${backing_disk}::drbd::volume" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$backing_disk}{drbd}{volume},
}});
# What's the VG's UUID?
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
}});
if (exists $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg})
{
my $scan_lvm_vg_internal_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg}{scan_lvm_vg_internal_uuid};
my $storage_group_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg}{storage_group_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:scan_lvm_vg_internal_uuid' => $scan_lvm_vg_internal_uuid,
's2:storage_group_uuid' => $storage_group_uuid,
}});
if ($storage_group_uuid)
{
$anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{storage_group_uuid} = $storage_group_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"new::resource::${resource}::host_uuid::${host_uuid}::volume_number::${volume}::storage_group_uuid" => $anvil->data->{new}{resource}{$resource}{host_uuid}{$host_uuid}{volume_number}{$volume}{storage_group_uuid},
}});
}
}
}
}
}
}
foreach my $connection ($name->findnodes('./connection'))

@ -31,6 +31,7 @@ my $THIS_FILE = "Database.pm";
# get_anvils
# get_bridges
# get_dr_links
# get_drbd_data
# get_fences
# get_file_locations
# get_files
@ -42,6 +43,7 @@ my $THIS_FILE = "Database.pm";
# get_job_details
# get_jobs
# get_local_uuid
# get_lvm_data
# get_mail_servers
# get_manifests
# get_recipients
@ -3061,6 +3063,313 @@ WHERE
}
=head2 get_drbd_data
This loads all of the LVM data into the following hashes;
* drbd::host_name::<short_host_name>::scan_drbd_uuid::<scan_drbd_uuid>::scan_drbd_common_xml
* drbd::host_name::<short_host_name>::scan_drbd_uuid::<scan_drbd_uuid>::scan_drbd_flush_disk
* drbd::host_name::<short_host_name>::scan_drbd_uuid::<scan_drbd_uuid>::scan_drbd_flush_md
* drbd::host_name::<short_host_name>::scan_drbd_uuid::<scan_drbd_uuid>::scan_drbd_timeout
* drbd::host_name::<short_host_name>::scan_drbd_uuid::<scan_drbd_uuid>::scan_drbd_total_sync_speed
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::resource_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::up
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::xml
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::volume_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::resource_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::device_path
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::device_minor
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::volume_size
* drbd::volume_uuid::<volume_uuid>::volume_number
* drbd::volume_uuid::<volume_uuid>::resource_name
* drbd::volume_uuid::<volume_uuid>::resource_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_host_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::volume_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::resource_uuid
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::connection_state
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::local_disk_state
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_disk_state
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::local_role
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_role
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::out_of_sync_size
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::replication_speed
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::estimated_time_to_sync
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_ip_address
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::peer_tcp_port
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::protocol
* drbd::host_name::<short_host_name>::resource_name::<resource_name>::volume::<volume_number>::peer_name::<peer_host_name>::fencing
For more information on what the data is that is stored in these hashes, please see C<< scan-drbd >>.
This method takes no parameters.
=cut
sub get_drbd_data
{
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 => "Database->get_drbd_data()" }});
if (not ref($anvil->data->{hosts}{host_uuid}) eq "HASH")
{
$anvil->Database->get_hosts({debug => $debug});
}
# This calls up the entry for this host. There will only be one.
my $query = "
SELECT
scan_drbd_uuid,
scan_drbd_host_uuid,
scan_drbd_common_xml,
scan_drbd_flush_disk,
scan_drbd_flush_md,
scan_drbd_timeout,
scan_drbd_total_sync_speed
FROM
scan_drbd
;";
$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,
}});
foreach my $row (@{$results})
{
# We've got an entry in the 'scan_drbd' table, so now we'll look for data in the node and
# services tables.
my $scan_drbd_uuid = $row->[0];
my $scan_drbd_host_uuid = $row->[1];
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_drbd_host_uuid}{short_host_name};
# Store the old data now.
$anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_common_xml} = $row->[2];
$anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_disk} = $row->[3];
$anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_md} = $row->[4];
$anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_timeout} = $row->[5];
$anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_total_sync_speed} = $row->[6];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"drbd::host_name::${short_host_name}::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_common_xml" => $anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_common_xml},
"drbd::host_name::${short_host_name}::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_flush_disk" => $anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_disk},
"drbd::host_name::${short_host_name}::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_flush_md" => $anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_flush_md},
"drbd::host_name::${short_host_name}::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_timeout" => $anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_timeout},
"drbd::host_name::${short_host_name}::scan_drbd_uuid::${scan_drbd_uuid}::scan_drbd_total_sync_speed" => $anvil->data->{drbd}{host_name}{$short_host_name}{scan_drbd_uuid}{$scan_drbd_uuid}{scan_drbd_total_sync_speed},
}});
}
undef $count;
undef $results;
# Read in the RAM module data.
$query = "
SELECT
scan_drbd_resource_uuid,
scan_drbd_resource_host_uuid,
scan_drbd_resource_name,
scan_drbd_resource_up,
scan_drbd_resource_xml
FROM
scan_drbd_resources
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
# We've got an entry in the 'scan_drbd_resources' table, so now we'll look for data in the node and
# services tables.
my $resource_uuid = $row->[0];
my $scan_drbd_resource_host_uuid = $row->[1];
my $scan_drbd_resource_name = $row->[2];
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_drbd_resource_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
resource_uuid => $resource_uuid,
scan_drbd_resource_host_uuid => $scan_drbd_resource_host_uuid,
scan_drbd_resource_name => $scan_drbd_resource_name,
short_host_name => $short_host_name,
}});
# Store the old data now.
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{resource_uuid} = $row->[0];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{up} = $row->[3];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{xml} = $row->[4];
$anvil->data->{drbd}{resource_uuid}{$resource_uuid}{resource_name} = $scan_drbd_resource_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:drbd::host_name::${short_host_name}::resource_name::${scan_drbd_resource_name}::resource_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{resource_uuid},
"s2:drbd::host_name::${short_host_name}::resource_name::${scan_drbd_resource_name}::up" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{up},
"s3:drbd::host_name::${short_host_name}::resource_name::${scan_drbd_resource_name}::xml" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$scan_drbd_resource_name}{xml},
"s4:drbd::resource_uuid::${resource_uuid}::resource_name" => $anvil->data->{drbd}{resource_uuid}{$resource_uuid}{resource_name},
}});
}
undef $count;
undef $results;
# Read in the RAM module data.
$query = "
SELECT
scan_drbd_volume_uuid,
scan_drbd_volume_host_uuid,
scan_drbd_volume_scan_drbd_resource_uuid,
scan_drbd_volume_number,
scan_drbd_volume_device_path,
scan_drbd_volume_device_minor,
scan_drbd_volume_size
FROM
scan_drbd_volumes
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
# We've got an entry in the 'scan_drbd_volumes' table, so now we'll look for data in the node and
# services tables.
my $scan_drbd_volume_uuid = $row->[0];
my $scan_drbd_volume_host_uuid = $row->[1];
my $scan_drbd_volume_scan_drbd_resource_uuid = $row->[2];
my $scan_drbd_volume_number = $row->[3];
my $resource_name = $anvil->data->{drbd}{resource_uuid}{$scan_drbd_volume_scan_drbd_resource_uuid}{resource_name};
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_drbd_volume_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
scan_drbd_volume_host_uuid => $scan_drbd_volume_host_uuid,
scan_drbd_volume_scan_drbd_resource_uuid => $scan_drbd_volume_scan_drbd_resource_uuid,
scan_drbd_volume_number => $scan_drbd_volume_number,
short_host_name => $short_host_name,
}});
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{volume_uuid} = $row->[0];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{resource_uuid} = $scan_drbd_volume_scan_drbd_resource_uuid;
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{device_path} = $row->[4];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{device_minor} = $row->[5];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{volume_size} = $row->[6];
$anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{volume_number} = $scan_drbd_volume_number;
$anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{resource_name} = $resource_name;
$anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{resource_uuid} = $scan_drbd_volume_scan_drbd_resource_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${scan_drbd_volume_number}::volume_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{volume_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${scan_drbd_volume_number}::resource_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{resource_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${scan_drbd_volume_number}::device_path" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{device_path},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${scan_drbd_volume_number}::device_minor" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{device_minor},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${scan_drbd_volume_number}::volume_size" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{volume_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$scan_drbd_volume_number}{volume_size}}).")",
"drbd::volume_uuid::${scan_drbd_volume_uuid}::volume_number" => $anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{volume_number},
"drbd::volume_uuid::${scan_drbd_volume_uuid}::resource_name" => $anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{resource_name},
"drbd::volume_uuid::${scan_drbd_volume_uuid}::resource_uuid" => $anvil->data->{drbd}{volume_uuid}{$scan_drbd_volume_uuid}{resource_uuid},
}});
}
undef $count;
undef $results;
# Read in the RAM module data.
$query = "
SELECT
scan_drbd_peer_uuid,
scan_drbd_peer_host_uuid,
scan_drbd_peer_scan_drbd_volume_uuid,
scan_drbd_peer_host_name,
scan_drbd_peer_connection_state,
scan_drbd_peer_local_disk_state,
scan_drbd_peer_disk_state,
scan_drbd_peer_local_role,
scan_drbd_peer_role,
scan_drbd_peer_out_of_sync_size,
scan_drbd_peer_replication_speed,
scan_drbd_peer_estimated_time_to_sync,
scan_drbd_peer_ip_address,
scan_drbd_peer_tcp_port,
scan_drbd_peer_protocol,
scan_drbd_peer_fencing
FROM
scan_drbd_peers
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
# We've got an entry in the 'scan_drbd_peers' table, so now we'll look for data in the node and
# services tables.
my $scan_drbd_peer_host_uuid = $row->[1];
my $scan_drbd_peer_scan_drbd_volume_uuid = $row->[2];
my $scan_drbd_peer_host_name = $row->[3];
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_drbd_peer_host_uuid}{short_host_name};
my $resource_uuid = $anvil->data->{drbd}{volume_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{resource_uuid};
my $resource_name = $anvil->data->{drbd}{volume_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{resource_name};
my $volume_number = $anvil->data->{drbd}{volume_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{volume_number};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
scan_drbd_peer_host_uuid => $scan_drbd_peer_host_uuid,
scan_drbd_peer_scan_drbd_volume_uuid => $scan_drbd_peer_scan_drbd_volume_uuid,
scan_drbd_peer_host_name => $scan_drbd_peer_host_name,
short_host_name => $short_host_name,
resource_uuid => $resource_uuid,
resource_name => $resource_name,
volume_number => $volume_number,
}});
# Store
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_uuid} = $row->[0];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_host_uuid} = $anvil->Database->get_host_uuid_from_string({debug => $debug, string => $scan_drbd_peer_host_name});
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{volume_uuid} = $scan_drbd_peer_scan_drbd_volume_uuid;
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{resource_uuid} = $resource_uuid;
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{connection_state} = $row->[4];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{local_disk_state} = $row->[5];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_disk_state} = $row->[6];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{local_role} = $row->[7];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_role} = $row->[8];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{out_of_sync_size} = $row->[9];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{replication_speed} = $row->[10];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{estimated_time_to_sync} = $row->[11];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_ip_address} = $row->[12];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_tcp_port} = $row->[13];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{protocol} = $row->[14];
$anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{fencing} = $row->[15];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_host_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_host_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::volume_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{volume_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::resource_uuid" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{resource_uuid},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::connection_state" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{connection_state},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::local_disk_state" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{local_disk_state},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_disk_state" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_disk_state},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::local_role" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{local_role},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_role" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_role},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::out_of_sync_size" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{out_of_sync_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{out_of_sync_size}}).")",
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::replication_speed" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{replication_speed}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{replication_speed}}).")",
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::estimated_time_to_sync" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{estimated_time_to_sync}." (".$anvil->Convert->time({'time' => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{estimated_time_to_sync}, long => 1, translate => 1}).")",
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_ip_address" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_ip_address},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::peer_tcp_port" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{peer_tcp_port},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::protocol" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{protocol},
"drbd::host_name::${short_host_name}::resource_name::${resource_name}::volume::${volume_number}::peer_name::${scan_drbd_peer_host_name}::fencing" => $anvil->data->{drbd}{host_name}{$short_host_name}{resource_name}{$resource_name}{volume}{$volume_number}{peer_name}{$scan_drbd_peer_host_name}{fencing},
}});
}
return(0);
}
=head2 get_fences
This loads the known fence devices into the C<< anvil::data >> hash at:
@ -4549,6 +4858,261 @@ sub get_local_uuid
}
=head2 get_lvm_data
This loads all of the LVM data into the following hashes;
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_uuid
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_internal_uuid
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_used_by_vg
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_attributes
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_size
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_free
* lvm::host_name::<short_host_name>::pv::<scan_lvm_pv_name>::scan_lvm_pv_sector_size
*
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_uuid
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_internal_uuid
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_attributes
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_extent_size
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_size
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::scan_lvm_vg_free
* lvm::host_name::<short_host_name>::vg::<scan_lvm_vg_name>::storage_group_uuid
*
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_uuid
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_internal_uuid
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_attributes
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_on_vg
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_size
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_path
* lvm::host_name::<short_host_name>::lv::<scan_lvm_lv_name>::scan_lvm_lv_on_pvs
This method takes no parameters.
=cut
sub get_lvm_data
{
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 => "Database->get_lvm_data()" }});
# Load Storage Group data
$anvil->Database->get_storage_group_data({debug => $debug});
# Load PVs
my $query = "
SELECT
scan_lvm_pv_uuid,
scan_lvm_pv_host_uuid,
scan_lvm_pv_internal_uuid,
scan_lvm_pv_name,
scan_lvm_pv_used_by_vg,
scan_lvm_pv_attributes,
scan_lvm_pv_size,
scan_lvm_pv_free,
scan_lvm_pv_sector_size
FROM
scan_lvm_pvs
;";
$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,
}});
foreach my $row (@{$results})
{
my $scan_lvm_pv_uuid = $row->[0];
my $scan_lvm_pv_host_uuid = $row->[1];
my $scan_lvm_pv_internal_uuid = $row->[2];
my $scan_lvm_pv_name = $row->[3];
my $scan_lvm_pv_used_by_vg = $row->[4];
my $scan_lvm_pv_attributes = $row->[5];
my $scan_lvm_pv_size = $row->[6];
my $scan_lvm_pv_free = $row->[7];
my $scan_lvm_pv_sector_size = $row->[8];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
scan_lvm_pv_uuid => $scan_lvm_pv_uuid,
scan_lvm_pv_host_uuid => $scan_lvm_pv_host_uuid,
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 => $scan_lvm_pv_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_size}).")",
scan_lvm_pv_free => $scan_lvm_pv_free." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_free}).")",
scan_lvm_pv_sector_size => $scan_lvm_pv_sector_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_pv_sector_size}).")",
}});
if (not exists $anvil->data->{hosts}{host_uuid}{$scan_lvm_pv_host_uuid})
{
$anvil->Database->get_hosts({debug => $debug});
}
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_lvm_pv_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { short_host_name => $short_host_name }});
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_uuid} = $scan_lvm_pv_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_internal_uuid} = $scan_lvm_pv_internal_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_used_by_vg} = $scan_lvm_pv_used_by_vg;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_attributes} = $scan_lvm_pv_attributes;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_size} = $scan_lvm_pv_size;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_free} = $scan_lvm_pv_free;
$anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_sector_size} = $scan_lvm_pv_sector_size;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_uuid},
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_internal_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_internal_uuid},
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_used_by_vg" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_used_by_vg},
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_attributes" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_attributes},
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_size" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_size}}).")",
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_free" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_free}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_free}}).")",
"lvm::host_name::${short_host_name}::pv::${scan_lvm_pv_name}::scan_lvm_pv_sector_size" => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_sector_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{pv}{$scan_lvm_pv_name}{scan_lvm_pv_sector_size}}).")",
}});
}
# Load VGs
$query = "
SELECT
scan_lvm_vg_uuid,
scan_lvm_vg_host_uuid,
scan_lvm_vg_internal_uuid,
scan_lvm_vg_name,
scan_lvm_vg_attributes,
scan_lvm_vg_extent_size,
scan_lvm_vg_size,
scan_lvm_vg_free
FROM
scan_lvm_vgs
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $scan_lvm_vg_uuid = $row->[0];
my $scan_lvm_vg_host_uuid = $row->[1];
my $scan_lvm_vg_internal_uuid = $row->[2];
my $scan_lvm_vg_name = $row->[3];
my $scan_lvm_vg_attributes = $row->[4];
my $scan_lvm_vg_extent_size = $row->[5];
my $scan_lvm_vg_size = $row->[6];
my $scan_lvm_vg_free = $row->[7];
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_lvm_vg_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
scan_lvm_vg_uuid => $scan_lvm_vg_uuid,
scan_lvm_vg_host_uuid => $scan_lvm_vg_host_uuid,
scan_lvm_vg_internal_uuid => $scan_lvm_vg_internal_uuid,
scan_lvm_vg_name => $scan_lvm_vg_name,
scan_lvm_vg_attributes => $scan_lvm_vg_attributes,
scan_lvm_vg_extent_size => $scan_lvm_vg_extent_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_extent_size}).")",
scan_lvm_vg_size => $scan_lvm_vg_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_size}).")",
scan_lvm_vg_free => $scan_lvm_vg_free." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_free}).")",
short_host_name => $short_host_name,
}});
my $storage_group_uuid = "";
if (exists $anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid})
{
$storage_group_uuid = $anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid}{storage_group_uuid};
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { storage_group_uuid => $storage_group_uuid }});
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_uuid} = $scan_lvm_vg_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_internal_uuid} = $scan_lvm_vg_internal_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_attributes} = $scan_lvm_vg_attributes;
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_extent_size} = $scan_lvm_vg_extent_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_extent_size}).")";
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_size} = $scan_lvm_vg_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_size}).")";
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_free} = $scan_lvm_vg_free." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_vg_free}).")";
$anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{storage_group_uuid} = $storage_group_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_uuid},
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_internal_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_internal_uuid},
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_attributes" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_attributes},
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_extent_size" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_extent_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_extent_size}}).")",
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_size" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_size}}).")",
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::scan_lvm_vg_free" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_free}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{scan_lvm_vg_free}}).")",
"lvm::host_name::${short_host_name}::vg::${scan_lvm_vg_name}::storage_group_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$scan_lvm_vg_name}{storage_group_uuid},
}});
}
# LVs
$query = "
SELECT
scan_lvm_lv_uuid,
scan_lvm_lv_host_uuid,
scan_lvm_lv_internal_uuid,
scan_lvm_lv_name,
scan_lvm_lv_attributes,
scan_lvm_lv_on_vg,
scan_lvm_lv_size,
scan_lvm_lv_path,
scan_lvm_lv_on_pvs
FROM
scan_lvm_lvs
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $scan_lvm_lv_uuid = $row->[0];
my $scan_lvm_lv_host_uuid = $row->[1];
my $scan_lvm_lv_internal_uuid = $row->[2];
my $scan_lvm_lv_name = $row->[3];
my $scan_lvm_lv_attributes = $row->[4];
my $scan_lvm_lv_on_vg = $row->[5];
my $scan_lvm_lv_size = $row->[6];
my $scan_lvm_lv_path = $row->[7];
my $scan_lvm_lv_on_pvs = $row->[8];
my $short_host_name = $anvil->data->{hosts}{host_uuid}{$scan_lvm_lv_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
scan_lvm_lv_uuid => $scan_lvm_lv_uuid,
scan_lvm_lv_host_uuid => $scan_lvm_lv_host_uuid,
scan_lvm_lv_internal_uuid => $scan_lvm_lv_internal_uuid,
scan_lvm_lv_name => $scan_lvm_lv_name,
scan_lvm_lv_attributes => $scan_lvm_lv_attributes,
scan_lvm_lv_on_vg => $scan_lvm_lv_on_vg,
scan_lvm_lv_size => $scan_lvm_lv_size." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $scan_lvm_lv_size}).")",
scan_lvm_lv_path => $scan_lvm_lv_path,
scan_lvm_lv_on_pvs => $scan_lvm_lv_on_pvs,
short_host_name => $short_host_name,
}});
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_uuid} = $scan_lvm_lv_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_internal_uuid} = $scan_lvm_lv_internal_uuid;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_attributes} = $scan_lvm_lv_attributes;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_on_vg} = $scan_lvm_lv_on_vg;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_size} = $scan_lvm_lv_size;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_path} = $scan_lvm_lv_path;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_on_pvs} = $scan_lvm_lv_on_pvs;
$anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$scan_lvm_lv_path}{scan_lvm_lv_name} = $scan_lvm_lv_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_uuid},
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_internal_uuid" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_internal_uuid},
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_attributes" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_attributes},
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_on_vg" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_on_vg},
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_size" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_size}}).")",
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_path" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_path},
"lvm::host_name::${short_host_name}::lv::${scan_lvm_lv_name}::scan_lvm_lv_on_pvs" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$scan_lvm_lv_name}{scan_lvm_lv_on_pvs},
"lvm::host_name::${short_host_name}::lv_path::${scan_lvm_lv_path}::scan_lvm_lv_name" => $anvil->data->{lvm}{host_name}{$short_host_name}{lv_path}{$scan_lvm_lv_path}{scan_lvm_lv_name},
}});
}
return(0);
}
=head2 get_mail_servers
This gets the list of configured mail servers.
@ -5302,7 +5866,7 @@ sub get_storage_group_data
$anvil->Database->get_hosts({debug => $debug});
}
$query = "
$query = "
SELECT
a.storage_group_uuid,
a.storage_group_anvil_uuid,
@ -5426,12 +5990,10 @@ WHERE
my $anvil_name = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_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};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
anvil_name => $anvil_name,
node1_host_uuid => $node1_host_uuid,
node2_host_uuid => $node2_host_uuid,
dr1_host_uuid => $dr1_host_uuid,
}});
foreach my $storage_group_uuid (keys %{$anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}})
{
@ -5444,19 +6006,20 @@ WHERE
my $size_to_match = 0;
my $node1_seen = 0;
my $node2_seen = 0;
my $dr1_seen = $dr1_host_uuid ? 0 : 1; # Only set to '0' if DR exists.
foreach my $this_host_uuid (keys %{$anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}})
{
my $storage_group_member_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{storage_group_member_uuid};
my $internal_vg_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_internal_uuid};
my $vg_size = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_size};
my $vg_name = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_name};
my $host_type = $anvil->data->{hosts}{host_uuid}{$this_host_uuid}{host_type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
this_host_uuid => $this_host_uuid,
storage_group_member_uuid => $storage_group_member_uuid,
internal_vg_uuid => $internal_vg_uuid,
vg_size => $anvil->Convert->add_commas({number => $vg_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size}).")",
vg_name => $vg_name,
host_type => $host_type,
}});
if ($vg_size > $size_to_match)
@ -5477,14 +6040,10 @@ WHERE
$node2_seen = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { node2_seen => $node2_seen }});
}
elsif (($dr1_host_uuid) && ($this_host_uuid eq $dr1_host_uuid))
elsif ($host_type eq "node")
{
$dr1_seen = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { dr1_seen => $dr1_seen }});
}
else
{
# This host doesn't belong in this group anymore. Delete it.
# This host is a node that isn't in the Anvil!, so it doesn't belong
# in this group anymore. Delete it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0130", variables => {
storage_group_name => $group_name,
host_name => $anvil->Get->host_name_from_uuid({host_uuid => $this_host_uuid}),
@ -5502,15 +6061,9 @@ WHERE
}
if ((not $node1_seen) or
(not $node2_seen) or
(not $dr1_seen))
(not $node2_seen))
{
my $hosts = [$node1_host_uuid, $node2_host_uuid];
if ($dr1_host_uuid)
{
push @{$hosts}, $dr1_host_uuid;
}
my $hosts = [$node1_host_uuid, $node2_host_uuid];
my $reload = 0;
foreach my $this_host_uuid (@{$hosts})
{

@ -511,45 +511,20 @@ sub available_resources
delete $anvil->data->{anvil_resources}{$anvil_uuid};
}
# Get the node UUIDs for this anvil.
my $query = "
SELECT
anvil_name,
anvil_node1_host_uuid,
anvil_node2_host_uuid
FROM
anvils
WHERE
anvil_uuid = ".$anvil->Database->quote($anvil_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 (not $count)
{
# Not found.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0169", variables => { anvil_uuid => $anvil_uuid }});
return("!!error!!");
}
# Load hosts and network bridges. This loads Anvil! data as well
$anvil->Database->get_hosts({debug => $debug});
$anvil->Database->get_bridges({debug => $debug});
# Get the details.
my $anvil_name = $results->[0]->[0];
my $node1_host_uuid = $results->[0]->[1];
my $node2_host_uuid = $results->[0]->[2];
my $anvil_name = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_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};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
anvil_name => $anvil_name,
node1_host_uuid => $node1_host_uuid,
node2_host_uuid => $node2_host_uuid,
}});
# Load hosts and network bridges
$anvil->Database->get_hosts({debug => $debug});
$anvil->Database->get_bridges({debug => $debug});
# This both loads storage group data and assembles ungrouped VGs into storage groups, when possible.
$anvil->Cluster->assemble_storage_groups({
debug => $debug,
@ -560,7 +535,6 @@ WHERE
$anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{cores} = 0;
$anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{threads} = 0;
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{hardware} = 0;
foreach my $host_uuid ($node1_host_uuid, $node2_host_uuid)
{
my $this_is = "node1";
@ -682,7 +656,7 @@ WHERE
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{allocated} = 0;
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{hardware} = $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available};
$query = "
my $query = "
SELECT
server_name,
server_ram_in_use
@ -693,8 +667,8 @@ WHERE
ORDER BY
server_name ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
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,
@ -795,8 +769,8 @@ ORDER BY
}});
# Make it easy to sort by group name
my $storage_group_name = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{group_name};
$anvil->data->{anvil_resources}{$anvil_uuid}{storage_group_name}{$storage_group_name}{storage_group_uuid} = $storage_group_uuid;
my $storage_group_name = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{group_name};
$anvil->data->{anvil_resources}{$anvil_uuid}{storage_group_name}{$storage_group_name}{storage_group_uuid} = $storage_group_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::${anvil_uuid}::storage_group_name::${storage_group_name}::storage_group_uuid" => $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group_name}{$storage_group_name}{storage_group_uuid},
}});

@ -1,4 +1,4 @@
.\" Manpage for the Anvil! server removal tool
.\" Manpage for the Anvil! DR hosts
.\" Contact mkelly@alteeve.com to report issues, concerns or suggestions.
.TH anvil-manage-dr "8" "August 18 2022" "Anvil! Intelligent Availability™ Platform"
.SH NAME
@ -7,7 +7,7 @@ anvil-manage-dr \- This program manages if a server is (and when) a server is pr
.B anvil-manage-dr --server <server>
\fI\,<command> \/\fR[\fI\,options\/\fR]
.SH DESCRIPTION
This tool is used to manage the protection of servers on DR hosts.
.TP
.SH OPTIONS
.TP

@ -0,0 +1,61 @@
.\" Manpage for the Anvil! storage groups
.\" Contact mkelly@alteeve.com to report issues, concerns or suggestions.
.TH anvil-manage-storage-group "8" "March 23 2023" "Anvil! Intelligent Availability™ Platform"
.SH NAME
anvil-manage-storage-group \- This program manages if a server is (and when) a server is protected by a DR host.
.SH SYNOPSIS
.B anvil-manage-storage-group
\fI\,<command> \/\fR[\fI\,options\/\fR]
.SH DESCRIPTION
This tool manages storage groups. Storage Groups are collections of LVM Volume Groups across sub-nodes and DR hosts. A server's virtual hard disk syncs across LVs in common storage groups.
.TP
.SH OPTIONS
.TP
\-?, \-h, \fB\-\-help\fR
Show this man page.
.TP
\fB\-\-log-secure\fR
When logging, record sensitive data, like passwords.
.TP
\-v, \-vv, \-vvv
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\-\-add\fR
This creates a new Storage Group on a given Anvil! node. Requires \fB\-\-group <name>\fR.
.TP
\fB\-\-anvil <name or UUID>\fR
This is the Anvil! node whose storage groups you want to see or work on.
.TP
\fB\-\-remove <group name or UUID>\fR
This deletes a storage group entirely.
.TP
\fB\-\-rename\fR
This is used along with \fB\-\-new\-name <new name>\fR and \fB\-\-group <name or UUID>\fR to change the name of an existing storage group.
.TP
\fB\-\-group <name or UUID>\fR
The is the storage group name or UUID that is being worked with.
.TP
\fB\-\-member <VG internal UUID>\fR
This is the LVM volume group's
.b internal
UUID (as shown by \fBvgdisplay\fR or with \fB\-\-show\fR. It is used to specify which volume group is being added or removed.
.TP
\fB\-\-new\-name <new name>\fR
When used with \fB\-\-rename\fR and \fB\-\-group <name or UUID>\fR, this specifies the new storage group name.
.TP
\fB\-\-show\fR
This shows the storage groups on each Anvil! node (or just the one specified with \fB\-\-anvil <name or UUID>\fR), and the available DR hosts.
.TP
.SH EXAMPLES
.RE
Add a VG to a storage group
.RS
anvil-manage-storage-groups --anvil vm-anvil-01 --group "Storage group 1" --add --member edrYMv-Fl2D-o0tO-g8ok-idOh-oBIh-65LuD6
.IP
.SH AUTHOR
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors.
.SH "REPORTING BUGS"
Report bugs to users@clusterlabs.org

@ -1,4 +1,3 @@
Common queries;
* SELECT a.job_uuid, b.host_name, a.job_command, a.job_data, a.job_progress, a.job_status FROM jobs a, hosts b WHERE a.job_host_uuid = b.host_uuid AND a.job_progress != 100;
* 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;

@ -122,6 +122,53 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub load_storage
{
my ($anvil) = @_;
# Host and server
my $short_host_name = $anvil->Get->short_host_name;
my $server_name = $anvil->data->{switches}{server_name};
# We need to know which volume groups the disks are on so that we can report how much free space is
# available for either growing or adding a disk.
$anvil->Get->available_resources({
debug => 2,
anvil_uuid => $anvil->data->{switches}{anvil_uuid},
});
# Load LVM and Storage Group data
$anvil->Database->get_lvm_data({debug => 2});
# Load DRBD data from the database.
$anvil->Database->get_drbd_data({debug => 2});
# Load DRBD resource data so that we can map DRBD resources / volumes to volume groups.
my $drbd_resource = "";
foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{$short_host_name}{$server_name}{device}})
{
my $on_lv = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{on_lv};
$drbd_resource = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{resource};
my $device_target = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{target};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:device_path' => $device_path,
's2:on_lv' => $on_lv,
's3:drbd_resource' => $drbd_resource,
's4:device_target' => $device_target,
}});
}
# There should only ever be one, but it's not impossible for there to be multiple.
foreach my $drbd_resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$short_host_name}{$server_name}{drbd}{resource}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { drbd_resource => $drbd_resource }});
# Get the DRBD volume data
load_drbd_data($anvil, $drbd_resource);
}
return($drbd_resource);
}
sub manage_disk
{
my ($anvil) = @_;
@ -160,6 +207,68 @@ sub manage_disk
}
}
my $drbd_resource = load_storage($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { drbd_resource => $drbd_resource }});
foreach my $host_type ("node", "dr")
{
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};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:host_uuid' => $host_uuid,
}});
foreach my $volume_number (sort {$a cmp $b} keys %{$anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}})
{
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};
my $meta_disk = $anvil->data->{new}{resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{meta_disk};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:volume_number' => $volume_number,
's2:device_path' => $device_path,
's3:device_minor' => $device_minor,
's4:volume_size' => $volume_size,
's5:backing_disk' => $backing_disk,
's6:meta_disk' => $meta_disk,
}});
# Which volume group is the backing device in?
foreach my $this_scan_lvm_lv_name (sort {$a cmp $b} keys %{$anvil->data->{lvm}{host_name}{$short_host_name}{lv}})
{
my $this_scan_lvm_lv_path = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_path};
my $this_scan_lvm_lv_on_vg = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_on_vg};
my $this_scan_lvm_lv_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:this_scan_lvm_lv_name' => $this_scan_lvm_lv_name,
's2:this_scan_lvm_lv_path' => $this_scan_lvm_lv_path,
's3:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
's4:this_scan_lvm_lv_uuid' => $this_scan_lvm_lv_uuid,
}});
if ($backing_disk eq $this_scan_lvm_lv_path)
{
# What's the VG's UUID?
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
}});
if (exists $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg})
{
my $scan_lvm_vg_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_name}{scan_lvm_vg_uuid};
my $storage_group_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_name}{storage_group_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:scan_lvm_vg_uuid' => $scan_lvm_vg_uuid,
's2:storage_group_uuid' => $storage_group_uuid,
}});
}
}
}
}
}
}
my $device_target = $anvil->data->{switches}{disk};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { device_target => $device_target }});
@ -202,7 +311,6 @@ sub manage_disk
my $volume = "";
print "Sub-Nodes:\n";
my $drbd_resource = "";
foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{$short_host_name}{$server_name}{device}})
{
my $on_lv = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{on_lv};
@ -388,15 +496,32 @@ sub get_definition_source
{
my ($anvil) = @_;
my $short_host_name = $anvil->Get->short_host_name;
my $server_name = $anvil->data->{switches}{server_name};
my $from_source = "";
my $short_host_name = $anvil->Get->short_host_name;
my $server_name = $anvil->data->{switches}{server_name};
my $server_uuid = $anvil->data->{switches}{server_uuid};
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state};
my $server_host_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_host_uuid};
my $from_source = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
short_host_name => $short_host_name,
server_name => $server_name,
server_uuid => $server_uuid,
server_state => $server_state,
from_source => $from_source,
}});
if (exists $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh})
$anvil->data->{server}{$short_host_name}{$server_name}{from_virsh} = "" if not exists $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh};
$anvil->data->{server}{$short_host_name}{$server_name}{from_disk} = "" if not exists $anvil->data->{server}{$short_host_name}{$server_name}{from_disk};
$anvil->data->{server}{$short_host_name}{$server_name}{from_db} = "" if not exists $anvil->data->{server}{$short_host_name}{$server_name}{from_db};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"server::${short_host_name}::${server_name}::from_virsh" => $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh},
"server::${short_host_name}::${server_name}::from_disk" => $anvil->data->{server}{$short_host_name}{$server_name}{from_disk},
"server::${short_host_name}::${server_name}::from_db" => $anvil->data->{server}{$short_host_name}{$server_name}{from_db},
}});
if (($server_state eq "running") &&
($server_host_uuid eq $anvil->Get->host_uuid()) &&
(exists $anvil->data->{server}{$short_host_name}{$server_name}{from_virsh}))
{
$from_source = "from_virsh";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { from_source => $from_source }});
@ -420,12 +545,17 @@ sub show_server_details
my ($anvil) = @_;
my $short_host_name = $anvil->Get->short_host_name;
my $host_uuid = $anvil->Get->host_uuid;
my $server_name = $anvil->data->{switches}{server_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:host_uuid' => $host_uuid,
's2:server_name' => $server_name,
}});
# Load storage data
my $drbd_resource = load_storage($anvil);
my $from_source = get_definition_source($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { from_source => $from_source }});
foreach my $device ("disk", "cdrom")
@ -471,15 +601,36 @@ sub show_server_details
my $device_path = $anvil->data->{server}{$short_host_name}{$server_name}{$from_source}{device}{$device}{target}{$device_target}{path};
my $driver_io = $anvil->data->{server}{$short_host_name}{$server_name}{$from_source}{device}{$device}{target}{$device_target}{driver}{io};
my $driver_cache = $anvil->data->{server}{$short_host_name}{$server_name}{$from_source}{device}{$device}{target}{$device_target}{driver}{cache};
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};
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};
my $metadata_size = $lv_size - $resource_size;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:address_domain' => $address_domain,
's2:address_slot' => $address_slot,
's3:address_function' => $address_function,
's4:device_path' => $device_path,
's5:driver_io' => $driver_io,
's6:driver_cache' => $driver_cache,
's01:address_domain' => $address_domain,
's02:address_slot' => $address_slot,
's03:address_function' => $address_function,
's04:device_path' => $device_path,
's05:driver_io' => $driver_io,
's06:driver_cache' => $driver_cache,
's07:on_lv' => $on_lv,
's08:lv_name' => $lv_name,
's09:drbd_resource' => $drbd_resource,
's10:drbd_volume' => $drbd_volume,
's11:resource_size' => $anvil->Convert->bytes_to_human_readable({'bytes' => $resource_size})." (".$anvil->Convert->add_commas({number => $resource_size}).")",
's12:lv_size' => $anvil->Convert->bytes_to_human_readable({'bytes' => $lv_size})."] (".$anvil->Convert->add_commas({number => $lv_size}).")",
's13:metadata_size' => $anvil->Convert->bytes_to_human_readable({'bytes' => $metadata_size})."] (".$anvil->Convert->add_commas({number => $metadata_size}).")",
}});
print "- Target: [".$device_target."], boot: [".$say_boot."], path: [".$device_path."], cache: [".$driver_cache."], driver type: [".$driver_type."]\n";
print "- Target: [".$device_target."], boot: [".$say_boot."], Replication Volume: [".$drbd_resource."/".$drbd_volume."]\n";
print " - Resource / LV / Metadata sizes: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $resource_size})." / ".$anvil->Convert->bytes_to_human_readable({'bytes' => $lv_size})." / ".$anvil->Convert->bytes_to_human_readable({'bytes' => $metadata_size})."], cache: [".$driver_cache."], IO Policy: [".$driver_io."]\n";
# Get the backing LV from the DRBD resource.
#if ($anvil->data->{storage_groups}{vg_uuid}{$vg_uuid}{storage_group_uuid})
}
else
{
@ -503,27 +654,6 @@ sub show_server_details
}
print "\n";
my $drbd_resource = "";
foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{$short_host_name}{$server_name}{device}})
{
my $on_lv = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{on_lv};
$drbd_resource = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{resource};
my $device_target = $anvil->data->{server}{$short_host_name}{$server_name}{device}{$device_path}{target};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:device_path' => $device_path,
's2:on_lv' => $on_lv,
's3:drbd_resource' => $drbd_resource,
's4:device_target' => $device_target,
}});
}
foreach my $drbd_resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$short_host_name}{$server_name}{drbd}{resource}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { drbd_resource => $drbd_resource }});
# Get the DRBD volume data
load_drbd_data($anvil, $drbd_resource);
}
print "Sub-Nodes:\n";
show_volume($anvil, $drbd_resource, "node");
@ -613,6 +743,8 @@ sub show_volume
{
my ($anvil, $drbd_resource, $host_type) = @_;
my $anvil_uuid = defined $anvil->data->{switches}{anvil_uuid} ? $anvil->data->{switches}{anvil_uuid} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
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};
@ -623,20 +755,73 @@ sub show_volume
print " |- Name: [".$short_host_name."], UUID: [".$host_uuid."]\n";
foreach my $volume_number (sort {$a cmp $b} keys %{$anvil->data->{drbd_resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}})
{
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};
my $meta_disk = $anvil->data->{new}{resource}{$drbd_resource}{host_uuid}{$host_uuid}{volume_number}{$volume_number}{meta_disk};
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};
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 => {
's1:volume_number' => $volume_number,
's2:device_path' => $device_path,
's3:device_minor' => $device_minor,
's4:volume_size' => $volume_size,
's5:backing_disk' => $backing_disk,
's6:meta_disk' => $meta_disk,
's1:volume_number' => $volume_number,
's2:device_path' => $device_path,
's3:device_minor' => $device_minor,
's4:volume_size' => $volume_size,
's5:backing_disk' => $backing_disk,
's6:meta_disk' => $meta_disk,
's7:storage_group_uuid' => $storage_group_uuid,
}});
print " ^- Volume: [".$volume_number."], backing device: [".$backing_disk."], DRBD minor: [".$device_minor."], size: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $volume_size})."]\n";
my $storage_group_name = "<unknown>";
my $storage_group_size = 0;
my $storage_group_free_space = 0;
if (($storage_group_uuid) && ($anvil_uuid) && (exists $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}))
{
$storage_group_name = $anvil->data->{storage_groups}{storage_group_uuid}{$storage_group_uuid}{storage_group_name};
$storage_group_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{vg_size};
$storage_group_free_space = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size};
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:storage_group_size' => $storage_group_size,
's2:storage_group_free_space' => $storage_group_free_space,
}});
print " |- Volume: [".$volume_number."], backing device: [".$backing_disk."], DRBD minor: [".$device_minor."], size: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $volume_size})."]\n";
print " ^- In storage group: [".$storage_group_name."], size: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $storage_group_size})."], free: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $storage_group_free_space})."]\n";
# How much space is available in the storage group this volume is in?
foreach my $this_scan_lvm_lv_name (sort {$a cmp $b} keys %{$anvil->data->{lvm}{host_name}{$short_host_name}{lv}})
{
my $this_scan_lvm_lv_path = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_path};
my $this_scan_lvm_lv_on_vg = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_on_vg};
my $this_scan_lvm_lv_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{lv}{$this_scan_lvm_lv_name}{scan_lvm_lv_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:this_scan_lvm_lv_name' => $this_scan_lvm_lv_name,
's2:this_scan_lvm_lv_path' => $this_scan_lvm_lv_path,
's3:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
's4:this_scan_lvm_lv_uuid' => $this_scan_lvm_lv_uuid,
}});
if ($backing_disk eq $this_scan_lvm_lv_path)
{
# What's the VG's UUID?
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:this_scan_lvm_lv_on_vg' => $this_scan_lvm_lv_on_vg,
}});
if (exists $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg})
{
my $scan_lvm_vg_internal_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg}{scan_lvm_vg_internal_uuid};
my $storage_group_uuid = $anvil->data->{lvm}{host_name}{$short_host_name}{vg}{$this_scan_lvm_lv_on_vg}{storage_group_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:scan_lvm_vg_internal_uuid' => $scan_lvm_vg_internal_uuid,
's2:storage_group_uuid' => $storage_group_uuid,
}});
if ($storage_group_uuid)
{
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};
}
}
}
}
}
}
@ -680,6 +865,7 @@ sub validate_server
my $server_definition = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_definition_xml};
my $server_host_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_host_uuid};
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state};
my $anvil_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_anvil_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:server_name' => $server_name,
@ -687,7 +873,21 @@ sub validate_server
's4:server_definition' => $server_definition,
's5:server_host_uuid' => $server_host_uuid,
's6:server_state' => $server_state,
's7:anvil_uuid' => $anvil_uuid,
}});
if (not $anvil->data->{switches}{anvil_uuid})
{
$anvil->data->{switches}{anvil_uuid} = $anvil_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:switches::anvil_uuid' => $anvil->data->{switches}{anvil_uuid},
}});
}
if ($server_state eq "DELETED")
{
print "The server: [".$server_name."] has been deleted.\n";
$anvil->nice_exit({exit_code => 1});
}
# Parse the definition.
$anvil->Server->parse_definition({
@ -710,7 +910,7 @@ sub validate_server
# The server isn't actually running... Not here anyway.
if ($server_state eq "running")
{
my $server_host_name = $anvil->Get->get_host_from_uuid({
my $server_host_name = $anvil->Database->get_host_from_uuid({
short => 1,
host_uuid => $server_host_uuid,
});
@ -943,11 +1143,14 @@ sub show_server_list
{
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_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 => {
server_name => $server_name,
server_uuid => $server_uuid,
server_name => $server_name,
server_uuid => $server_uuid,
server_state => $server_state,
}});
next if $server_state eq "DELETED";
print "^- Server: [".$server_name."], UUID: [".$server_uuid."]\n";
}
}

Loading…
Cancel
Save