- # Build the beginning remote command
- my $remoteCmd = "/usr/bin/".basename($0);
- #print "Remote command is $remoteCmd\n";
-
- my $host = shift(@ARGV);
- die "Hostname argument required" if (!defined($host));
- die "No command to execute after hostname" if ($#ARGV < 0);
-
- # Find $host in the list of VEs
- loadVeList();
- my $ve = getVeByHostname($host);
- die "VE $host not found" if (!defined($ve));
- #printVeEntry($ve);
-
- # The command line is bisected by the next occurrence of $host. Everything
- # before is the ssh command (sans what to run on the VE) and everything
- # after is the xfer command to run on the VE.
- my @sshCmd;
- my @xferCmd;
- my $foundHost = 0;
- foreach my $arg (@ARGV) {
- if ($arg eq $host) {
- $foundHost = 1;
- } else {
- if ($foundHost) {
- push(@xferCmd, $arg);
- } else {
- push(@sshCmd, $arg);
- }
- }
- }
- die "No ssh command found" if ($#sshCmd < 0);
- die "No xfer command found" if ($#xferCmd < 0);
- #print "ssh command: |".join(' ', @sshCmd)."|\n";
- #print "xfer command: |".join(' ', @xferCmd)."|\n";
-
- # Create command line to initiate the remote side of the backup. The
- # remote side runs on the VE's HN and is given the VE's VEID.
- my $cmd = join(' ', @sshCmd)." ".$ve->{'HN'}." $remoteCmd ".
- ($restore ? "restore " : "").$ve->{'VEID'}." ".join(' ', @xferCmd);
- #print "remote command: |$cmd|\n";
-
- ## Search and replace
- #foreach my $key (keys %{$velist[0]}) {
- # my $val = $ve->{$key};
- # $cmd =~ s/\@$key\@/$val/g if (defined($val));
- #}
-
- cmdExecOrEval($cmd);
-}
-
-# A hard-coded test; didn't seem to help
-sub runServer_test($)
-{
- my ($restore) = @_;
-
- # Build the beginning remote command
- my $remoteCmd = "/usr/bin/".basename($0);
- #print "Remote command is $remoteCmd\n";
-