clienttest.pl revision 9e891b3b323c4dbee732df7ef95037134d21e5aa
#
# This little perl program attempts to connect to a running VirtualBox
# webservice and calls various methods on it. Please refer to the SDK
# programming reference (SDKRef.pdf) for how to use this sample.
#
# Copyright (C) 2008-2009 Sun Microsystems, Inc.
#
# The following license applies to this file only:
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
use strict;
use vboxService; # generated by stubmaker, see SDKRef.pdf
my $cmd = 'clienttest';
my $optMode;
my $vmname;
{
{
print "$cmd: test the VirtualBox web service.\n".
"Usage:\n".
" $cmd <mode>\n".
"with <mode> being one of 'version', 'list', 'start'; default is 'list'.\n".
" $cmd version: print version of VirtualBox web service.\n".
" $cmd list: list installed virtual machines.\n".
" $cmd startvm <vm>: start the virtual machine named <vm>.\n";
exit 0;
}
elsif ( ($this eq 'version')
|| ($this eq 'list')
)
{
}
elsif ($this eq 'startvm')
{
{
die "[$cmd] Missing parameter: You must specify the name of the VM to start.\nStopped";
}
}
else
{
die "[$cmd] Unknown option \"$this\"; stopped";
}
}
$optMode = "list"
if (!$optMode);
if (!$vbox)
{
die "[$cmd] Logon to session manager with user \"test\" and password \"test\" failed.\nStopped";
}
if ($optMode eq "version")
{
print "[$cmd] Version number of running VirtualBox web service: $v\n";
}
elsif ($optMode eq "list")
{
print "[$cmd] Listing machines:\n";
{
print "machine $if $idMachine: $name\n";
}
}
elsif ($optMode eq "startvm")
{
# assume it's a UUID
if (!$machine)
{
# no: then try a name
}
die "[$cmd] Cannot find VM \"$vmname\"; stopped"
if (!$machine);
die "[$cmd] Cannot get session object; stopped"
if (!$session);
die "[$cmd] Cannot get uuid for machine; stopped"
if (!$uuid);
print "[$cmd] UUID: $uuid\n";
$session,
$uuid,
"vrdp",
"");
die "[$cmd] Cannot open remote session; stopped"
if (!$progress);
print("[$cmd] Waiting for the remote session to open...\n");
my $fCompleted;
print("[$cmd] Completed: $fCompleted\n");
my $resultCode;
print("[$cmd] Result: $resultCode\n");
}