Skip to content

Commit

Permalink
Made requests to (un)plug network interfaces reassign the request to the
Browse files Browse the repository at this point in the history
server's host when requested elsewhere in the cluster.

This resolves issue #740.

Signed-off-by: Madison Kelly <[email protected]>
  • Loading branch information
digimer-bot committed Jan 8, 2025
1 parent 87618bf commit 6a67391
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Anvil/Tools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,10 @@ sub _set_paths
'anvil-manage-firewall' => "/usr/sbin/anvil-manage-firewall",
'anvil-manage-host' => "/usr/sbin/anvil-manage-host",
'anvil-manage-keys' => "/usr/sbin/anvil-manage-keys",
'anvil-manage-server' => "/usr/sbin/anvil-manage-server",
'anvil-manage-server-network' => "/usr/sbin/anvil-manage-server-network",
'anvil-manage-server-storage' => "/usr/sbin/anvil-manage-server-storage",
'anvil-manage-server-system' => "/usr/sbin/anvil-manage-server-system",
'anvil-manage-power' => "/usr/sbin/anvil-manage-power",
'anvil-manage-vnc-pipe' => "/usr/sbin/anvil-manage-vnc-pipe",
'anvil-migrate-server' => "/usr/sbin/anvil-migrate-server",
Expand Down
8 changes: 4 additions & 4 deletions share/words.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Failed to generate an RSA public key for the user: [#!variable!user!#]. The outp
<key name="error_0077">Unable to connect to the database, unable to read the details of the key to remove.</key>
<key name="error_0078">Asked to plug in an interface from: [#!variable!server!#] but there was a problem parsing the definition file. More details are likely in the logs.</key>
<key name="error_0079">Job data not found for job_uuid: [#!variable!job_uuid!#].</key>
<key name="error_0080">Asked to unplug an interface from: [#!variable!server!#] but the server is not running here. It's running on: [#!variable!host_name!#] (#!variable!host_uuid!#). Please run this on that host.</key>
<key name="error_0080">#!free!#</key>
<key name="error_0081">The job_uuid: [#!variable!job_uuid!#] appears valid, but there was no job_data.</key>
<key name="error_0082">The state UUID: [#!variable!state_uuid!#] does not appear to be a valid UUID.</key>
<key name="error_0083">No (good) state UUIDs found, unable to run this job.</key>
Expand Down Expand Up @@ -1398,7 +1398,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0134">Successfully deleted the file: [#!variable!file_path!#].</key>
<key name="job_0135">No need to delete the file: [#!variable!file_path!#], it already doesn't exist.</key>
<key name="job_0136"><![CDATA[The server: [#!variable!server!#] appears to be running on: [#!variable!host_name!#], assigned the job: [#!variable!job_uuid!#] to that host.]]></key>
<key name="job_0137">#!free!#</key>
<key name="job_0137">The job for the peer: [#!variable!host_name!#] has been created with the UUID: [#!variable!job_uuid!#].</key>
<key name="job_0138">#!free!#</key>
<key name="job_0139">#!free!#</key>
<key name="job_0140">No need to rename the file: [#!variable!file_path!#], it doesn't exist on this host.</key>
Expand Down Expand Up @@ -2995,8 +2995,8 @@ About to try to download approximately: [#!variable!packages!#] packages needed
<key name="message_0144">- The current gateway is: [#!variable!current_gateway!#], but this is not the gateway interface. Will remove it.</key>
<key name="message_0145">- This is the gateway interface, but there is no gateway yet. Will configure it as: [#!variable!new_gateway!#].</key>
<key name="message_0146">Updating out password in the config file: [#!variable!file!#] on the host: [#!variable!host_name!#] now... </key>
<key name="message_0147">#!free!#</key>
<key name="message_0148">#!free!#</key>
<key name="message_0147">[ Note ] - Asked to unplug an interface from: [#!variable!server!#] but the server is not running here. It's running on: [#!variable!host_name!#] (#!variable!host_uuid!#). Creating a job for that host to unplug the interface.</key>
<key name="message_0148">[ Note ] - Asked to plug in an interface from: [#!variable!server!#] but the server is not running here. It's running on: [#!variable!host_name!#] (#!variable!host_uuid!#). Creating a job for that host to plug in the interface.</key>
<key name="message_0149">The target: [#!variable!target!#]'s host key has changed. If the target has been rebuilt, or the target IP reused, the old key will need to be removed. If this is the case, remove line: [#!variable!line!#] from: [#!variable!file!#].</key>
<key name="message_0150">#!free!#</key>
<key name="message_0151">#!free!#</key>
Expand Down
45 changes: 41 additions & 4 deletions tools/anvil-manage-server-network
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,52 @@ sub handle_plug_unplug
# Lastly, are we the host?
if ($server_host_uuid ne $anvil->Get->host_uuid)
{
# No, reassign the job.
$anvil->Job->update_progress({
progress => 99,
message => $task eq "plug" ? "message_0148" : "message_0147",
job_status => "reassigned",
log_level => 1,
'print' => 1,
variables => {
server => $anvil->data->{switches}{server_name},
host_name => $server_host_name,
host_uuid => $server_host_uuid,
},
});

my $say_add = $anvil->data->{switches}{add} ? "true" : "";
my $say_plug = $anvil->data->{switches}{plug} ? "true" : "";
my $say_remove = $anvil->data->{switches}{remove} ? "true" : "";
my $say_unplug = $anvil->data->{switches}{unplug} ? "true" : "";
my $job_data = "add=".$say_add."\n";
$job_data .= "bridge=".$anvil->data->{switches}{bridge}."\n";
$job_data .= "confirm=true\n";
$job_data .= "mac=".$anvil->data->{switches}{mac}."\n";
$job_data .= "model=".$anvil->data->{switches}{model}."\n";
$job_data .= "plug=".$say_plug."\n";
$job_data .= "remove=".$say_remove."\n";
$job_data .= "server=".$anvil->data->{switches}{server}."\n";
$job_data .= "unplug=".$say_unplug;
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
debug => 2,
job_command => $anvil->data->{path}{exe}{$THIS_FILE}.$anvil->Log->switches,
job_data => $job_data,
job_host_uuid => $server_host_uuid,
job_progress => 0,
job_name => "server::".$server_uuid."::set_interface_state",
job_title => "job_0505",
job_description => "job_0506",
});

$anvil->Job->update_progress({
progress => 100,
message => $task eq "plug" ? "error_0078" : "error_0022",
job_status => "failed",
message => "job_0137",
log_level => 1,
'print' => 1,
priority => "err",
variables => {
server => $anvil->data->{switches}{server_name},
host_name => $server_host_name,
job_uuid => $job_uuid,
},
});
$anvil->nice_exit({exit_code => 1});
Expand Down
13 changes: 13 additions & 0 deletions tools/anvil-manage-server-storage
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,19 @@ sub manage_disk_add
'print' => 1,
});
update_definition($anvil, "undefine", $virsh_definition);

# Copy the new definition to the other host(s)
$anvil->Job->update_progress({
progress => $anvil->Job->bump_progress({steps => 2}),
message => "log_0808",
log_level => 1,
'print' => 1,
});
$anvil->Server->update_definition({
debug => 2,
server => $server_name,
new_definition_xml => $virsh_definition,
});

# Done!
$anvil->Job->update_progress({
Expand Down

0 comments on commit 6a67391

Please sign in to comment.