"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; }); };