diff --git a/Anvil/Tools/Server.pm b/Anvil/Tools/Server.pm index 6004c131..6fa1ecc8 100644 --- a/Anvil/Tools/Server.pm +++ b/Anvil/Tools/Server.pm @@ -3089,6 +3089,7 @@ sub update_definition }}); # Define the server + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0818", variables => { server_name => $server_name }}); eval { $anvil->data->{libvirtd}{$short_host_name}{connection}->define_domain($new_definition_xml); }; if ($@) { @@ -3099,6 +3100,66 @@ sub update_definition error => $@, }}); } + else + { + if (not ref($anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}) eq "Sys::Virt::Domain") + { + # Connect to the server. + my @domains = $anvil->data->{libvirtd}{$short_host_name}{connection}->list_all_domains(); + foreach my $domain_handle (@domains) + { + my $this_server_name = $domain_handle->get_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + domain_handle => $domain_handle, + this_server_name => $this_server_name, + }}); + if ($this_server_name eq $server_name) + { + $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection} = $domain_handle; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "libvirtd::${short_host_name}::server::${server_name}::connection" => $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}, + }}); + last; + } + } + + } + + # If this connection still valid? + if (ref($anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}) eq "Sys::Virt::Domain") + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0819", variables => { server_name => $server_name }}); + my $uuid = ""; + eval { $uuid = $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}->get_uuid_string(); }; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "uuid" => $uuid }}); + if ((not $@) && ($uuid)) + { + # Connection is good. + my $updated = $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}->is_updated(); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "updated" => $updated }}); + if ($updated) + { + eval { $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}->undefine; }; + if ($@) + { + # Throw an error, then clear the URI so that we just update the DB/on-disk definitions. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "warning_0167", variables => { + host_name => $short_host_name, + server_name => $server_name, + error => $@, + }}); + } + else + { + my $updated = $anvil->data->{libvirtd}{$short_host_name}{server}{$server_name}{connection}->is_updated(); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "updated" => $updated }}); + + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0817", variables => { server_name => $server_name }}); + } + } + } + } + } } } } diff --git a/share/words.xml b/share/words.xml index aba0d9c7..411bf4a0 100644 --- a/share/words.xml +++ b/share/words.xml @@ -2629,6 +2629,9 @@ The file: [#!variable!file!#] needs to be updated. The difference is: There is an existing a functioning connection to: [#!variable!target!#], no need to reconnect. There is an existing a functioning connection to the server: [#!variable!server_name!#], no need to reconnect. Waiting for: [#!variable!delay!#] seconds. + The server: [#!variable!server_name!#] libvirt definition was updated, undefining static config. + The server: [#!variable!server_name!#] libvirt definition will now be updated. + Check to verify that the connection to the server: [#!variable!server_name!#] is valid. The host name: [#!variable!target!#] does not resolve to an IP address. @@ -3960,6 +3963,11 @@ We will try to proceed anyway. ==== #!variable!error!# ==== + + Failed to undefine the running server: [#!variable!server_name!#] on the host: [#!variable!host_name!#]. The error, if any, was: +==== +#!variable!error!# +==== diff --git a/tools/anvil-delete-server b/tools/anvil-delete-server index 4b7bdc89..c7065796 100755 --- a/tools/anvil-delete-server +++ b/tools/anvil-delete-server @@ -36,6 +36,10 @@ $anvil->Get->switches({list => [ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => $anvil->data->{switches}}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }}); +### TODO: Remove this post testing +$anvil->Log->level({set => 2}); +$anvil->Log->secure({set => 1}); + $anvil->Database->connect(); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 3, secure => 0, key => "log_0132"}); if (not $anvil->data->{sys}{database}{connections})