+sub handle_novaboot_server
+{
+ my ($n, $val) = @_;
+ my $xdg_runtime_dir = $ENV{XDG_RUNTIME_DIR} || '/var/run';
+ my $ssh_ctl_path = "${xdg_runtime_dir}/novaboot$$";
+
+ @remote_cmd = ('ssh', '-tt', '-M', '-S', $ssh_ctl_path, $val, 'console');
+ $remote_expect = "novaboot-shell: Connected";
+ $server = "$val:";
+ $rsync_flags = "--rsh='ssh -S \'${ssh_ctl_path}\''";
+ ($grub_prefix = $val) =~ s|(.*)@.*|\/$1\/| if index($val, '@') != -1;
+ @reset_cmd = ('ssh', '-tt', '-S', $ssh_ctl_path, $val, 'reset');
+
+ $target_power_off = sub { system_verbose('ssh', '-tt', '-S', $ssh_ctl_path, $val, 'off'); };
+ $target_power_on = sub { system_verbose('ssh', '-tt', '-S', $ssh_ctl_path, $val, 'on'); };
+
+ my $cmd = "ssh '${val}' get-config";
+ print STDERR "novaboot: Running: $cmd\n";
+ my @target_config = qx($cmd < /dev/null);
+ if ($?) { die("Cannot get target configuration from the server"); }
+ printf "novaboot: Received configuration from the server:%s\n", (!@target_config) ? " empty" : "";
+ foreach (@target_config) { chomp; print " $_\n"; }
+
+ my $p = Getopt::Long::Parser->new;
+ $p->configure(qw/no_ignore_case no_pass_through/);
+ $p->getoptionsfromarray(\@target_config, %opt_spec_safe) or die("Error processing configuration from the server");
+
+ if (scalar @target_config) { die "Unsuported configuration received from the server: ".join(", ", @target_config); }
+}
+