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.
28 lines
639 B
JavaScript
28 lines
639 B
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
const memoizee = require("memoizee");
|
|
|
|
const lvm = require("../../../packages/exec-lvm");
|
|
const All = require("../../../packages/graphql-interface/symbols/all");
|
|
|
|
module.exports = function () {
|
|
let getVolumeGroupsOnce = memoizee(lvm.getVolumeGroups);
|
|
|
|
return function (names) {
|
|
return Promise.try(() => {
|
|
return getVolumeGroupsOnce();
|
|
}).then((result) => {
|
|
return result.groups;
|
|
}).then((groups) => {
|
|
return names.map((name) => {
|
|
if (name === All) {
|
|
return groups;
|
|
} else {
|
|
return groups.find((group) => group.name === name);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|