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.
90 lines
3.2 KiB
JavaScript
90 lines
3.2 KiB
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
const execBinary = require("../../exec-binary");
|
|
const parseIECBytes = require("../../parse-bytes-iec");
|
|
const parseIntStrict = require("../../parse-int-strict");
|
|
|
|
const asJson = require("../modifiers/as-json");
|
|
const mapFlag = require("../map-flag");
|
|
const parseOptionalString = require("../parse-optional-string");
|
|
const parseStringList = require("../parse-string-list");
|
|
|
|
module.exports = function () {
|
|
return Promise.try(() => {
|
|
return execBinary("vgs")
|
|
.asRoot()
|
|
.withFlags({
|
|
options: "vg_all"
|
|
})
|
|
.withModifier(asJson((result) => {
|
|
return {
|
|
groups: result.report[0].vg.map((group) => {
|
|
return {
|
|
name: group.vg_name,
|
|
uuid: group.vg_uuid,
|
|
systemID: parseOptionalString(group.vg_systemid),
|
|
metadataRevision: parseIntStrict(group.vg_seqno),
|
|
tags: parseStringList(group.vg_tags),
|
|
configurationProfile: parseOptionalString(group.vg_profile),
|
|
// FIXME: vg_lock_type, vg_lock_args
|
|
// FIXME: These amounts can contain commas depending on locale (eg. https://serverfault.com/a/648302)
|
|
totalSpace: parseIECBytes(group.vg_size),
|
|
freeSpace: parseIECBytes(group.vg_free),
|
|
extentSize: parseIECBytes(group.vg_extent_size),
|
|
totalExtents: parseIntStrict(group.vg_extent_count),
|
|
freeExtents: parseIntStrict(group.vg_free_count),
|
|
freeMetadataSpace: parseIECBytes(group.vg_mda_free),
|
|
smallestMetadataSize: parseIECBytes(group.vg_mda_size),
|
|
totalMetadataAreas: parseIntStrict(group.vg_mda_count),
|
|
usedMetadataAreas: parseIntStrict(group.vg_mda_used_count),
|
|
usedMetadataAreasTarget: (group.vg_mda_copies === "unmanaged" ? undefined : parseIntStrict(group.vg_mda_copies)),
|
|
physicalVolumeCount: parseIntStrict(group.pv_count),
|
|
physicalVolumeLimit: (group.max_pv === "0") ? Infinity : parseIntStrict(group.max_pv),
|
|
missingPhysicalVolumes: parseIntStrict(group.vg_missing_pv_count),
|
|
logicalVolumeCount: parseIntStrict(group.lv_count),
|
|
logicalVolumeLimit: (group.max_lv === "0") ? Infinity : parseIntStrict(group.max_lv),
|
|
snapshotCount: parseIntStrict(group.snap_count),
|
|
isExtendable: (group.vg_extendable === "extendable"),
|
|
isReadOnly: mapFlag(group.vg_attr, 0, {
|
|
// Permissions: (w)riteable, (r)ead-only
|
|
r: true,
|
|
w: false
|
|
}),
|
|
isResizeable: mapFlag(group.vg_attr, 1, {
|
|
// Resi(z)eable
|
|
z: true,
|
|
"-": false
|
|
}),
|
|
isExported: mapFlag(group.vg_attr, 2, {
|
|
// E(x)ported
|
|
x: true,
|
|
"-": false
|
|
}),
|
|
isIncomplete: mapFlag(group.vg_attr, 3, {
|
|
// (p)artial: one or more physical volumes belonging to the volume group are missing from the system
|
|
p: true,
|
|
"-": false
|
|
}),
|
|
allocationPolicy: mapFlag(group.vg_attr, 4, {
|
|
// Allocation policy: (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere
|
|
c: "CONTIGUOUS",
|
|
l: "CLING",
|
|
n: "NORMAL",
|
|
a: "ANYWHERE"
|
|
}),
|
|
mode: mapFlag(group.vg_attr, 5, {
|
|
c: "CLUSTERED",
|
|
s: "SHARED",
|
|
"-": "LOCAL"
|
|
})
|
|
};
|
|
})
|
|
};
|
|
}))
|
|
.execute();
|
|
}).then((output) => {
|
|
return output.result;
|
|
});
|
|
};
|