# The actual migration command will involve enabling dual primary, then beginning the migration. The
@ -1186,7 +1192,7 @@ sub migrate_server
# success or failure, dual primary will be disabled again.
my $migration_command = "";
my $migrated = 0;
if ($anvil->data->{switches}{migrate_to})
if ($target)
{
# Can I even connect to the target?
my ($access) = $anvil->Remote->test_access({debug => 3, target => $target});
@ -1340,11 +1346,12 @@ sub migrate_server
($migrated) = $anvil->Server->migrate({
debug => 2,
server => $server,
source => $source,
target => $target
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { migrated => $migrated }});
}
elsif ($anvil->data->{switches}{migrate_from})
elsif ($source)
{
# Pull the server here. Start by verifying it's on the 'meta_on_node' host.
# Scan locally and on our peer
@ -1353,7 +1360,7 @@ sub migrate_server
my $host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $short_host = ($host =~ /^(.*?)\..*$/)[0];
my $status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
my $status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host => $host,
short_host => $short_host,
@ -1362,7 +1369,6 @@ sub migrate_server
}});
# Convert the host to a short name, in case the node's name is the short version.
my $server_host = defined $anvil->data->{server}{location}{$server}{host} ? $anvil->data->{server}{location}{$server}{host} : "";
my $server_status = defined $anvil->data->{server}{location}{$server}{status} ? $anvil->data->{server}{location}{$server}{status} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
@ -1421,10 +1427,18 @@ sub validate_all
### TODO: When we have actual Anvil! systems, connect to the peers (nodes / DR) for this host and see
### if the server is running elsewhere.
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = defined $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} ? $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} : "";
my $target = defined $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} ? $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
source => $source,
target => $target,
}});
# Read in an parse the server's XML.
$anvil->System->check_storage({debug => 3});
$anvil->Server->get_status({debug => 3, server => $anvil->data->{environment}{OCF_RESKEY_name}});
$anvil->System->check_storage({debug => 2});
$anvil->Server->get_status({debug => 2, server => $server});
# Is the name in the definition file what we expect (and did we read the XML data at all)?
validate_name($anvil);
@ -1433,7 +1447,7 @@ sub validate_all
validate_emulator($anvil);
# These tests are only needed if we're about to boot the server
if (($anvil->data->{switches}{start}) or ($anvil->data->{switches}{migrate_from}))
if (($anvil->data->{switches}{start}) or ($source))
{
# Check that we have enough RAM.
validate_ram($anvil);
@ -1497,28 +1511,33 @@ sub validate_storage
my ($anvil) = @_;
# When checking on a running server, use 'from_memory'.
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = "from_disk";
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $target = defined $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} ? $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
target => $target,
}});
my $xml_source = "from_disk";
if ($anvil->data->{server}{'local'}{$server}{from_memory}{host})
{
$source = "from_memory";
$xml_source = "from_memory";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
server => $server,
source => $source,
server => $server,
xml_source => $xml_source,
}});
### TODO: If we're called with a status and find an ISO file missing and eject it instead of failing.
### For now, we just fault out.
# Do the optical discs in the drive exist? If not, we'll eject it if we're about to boot and fail if
# we're about to migrate. We skip this check if we're migrating off or shutting down the server.
if ((exists $anvil->data->{server}{'local'}{$server}{$source}{device}{cdrom}) && (not $anvil->data->{switches}{migrate_to}) && (not $anvil->data->{switches}{stop}))
if ((exists $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}) && (not $target) && (not $anvil->data->{switches}{stop}))
{
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$source}{device}{cdrom}{target}})
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}})
{
if ($anvil->data->{server}{'local'}{$server}{$source}{device}{cdrom}{target}{$device_target}{path})
if ($anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path})
{
my $file = $anvil->data->{server}{'local'}{$server}{$source}{device}{cdrom}{target}{$device_target}{path};
my $file = $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file => $file }});
if (not -e $file)
{
@ -1555,9 +1574,9 @@ sub validate_storage_drbd
my ($anvil) = @_;
# Now check storage.
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = "from_disk";
my $host = $anvil->_short_host_name;
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $xml_source = "from_disk";
my $host = $anvil->_short_host_name;
# Did I find a resource for each disk?
foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{device}})
@ -1573,9 +1592,9 @@ sub validate_storage_drbd
}
}
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$source}{device}{disk}{target}})
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$xml_source}{device}{disk}{target}})
{
my $drbd_device = $anvil->data->{server}{'local'}{$server}{$source}{device}{disk}{target}{$device_target}{path};
my $drbd_device = $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{disk}{target}{$device_target}{path};
my $drbd_resource = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} : "";
my $on_lv = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
my$xml='<cibcrm_feature_set="3.3.0"validate-with="pacemaker-3.2"epoch="322"num_updates="6"admin_epoch="0"cib-last-written="Sun Aug 16 18:24:22 2020"update-origin="mk-a02n01"update-client="cibadmin"update-user="root"have-quorum="1"dc-uuid="2">