'use strict'; const Promise = require("bluebird"); const uuid = require("uuid"); const childProcess = Promise.promisifyAll(require("child-process"), {multiArgs: true}); module.exports = function(storePath) { function getPath(id) { return path.join(storePath, `${id}.img`); } return { getPath: function getDisk(id) { return getPath(id); }, create: function createDisk(size, {type} = {type: "qcow2"}) { return Promise.try(() => { let diskId = uuid.v4(); return Promise.try(() => { childProcess.execFileAsync("qemu-img", [ "create", "-f", type, getPath(diskId), size ]); }).then(([stdout, stderr]) => { return diskId; }); }); }, resize: function resizeDisk(id, size) { } } }