Added a call to Remote->add_target_to_known_hosts in Remote->test_access

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 6bc2601d34
commit b5ce2c4871
  1. 7
      Anvil/Tools/Remote.pm
  2. 9
      man/anvil-manage-server-system.8
  3. 69
      tools/anvil-manage-server-system

@ -1007,6 +1007,13 @@ sub test_access
user => $user,
}});
# Make sure we've got the target in our known_hosts file.
$anvil->Remote->add_target_to_known_hosts({
debug => $debug,
target => $target,
user => getpwuid($<),
});
# Call the target
my ($output, $error, $return_code) = $anvil->Remote->call({
debug => $debug,

@ -24,18 +24,19 @@ Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a s
.SS "Commands:"
.TP
\fB\-\-boot\-menu\fR <yes,no>
.TP
When called without a value, it shows if the boot menu is enabled or not. If called with 'yes', it enables the boot menu. If called with 'no', the boot meny is disabled.
.TP
\fB\-\-boot\-order\fR <dev1,dev2,...,devN>
.TP
When called without a value, it shows if the current order of boot devices. To set a new boot device order, use a comma-separated list of boot devices. Note that any boot devices that are not specified will be moved in their original order to boot after the specified devices are moved up. For this reason, you can just specify the device you want to boot, and it will be moved to the front of the list.
.TP
\fB\-\-job\-uuid\fR
This is the jobs -> job_uuid to execute. Generally this is only used by other programs.
.TP
\fB\-\-\fR
\fB\-\-ram\fR <size>
If this is called without a value, the current RAM allocated to the server is displayed. If it is passed with a size, and if that size is available, the amount of RAM allocated to the server will be updated.
.TP
.BR
The size can be in bytes, or a human-readible size, using base-2 notation. Ie: '8GiB' (no space) and '8589934592' are the same.
.IP
.SH AUTHOR
Written by Madison Kelly, Alteeve staff and the Anvil! project contributors.

@ -49,6 +49,7 @@ $anvil->Get->switches({list => [
"grow",
"insert",
"optical",
"ram",
"server",
"storage-group",
], man => $THIS_FILE});
@ -107,7 +108,7 @@ if ($anvil->data->{switches}{cpu})
}
elsif ($anvil->data->{switches}{ram})
{
#manage_ram($anvil);
manage_ram($anvil);
}
elsif ($anvil->data->{switches}{'boot-order'})
{
@ -134,6 +135,72 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub manage_ram
{
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};
my $server_uuid = $anvil->data->{switches}{server_uuid};
my $server_host_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_host_uuid};
my $anvil_uuid = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_anvil_uuid};
my $anvil_name = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_name};
my $server_host_name = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:short_host_name' => $short_host_name,
's2:host_uuid' => $host_uuid,
's3:server_name' => $server_name,
's4:server_uuid' => $server_uuid,
's5:server_host_uuid' => $server_host_uuid,
's6:anvil_uuid' => $anvil_uuid,
's7:anvil_name' => $anvil_name,
}});
my $from_source = get_definition_source($anvil);
my $server_state = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_state};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
from_source => $from_source,
server_state => $server_state,
}});
if ($server_state eq "running")
{
$server_host_name = $anvil->Database->get_host_from_uuid({
short => 1,
host_uuid => $server_host_uuid,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_host_name => $server_host_name }});
}
# Get available resources.
$anvil->Get->available_resources({
debug => 2,
anvil_uuid => $anvil_uuid,
});
# The RAM In the database is stored in KiB
my $server_ram_in_use = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_ram_in_use};
my $server_configured_ram = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_configured_ram};
my $server_definition_ram = $anvil->data->{server}{$short_host_name}{$server_name}{$from_source}{memory};
my $ram_available = $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server_ram_in_use => $server_ram_in_use." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_ram_in_use}).")",
server_configured_ram => $server_configured_ram." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_configured_ram}).")",
server_definition_ram => $server_definition_ram." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_definition_ram}).")",
ram_available => $ram_available." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $ram_available}).")",
}});
if ($anvil->data->{switches}{ram} eq "#!SET!#")
{
print "RAM:\n";
print "- In Use: ... [".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_ram_in_use})."]\n";
print "- Configured: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_configured_ram})."]\n";
print "- Defined: .. [".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_definition_ram})."]\n";
print "- Available: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $ram_available})."]\n";
}
return(0);
}
sub manage_boot_order
{
my ($anvil) = @_;

Loading…
Cancel
Save