diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm
index 8d63d444..be0d4d59 100644
--- a/Anvil/Tools/Cluster.pm
+++ b/Anvil/Tools/Cluster.pm
@@ -226,11 +226,11 @@ sub add_server
my $host_name = $anvil->Get->host_name();
my $server_state = defined $anvil->data->{server}{location}{$server_name}{status} ? $anvil->data->{server}{location}{$server_name}{status} : "";
my $server_host = defined $anvil->data->{server}{location}{$server_name}{host_name} ? $anvil->data->{server}{location}{$server_name}{host_name} : "";
- my $target_role = $server_state eq "running" ? "started" : "stopped";
+ my $target_role = $server_host ? "started" : "stopped"; # Don't use state as it could be 'paused' if caught during initialization.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_name => $host_name,
server_state => $server_state,
- server_host => $server_host,
+ server_host => $server_host,
target_role => $target_role,
}});
@@ -262,17 +262,70 @@ sub add_server
return_code => $return_code,
}});
- my $constraint_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." constraint location ".$server_name." prefers ";
- if (($server_state eq "running") && ($server_host ne $host_name))
+ ### NOTE: The higher the constraint score, the more preferred the host is.
+ # Which sub-node do we want to run the server on?
+ my $run_on_host_name = "";
+ my $backup_host_name = "";
+ my $target_host_uuid = $anvil->Cluster->get_primary_host_uuid({debug => 2, anvil_uuid => $anvil_uuid});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { target_host_uuid => $target_host_uuid }});
+
+ if ($target_role eq "started")
{
- # Set the peer as primary.
- $constraint_command .= $local_name."=100 ".$peer_name."=200";
+ # Run on the current host.
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ server_host => $server_host,
+ host_name => $host_name,
+ }});
+ if ($server_host eq $host_name)
+ {
+ # Run here
+ $run_on_host_name = $local_name;
+ $backup_host_name = $peer_name;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ run_on_host_name => $run_on_host_name,
+ backup_host_name => $backup_host_name,
+ }});
+ }
+ else
+ {
+ # Run on the
+ $run_on_host_name = $peer_name;
+ $backup_host_name = $local_name;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ run_on_host_name => $run_on_host_name,
+ backup_host_name => $backup_host_name,
+ }});
+ }
}
else
{
- # Set us as primary.
- $constraint_command .= $local_name."=200 ".$peer_name."=100";
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ target_host_uuid => $target_host_uuid,
+ peer_host_uuid => $peer_host_uuid,
+ }});
+ if ($target_host_uuid eq $peer_host_uuid)
+ {
+ # Run on the
+ $run_on_host_name = $peer_name;
+ $backup_host_name = $local_name;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ run_on_host_name => $run_on_host_name,
+ backup_host_name => $backup_host_name,
+ }});
+ }
+ else
+ {
+ # Run here
+ $run_on_host_name = $local_name;
+ $backup_host_name = $peer_name;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ run_on_host_name => $run_on_host_name,
+ backup_host_name => $backup_host_name,
+ }});
+ }
}
+
+ my $constraint_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." constraint location ".$server_name." prefers ".$run_on_host_name."=200 ".$backup_host_name."=100";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { constraint_command => $constraint_command }});
undef $output;
diff --git a/Anvil/Tools/DRBD.pm b/Anvil/Tools/DRBD.pm
index 55b03424..95b21170 100644
--- a/Anvil/Tools/DRBD.pm
+++ b/Anvil/Tools/DRBD.pm
@@ -676,6 +676,21 @@ sub delete_resource
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "job_0134", variables => { file_path => $definition_file }});
}
+ # Call scan-lvm and scan-drbd to make sure the databases are updated.
+ foreach my $agent ("scan-drbd", "scan-lvm")
+ {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
+
+ my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
+
+ my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
+ output => $output,
+ return_code => $return_code,
+ }});
+ }
+
return(0);
}
diff --git a/share/words.xml b/share/words.xml
index e735f11a..23708d04 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -1549,6 +1549,7 @@ Note: This is a permanent action! If you protect this server again later, a full
File name: [#!variable!name!#], file UUID: [#!variable!uuid!#], size: [#!variable!size!#]]]>
Enabling the enable-safe-start daemon.
+ Calling select ScanCore scan agents to ensure the database is updated.
Starting: [#!variable!program!#].
@@ -2390,6 +2391,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
The job: [#!variable!command!#] (with job UUID: [#!variable!job_uuid!#]) is being skipped for now, already started a job (started job_uuid: [#!variable!started_job!#]) with this command on this loop.
There are no databases available at this time.
The server: [#!variable!server!#] needs it's pacemaker configuration updated. Running: [#!variable!command!#].
+ Running the scan-agent: [#!variable!agent!#] now to ensure that the database has an updated view of resources.
The host name: [#!variable!target!#] does not resolve to an IP address.
diff --git a/tools/anvil-delete-server b/tools/anvil-delete-server
index c066c6f4..f7fdd899 100755
--- a/tools/anvil-delete-server
+++ b/tools/anvil-delete-server
@@ -240,6 +240,27 @@ WHERE
unlink $resource_file;
}
+ # Call scan-cluster, scan-network and scan-server to make sure the databases are updated.
+ $anvil->Job->update_progress({
+ progress => 90,
+ message => "job_0464",
+ });
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
+ foreach my $agent ("scan-cluster", "scan-network", "scan-server")
+ {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
+
+ my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
+
+ my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ output => $output,
+ return_code => $return_code,
+ }});
+ }
+
+ # We're done
$anvil->Job->update_progress({
progress => 100,
message => "job_0216",
diff --git a/tools/anvil-provision-server b/tools/anvil-provision-server
index f1ad17c0..452e1577 100755
--- a/tools/anvil-provision-server
+++ b/tools/anvil-provision-server
@@ -324,6 +324,26 @@ sub run_jobs
# Add the server to the cluster.
add_server_to_cluster($anvil);
+ # Update the database by calling select scan agents
+ $anvil->Job->update_progress({
+ progress => 95,
+ message => "job_0464",
+ });
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
+ foreach my $agent ("scan-drbd", "scan-cluster", "scan-network", "scan-server")
+ {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
+
+ my $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
+
+ my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ output => $output,
+ return_code => $return_code,
+ }});
+ }
+
# Done!
$anvil->Job->update_progress({
progress => 100,
@@ -1408,6 +1428,24 @@ sub create_lv
$anvil->nice_exit({exit_code => 1});
}
+ # Call scan-lvm now to make sure we've recorded this LV.
+ $anvil->Job->update_progress({
+ progress => 28,
+ message => "job_0464",
+ });
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0464"});
+ my $agent = "scan-lvm";
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0740", variables => { agent => $agent }});
+
+ $shell_call = $anvil->data->{path}{directories}{scan_agents}."/".$agent."/".$agent.$anvil->Log->switches();
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
+
+ ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ output => $output,
+ return_code => $return_code,
+ }});
+
# Report
$anvil->Job->update_progress({
progress => 30,