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.
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
const { errorResult } = require("../../text-parser");
|
|
const createRegexParser = require("../../text-parser-regex");
|
|
|
|
const errors = require("../errors");
|
|
|
|
module.exports = function (physicalVolume) {
|
|
return function handlePhysicalVolumeInUse(command) {
|
|
return command
|
|
.expectOnStderr(createRegexParser(/Physical volume '([^']+)' is already in volume group '([^']+)'/, (match) => {
|
|
let [ _device, existingVolumeGroup ] = match.subMatches;
|
|
|
|
return errorResult(new errors.PhysicalVolumeInUse(`Specified Physical Volume '${physicalVolume}' is already in use in another Volume Group (${existingVolumeGroup})`, {
|
|
volume: {
|
|
device: physicalVolume,
|
|
volumeGroup: existingVolumeGroup
|
|
}
|
|
}));
|
|
}))
|
|
.expectOnStderr(createRegexParser(/PV (.+) is used by VG (.+) so please use vgreduce first\./, (match) => {
|
|
let [ _device, existingVolumeGroup ] = match.subMatches;
|
|
|
|
// FIXME: Improve context structure here?
|
|
return errorResult(new errors.PhysicalVolumeInUse(`Specified Physical Volume '${physicalVolume}' is still in use in Volume Group '${existingVolumeGroup}'`, {
|
|
volume: {
|
|
device: physicalVolume,
|
|
volumeGroup: existingVolumeGroup
|
|
}
|
|
}));
|
|
}));
|
|
};
|
|
};
|
|
|
|
// /dev/loop0 is used by VG vg-name so please use vgreduce first.
|