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/src/packages/exec-lvm/commands/get-physical-volumes.js

46 lines
1.2 KiB
JavaScript

"use strict";
const Promise = require("bluebird");
const execBinary = require("../../exec-binary");
const parseIECBytes = require("../../parse-bytes-iec");
const asJson = require("../modifiers/as-json");
const mapFlag = require("../map-flag");
module.exports = function () {
return Promise.try(() => {
return execBinary("pvs")
.asRoot()
.withModifier(asJson((result) => {
return {
volumes: result.report[0].pv.map((volume) => {
return {
path: volume.pv_name,
volumeGroup: (volume.vg_name === "") ? null : volume.vg_name,
format: volume.pv_fmt,
// FIXME: These amounts can contain commas depending on locale (eg. https://serverfault.com/a/648302)
totalSpace: parseIECBytes(volume.pv_size),
freeSpace: parseIECBytes(volume.pv_free),
status: mapFlag(volume.pv_attr, 0, {
d: "DUPLICATE",
a: "ALLOCATABLE",
u: "USED"
}),
isExported: mapFlag(volume.pv_attr, 1, {
x: true,
"-": false
}),
isMissing: mapFlag(volume.pv_attr, 2, {
m: true,
"-": false
}),
};
})
};
}))
.execute();
}).then((output) => {
return output.result;
});
};