clienttest.pl revision 92a27575521748a392dcd1b996fce55b87411a00
#
# This little perl program attempts to connect to a running VirtualBox
# webservice and calls various methods on it.
#
# To get this to run:
#
# 0) If not yet among perl's modules, install SOAP::Lite. Users of debian
# based systems might try 'sudo apt-get install libsoap-lite-perl'.
#
# 1) In this directory, run
# stubmaker file:///path/to/sdk/bindings/webservice/vboxwebService.wsdl
# Note: the command is named stubmaker.pl on some systems.
# stubmaker should be installed on your system if you have SOAP::Lite and
# will, after a little while of thinking, create a vboxService.pm
# file in the current directory, which the "use" statement below
# then includes.
#
# (SOAP::Lite supports parsing the WSDL file on every run of
# the script, but it takes up to a minute to do so, hence the external
# variant via stubmaker.pl here.)
#
# 2) Start vboxwebsrv.
#
# 3) Run this script.
#
#
# Copyright (C) 2006-2009 Sun Microsystems, Inc.
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
use strict;
use vboxService;
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");
}