Changeset 42041 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 6, 2012 4:22:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/webservice/samples/perl/clienttest.pl
r32394 r42041 6 6 # programming reference (SDKRef.pdf) for how to use this sample. 7 7 # 8 # Copyright (C) 2008-201 0Oracle Corporation8 # Copyright (C) 2008-2012 Oracle Corporation 9 9 # 10 10 # The following license applies to this file only: … … 51 51 " $cmd version: print version of VirtualBox web service.\n". 52 52 " $cmd list: list installed virtual machines.\n". 53 " $cmd startvm <vm>: start the virtual machine named <vm>.\n"; 53 " $cmd startvm <vm>: start the virtual machine named <vm>.\n". 54 " $cmd acpipowerbutton <vm>: shutdown of the irtual machine named <vm>.\n"; 54 55 exit 0; 55 56 } … … 60 61 $optMode = $this; 61 62 } 62 elsif ($this eq 'startvm') 63 elsif ( ($this eq 'startvm') 64 || ($this eq 'acpipowerbutton') 65 ) 63 66 { 64 67 $optMode = $this; … … 113 116 elsif ($optMode eq "startvm") 114 117 { 115 # assume it's a UUID 116 my $machine = vboxService->IVirtualBox_getMachine($vbox, $vmname); 117 if (!$machine) 118 { 119 # no: then try a name 120 $machine = vboxService->IVirtualBox_findMachine($vbox, $vmname); 121 } 118 my $machine = vboxService->IVirtualBox_findMachine($vbox, $vmname); 122 119 123 120 die "[$cmd] Cannot find VM \"$vmname\"; stopped" … … 134 131 print "[$cmd] UUID: $uuid\n"; 135 132 136 my $progress = vboxService->IVirtualBox_openRemoteSession($vbox, 137 $session, 138 $uuid, 139 "vrdp", 140 ""); 141 die "[$cmd] Cannot open remote session; stopped" 133 my $progress = vboxService->IMachine_launchVMProcess($machine, 134 $session, 135 "headless", 136 ""); 137 die "[$cmd] Cannot launch VM; stopped" 142 138 if (!$progress); 143 139 144 print("[$cmd] Waiting for the remote session to open...\n");140 print("[$cmd] Waiting for the VM to start...\n"); 145 141 vboxService->IProgress_waitForCompletion($progress, -1); 146 142 … … 154 150 print("[$cmd] Result: $resultCode\n"); 155 151 156 vboxService->ISession_close($session); 152 vboxService->ISession_unlockMachine($session); 153 154 vboxService->IWebsessionManager_logoff($vbox); 155 } 156 elsif ($optMode eq "acpipowerbutton") 157 { 158 my $machine = vboxService->IVirtualBox_findMachine($vbox, $vmname); 159 160 die "[$cmd] Cannot find VM \"$vmname\"; stopped" 161 if (!$machine); 162 163 my $session = vboxService->IWebsessionManager_getSessionObject($vbox); 164 die "[$cmd] Cannot get session object; stopped" 165 if (!$session); 166 167 my $shared = SOAP::Data->type('vbox:LockType')->name('session')->value('Shared'); 168 vboxService->IMachine_lockMachine($machine, $session, $shared); 169 170 my $console = vboxService->ISession_getConsole($session); 171 172 vboxService->IConsole_powerButton($console); 173 174 vboxService->ISession_unlockMachine($session); 157 175 158 176 vboxService->IWebsessionManager_logoff($vbox); … … 160 178 elsif ($optMode eq "openhd") 161 179 { 162 my $harddisk = vboxService->IVirtualBox_openHardDisk($vbox, $disk, 1, 0, "", 0, ""); 180 my $medium = vboxService->IVirtualBox_openMedium($vbox, $disk, 3, # DeviceType_HardDisk 181 1, # AccessMode_ReadWrite 182 0, # false 183 "", # empty uuid 184 0, # false 185 ""); #empty uuid 163 186 }
Note:
See TracChangeset
for help on using the changeset viewer.