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/add-volume-to-volume-group.js

29 lines
1.2 KiB
JavaScript

"use strict";
const Promise = require("bluebird");
const execBinary = require("../../exec-binary");
const unattendedFlags = require("../modifiers/unattended-flags");
const handleDeviceNotFound = require("../modifiers/handle-device-not-found");
const handleVolumeGroupNotFound = require("../modifiers/handle-volume-group-not-found");
const handlePhysicalVolumeInUse = require("../modifiers/handle-physical-volume-in-use");
const handlePartitionExists = require("../modifiers/handle-partition-exists");
const handleIncompatibleDevice = require("../modifiers/handle-incompatible-device");
module.exports = function ({ physicalVolume, volumeGroup }) {
return Promise.try(() => {
return execBinary("vgextend", [volumeGroup, physicalVolume])
.asRoot()
.requireResult()
.withModifier(unattendedFlags)
.withModifier(handleDeviceNotFound(physicalVolume))
.withModifier(handleVolumeGroupNotFound(volumeGroup))
.withModifier(handlePhysicalVolumeInUse(physicalVolume))
.withModifier(handlePartitionExists(physicalVolume, "add device to Volume Group"))
.withModifier(handleIncompatibleDevice(physicalVolume, "added to the Volume Group"))
.execute();
}).then((_output) => {
return true;
});
};