You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cvm/lib/disk-store.js

40 lines
863 B
JavaScript

'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) {
}
}
}