'use strict'; const Promise = require("bluebird"); const uuid = require("uuid"); const defaultValue = require("default-value"); 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, options = {}) { return Promise.try(() => { let imageFormat = defaultValue(options.format, "qcow2"); let diskId = uuid.v4(); return Promise.try(() => { childProcess.execFileAsync("qemu-img", [ "create", "-f", imageFormat, getPath(diskId), size ]); }).then(([stdout, stderr]) => { return diskId; }); }); }, resize: function resizeDisk(id, size) { } } }