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.
26 lines
920 B
JavaScript
26 lines
920 B
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
const execBinary = require("../../exec-binary");
|
|
|
|
const forceFlags = require("../modifiers/force-flags");
|
|
const unattendedFlags = require("../modifiers/unattended-flags");
|
|
const handleDeviceNotFound = require("../modifiers/handle-device-not-found");
|
|
const handlePartitionExists = require("../modifiers/handle-partition-exists");
|
|
const handleDeviceInUse = require("../modifiers/handle-device-in-use");
|
|
|
|
module.exports = function ({ devicePath, force }) {
|
|
return Promise.try(() => {
|
|
return execBinary("pvcreate", [devicePath])
|
|
.asRoot()
|
|
.requireResult()
|
|
.withModifier((force === true) ? forceFlags : unattendedFlags)
|
|
.withModifier(handleDeviceNotFound(devicePath))
|
|
.withModifier(handleDeviceInUse(devicePath))
|
|
.withModifier(handlePartitionExists(devicePath, "create a Physical Volume"))
|
|
.execute();
|
|
}).then((_output) => {
|
|
return true;
|
|
});
|
|
};
|