From e6ea5024b71f68107eef9b03166b478044e9fc03 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Wed, 11 Feb 2015 15:24:29 -0800 Subject: [PATCH] Temporary removal of VirtualBox --- src/Virtualbox.js | 66 ----------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/Virtualbox.js diff --git a/src/Virtualbox.js b/src/Virtualbox.js deleted file mode 100644 index a1d20bb427..0000000000 --- a/src/Virtualbox.js +++ /dev/null @@ -1,66 +0,0 @@ -var fs = require('fs'); -var util = require('./Util'); -var Promise = require('bluebird'); - -var VirtualBox = { - command: function () { - return '/usr/bin/VBoxManage'; - }, - installed: function () { - return fs.existsSync('/usr/bin/VBoxManage') && fs.existsSync('/Applications/VirtualBox.app'); - }, - version: function () { - return new Promise((resolve, reject) => { - util.exec([this.command(), '-v']).then(stdout => { - var match = stdout.match(/(\d+\.\d+\.\d+).*/); - if (!match || match.length < 2) { - reject('VBoxManage -v output format not recognized.'); - } - resolve(match[1]); - }).catch(reject); - }); - }, - poweroffall: function () { - if (!this.installed()) { - return Promise.reject('VirtualBox not installed.'); - } - return util.exec(this.command() + ' list runningvms | sed -E \'s/.*\\{(.*)\\}/\\1/\' | xargs -L1 -I {} ' + this.command() + ' controlvm {} poweroff'); - }, - killall: function () { - if (!this.installed()) { - return Promise.reject('VirtualBox not installed.'); - } - return this.poweroffall().then(() => { - return util.exec(['pkill', 'VirtualBox']); - }).then(() => { - return util.exec(['pkill', 'VBox']); - }); - }, - vmstate: function (name) { - return new Promise((resolve, reject) => { - util.exec([this.command(), 'showvminfo', name, '--machinereadable']).then(stdout => { - var match = stdout.match(/VMState="(\w+)"/); - if (!match) { - reject('Could not parse VMState'); - } - resolve(match[1]); - }).catch(reject); - }); - }, - vmdestroy: function (name) { - return Promise.coroutine(function* () { - if (!this.installed()) { - return Promise.reject('VirtualBox not installed.'); - } - try { - var state = yield this.vmstate(name); - if (state === 'running') { - yield util.exec([this.command(), 'controlvm', name, 'poweroff']); - } - yield util.exec([this.command(), 'unregistervm', name, '--delete']); - } catch (err) {} - }.bind(this))(); - } -}; - -module.exports = VirtualBox;