@@ -14,6 +14,12 @@ A JavaScript library to interact with [VirtualBox](https://www.virtualbox.org/)
1414 - [Starting a cold machine: Two ways](#starting-a-cold-machine-two-ways)
1515 - [Stopping a machine](#stopping-a-machine)
1616 - [Pausing, Saving and Resuming a machine](#pausing-saving-and-resuming-a-machine)
17+ - [ Export a Machine] ( #export-a-machine )
18+ - [ Snapshot Manage] ( #snapshot-manage )
19+ - [ Cloning a VM] ( #cloning-vms )
20+ - [ Storage] ( #storage )
21+ - [Manage the IDE controller](#manage-the-ide-controller)
22+ - [Attach a disk image file](#attach-a-disk-image-file)
1723- [ Controlling the guest OS] ( #controlling-the-guest-os )
1824 - [A note about security :warning:](#a-note-about-security)
1925 - [Running programs in the guest](#running-programs-in-the-guest)
@@ -197,6 +203,66 @@ virtualbox.snapshotRestore("machine_name", "snapshot_name", function(error) {
197203});
198204```
199205
206+ ## Cloning VMs
207+
208+ Make a full clone (duplicate virtual hard drive) of a machine:
209+
210+ ``` javascript
211+ virtualbox .clone (" source_machine_name" , " new_machine_name" , function (error ) {
212+ if (error) throw error;
213+ console .log (' Done fully cloning the virtual machine!' );
214+ });
215+ ```
216+
217+ Make a linked clone (interdependent-differentially stored virtual hard drive) of a machine:
218+
219+ ``` javascript
220+ virtualbox .snapshotTake (" machine_name" , " snapshot_name" , function (error , uuid ) {
221+ if (error) throw error;
222+ console .log (' Snapshot has been taken!' );
223+ console .log (' UUID: ' , uuid);
224+ virtualbox .clone (" machine_name" , " new_machine_name" , " snapshot_name" , function (error ) {
225+ if (error) throw error;
226+ console .log (' Done making a linked clone of the virtual machine!' );
227+ });
228+ });
229+ ```
230+
231+ ## Storage
232+
233+ ### Manage the IDE controller
234+
235+ In case the VM doesn't have an IDE controller you can use the storagectl command to add one:
236+
237+ ``` javascript
238+ virtualbox .storage .addCtl ({
239+ vm: " machine_name" ,
240+ perhiperal_name: " IDE" , // optional
241+ type: " ide" // optional
242+ }, function (){
243+ console .log (' Controller has been added!' );
244+ })
245+ ```
246+
247+ ### Attach a disk image file
248+
249+ Mount an ISO file to the added controller:
250+
251+ ``` javascript
252+ virtualbox .storage .attach ({
253+ vm: " machine_name" ,
254+ perhiperal_name: " IDE" , // optional
255+ port: " 0" , // optional
256+ device: " 0" , // optional
257+ type: " dvddrive" , // optional
258+ medium: " X:\F older\c ontaining\t he.iso"
259+ }, function (){
260+ console .log (' Image has been mounted!' );
261+ })
262+ ```
263+
264+ The _ medium_ parameter of the options object can be set to the ** none** value to unmount.
265+
200266# Controlling the guest OS
201267
202268## A note about security :warning :
@@ -292,7 +358,7 @@ var options = {
292358 key: " /VirtualBox/GuestInfo/Net/0/V4/IP"
293359}
294360
295- virtualbox .guestproperty (function guestproperty_callback (machines , error ) {
361+ virtualbox .guestproperty . get (function guestproperty_callback (machines , error ) {
296362 if (error) throw error;
297363 // Act on machines
298364});
@@ -327,6 +393,8 @@ virtualbox.extradata.set(options, function extradataset_callback(error) {
327393});
328394```
329395
396+ _ Note: some properties are only available/effective if the Guest OS has the (https://www.virtualbox.org/manual/ch04.html)[Guest Additions] installed and running._
397+
330398# Putting it all together
331399
332400``` javascript
@@ -366,7 +434,7 @@ virtualbox.start("machine_name", function start_callback(error) {
366434- ` .poweroff({vm:"machine_name"}, callback) `
367435- ` .acpisleepbutton({vm:"machine_name"}, callback) `
368436- ` .acpipowerbutton({vm:"machine_name"}, callback) `
369- - ` .guestproperty({vm:"machine_name", property: "propname"}, callback) `
437+ - ` .guestproperty.get ({vm:"machine_name", property: "propname"}, callback) `
370438- ` .exec(){vm: "machine_name", cmd: "C:\\Program Files\\Internet Explorer\\iexplore.exe", params: "http://google.com"}, callback) `
371439- ` .exec(){vm: "machine_name", user:"Administrator", password: "123456", cmd: "C:\\Program Files\\Internet Explorer\\iexplore.exe", params: "http://google.com"}, callback) `
372440- ` .keyboardputscancode("machine_name", [scan_codes], callback) `
@@ -377,6 +445,9 @@ virtualbox.start("machine_name", function start_callback(error) {
377445- ` .snapshotTake({vm:"machine_name"}, {vm:"snapshot_name"}, callback) `
378446- ` .snapshotDelete({vm:"machine_name"}, {vm:"snapshot_UUID"}, callback) `
379447- ` .snapshotRestore({vm:"machine_name"}, {vm:"snapshot_UUID"}, callback) `
448+ - ` .clone({vm:"machine_name"}, {vm:"new_machine_name"}, callback) `
449+ - ` .storage.addCtl({vm: "machine_name", perhiperal_name: "IDE", type: "ide"}, callback) `
450+ - ` .storage.attach({vm: "machine_name", perhiperal_name: "IDE", port: "0", device: "0", type: "dvddrive", medium: "X:\Folder\containing\the.iso"}, callback) `
380451- ` .extradata.get({vm:"machine_name", key:"keyname"}, callback) `
381452- ` .extradata.set({vm:"machine_name", key:"keyname", value:"val"}, callback) `
382453
0 commit comments