Here are the examples of the java api com.linbit.extproc.ExtCmd taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
129 Examples
19
Source : ZfsVolumeInfo.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
@SuppressWarnings("checkstyle:magicnumber")
public static ZfsVolumeInfo getInfo(final ExtCmd ec, final String zfsCommand, final String pool, final String identifier) throws StorageException {
ZfsVolumeInfo volumeInfo;
final String[] command = getZfsVolumeInfoCommand(zfsCommand, pool, identifier);
try {
OutputData outputData = ec.exec(command);
if (outputData.exitCode != 0) {
StringBuilder commandBuilder = new StringBuilder();
for (String commandPart : command) {
commandBuilder.append(commandPart).append(" ");
}
throw new StorageException(String.format("Command returned with exitCode %d and message %s: %s", outputData.exitCode, new String(outputData.stderrData), commandBuilder.toString()));
}
String rawOut = new String(outputData.stdoutData);
if (rawOut.contains("\n")) {
rawOut = rawOut.substring(0, rawOut.indexOf('\n'));
}
String[] parts = rawOut.split("\t");
if (parts.length < 2) {
throw new StorageException("ZFS listing output has unexpected number of entries", "Pool: " + pool + ", zvol: " + identifier + "; output to parse: '" + rawOut + "'", null, null, "External command used: " + join(" ", command));
}
// convert to KiB
long size = Long.parseLong(parts[0]) >> 10;
// convert to KiB
long used = Long.parseLong(parts[1]) >> 10;
final String path = File.separator + "dev" + File.separator + "zvol" + File.separator + pool + File.separator + identifier;
volumeInfo = new ZfsVolumeInfo(size, used, identifier, path);
} catch (ChildProcessTimeoutException | IOException exc) {
throw new StorageException("Failed to get volume information", String.format("Failed to get information for volume: %s", identifier), (exc instanceof ChildProcessTimeoutException) ? "External command timed out" : "External command threw an IOException", null, String.format("External command: %s", join(" ", command)), exc);
}
return volumeInfo;
}
19
Source : LvsInfo.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static HashMap<String, LvsInfo> getAllInfo(final ExtCmd ec, final String lvmLvsCommand, final String volumeGroup) throws ChildProcessTimeoutException, IOException, StorageException {
final OutputData output = ec.exec(LvsInfo.getCommand(lvmLvsCommand, volumeGroup));
final String stdOut = new String(output.stdoutData);
final HashMap<String, LvsInfo> infoByIdentifier = new HashMap<>();
final String[] lines = stdOut.split("\n");
for (final String line : lines) {
final String[] data = line.trim().split(StorageUtils.DELIMITER);
final int expectedColCount = 3;
if (data.length >= expectedColCount) {
final String identifier = data[0];
final String path = data[1];
final String rawSize = data[2];
long size;
try {
size = StorageUtils.parseDecimalAsLong(rawSize.trim());
} catch (NumberFormatException nfExc) {
throw new StorageException("Unable to parse logical volume size", "Size to parse: '" + rawSize + "'", null, null, "External command used to query logical volume info: " + String.join(" ", lvmLvsCommand), nfExc);
}
final LvsInfo info = new LvsInfo(size, identifier, path);
infoByIdentifier.put(info.getIdentifier(), info);
}
}
return infoByIdentifier;
}
19
Source : DrbdVersion.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
/**
* Initializes the version variables
* majorVsn
* majorVsn
* patchLvl
*
* If the instance was unable to determine the DRBD version, an error will be raised,
* but only if DRBD is installed.
*/
public void checkVersion() {
ExtCmd cmd = new ExtCmd(timerRef, errorLogRef);
String value = null;
try {
restoreDefaults();
OutputData cmdData = cmd.exec(VSN_QUERY_COMMAND);
try (BufferedReader vsnReader = new BufferedReader(new InputStreamReader(cmdData.getStdoutStream()))) {
String key = KEY_VSN_CODE + "=";
for (String vsnLine = vsnReader.readLine(); vsnLine != null; vsnLine = vsnReader.readLine()) {
if (vsnLine.startsWith(key)) {
value = vsnLine.substring(key.length());
break;
}
}
if (value != null) {
if (value.startsWith("0x")) {
value = value.substring(2);
}
int vsnCode = Integer.parseInt(value, HEXADECIMAL);
majorVsn = (short) ((vsnCode >>> SHIFT_MAJOR_VSN) & MASK_VSN_ELEM);
minorVsn = (short) ((vsnCode >>> SHIFT_MINOR_VSN) & MASK_VSN_ELEM);
patchLvl = (short) (vsnCode & MASK_VSN_ELEM);
if (!hasDrbd9()) {
notSupportedReasons.add("DRBD version has to be >= 9. Current DRBD version: " + majorVsn + "." + minorVsn + "." + patchLvl);
}
}
}
} catch (NumberFormatException nfExc) {
errorLogRef.reportError(Level.ERROR, new LinStorException(LOG_TXT_CHECK_FAILED, ERR_DSC_CHECK_FAILED, "The value of the " + KEY_VSN_CODE + " field in the output of the " + DRBD_UTILS_CMD + "utility is unparsable", ERR_CORR_TXT, "The value of the " + KEY_VSN_CODE + " field is:\n" + value, nfExc));
} catch (IOException | ChildProcessTimeoutException exc) {
errorLogRef.logWarning("Unable to check drbdadm version. '" + exc.getMessage() + "'");
notSupportedReasons.add(exc.getClreplaced().getSimpleName() + " occurred when checking DRBD version");
}
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getPhysicalDevices(ExtCmd extCmdRef, String zPoolRef) throws StorageException {
final String failMsg = "Failed to query physical devices for zpool: " + zPoolRef;
return genericExecutor(extCmdRef, new String[] { "zpool", "list", // verbose, in order to include physical devices
"-v", // Display full paths for vdevs instead of only the last component of the path
"-P", // Scripted mode. Do not display headers, and separate fields by a single tab instead of arbitrary
"-H", // space.
// only "name" column
"-o", // only "name" column
"name", zPoolRef }, failMsg, failMsg);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData create(ExtCmd extCmd, String zpool, String identifier, long size, boolean thin, String... additionalParameters) throws StorageException {
String fullQualifiedId = zpool + File.separator + identifier;
ArrayList<String> cmdList = new ArrayList<>();
cmdList.add("zfs");
cmdList.add("create");
if (thin) {
cmdList.add("-s");
}
cmdList.add("-V");
cmdList.add(size + "KB");
cmdList.addAll(Arrays.asList(additionalParameters));
cmdList.add(fullQualifiedId);
return genericExecutor(extCmd, cmdList.toArray(new String[0]), "Failed to create zfsvolume", "Failed to create new zfs volume '" + fullQualifiedId + "' with size " + size + "kb");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData rollback(ExtCmd extCmd, String zPool, String vlmId, String snapName) throws StorageException {
String fullQualifiedSnapSource = zPool + File.separator + vlmId + "@" + snapName;
return genericExecutor(extCmd, new String[] { "zfs", "rollback", fullQualifiedSnapSource }, "Failed to rollback to snapshot '" + fullQualifiedSnapSource + "'", "Failed to rollback to snapshot '" + fullQualifiedSnapSource + "'");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData restoreSnapshot(ExtCmd extCmd, String zPool, String sourceLvName, String sourceSnapName, String targetLvName) throws StorageException {
String fullQualifiedSourceSnapId = zPool + File.separator + sourceLvName + "@" + sourceSnapName;
String fullQualifiedTargetLvId = zPool + File.separator + targetLvName;
return genericExecutor(extCmd, new String[] { "zfs", "clone", fullQualifiedSourceSnapId, fullQualifiedTargetLvId }, "Failed to restore snapshot '" + fullQualifiedSourceSnapId + "' into '" + fullQualifiedTargetLvId + "'", "Failed to restore snapshot '" + fullQualifiedSourceSnapId + "' into '" + fullQualifiedTargetLvId + "'");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getExtentSize(ExtCmd extCmd, String zpool, String identifier) throws StorageException {
String fullQualifiedId;
if (identifier == null || identifier.trim().isEmpty()) {
fullQualifiedId = zpool;
} else {
fullQualifiedId = zpool + File.separator + identifier;
}
return genericExecutor(extCmd, new String[] { "zfs", "get", "volblocksize", "-o", "value", "-Hp", fullQualifiedId }, "Failed to query zfs extent size", "Failed to query extent size of zfs volume " + fullQualifiedId);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData resize(ExtCmd extCmd, String zpool, String identifier, long size) throws StorageException {
String fullQualifiedId = zpool + File.separator + identifier;
return genericExecutor(extCmd, new String[] { "zfs", "set", "volsize=" + size + "KB", fullQualifiedId }, "Failed to resize zfs volume", "Failed to resize zfs volume '" + fullQualifiedId + "' to size " + size);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData createSnapshot(ExtCmd extCmd, String zPool, String srcIdentifier, String snapName) throws StorageException {
String fullQualifiedId = zPool + File.separator + srcIdentifier + "@" + snapName;
return genericExecutor(extCmd, new String[] { "zfs", "snapshot", fullQualifiedId }, "Failed to create snapshot '" + fullQualifiedId + "'", "Failed to create snapshot '" + fullQualifiedId + "'");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData rename(ExtCmd extCmd, String zpool, String currentId, String newId) throws StorageException {
String fullQualifiedCurrentId = zpool + File.separator + currentId;
String fullQualifiedNewId = zpool + File.separator + newId;
return genericExecutor(extCmd, new String[] { "zfs", "rename", fullQualifiedCurrentId, fullQualifiedNewId }, "Failed to rename zfs volume from '" + fullQualifiedCurrentId + "' to '" + fullQualifiedNewId + "'", "Failed to rename zfs volume from '" + fullQualifiedCurrentId + "' to '" + fullQualifiedNewId + "'");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData deleteZPool(ExtCmd extCmd, final String zpoolName) throws StorageException {
final String failMsg = "Failed to destroy zpool: " + zpoolName;
return genericExecutor(extCmd, new String[] { "zpool", "destroy", zpoolName }, failMsg, failMsg);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData createZPool(ExtCmd extCmd, final List<String> devicePaths, // ignore for now as we only support JBOD yet
final RaidLevel raidLevel, final String zpoolName) throws StorageException {
final String failMsg = "Failed to create zpool: " + zpoolName;
return genericExecutor(extCmd, StringUtils.concat(new String[] { "zpool", "create", // force otherwise zpool will cry about possible parreplacedion on device
"-f", zpoolName }, devicePaths), failMsg, failMsg);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getZPoolTotalSize(ExtCmd extCmd, Set<String> zpools) throws StorageException {
return genericExecutor(extCmd, StringUtils.concat(new String[] { "zpool", "get", "size", "-Hp" }, zpools), "Failed to query total size of zpool(s) " + zpools, "Failed to query total size of zpool(s) " + zpools);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getZPoolFreeSize(ExtCmd extCmd, Set<String> zPools) throws StorageException {
return genericExecutor(extCmd, StringUtils.concat(new String[] { "zfs", "get", "available", "-o", "name,value", "-Hp" }, zPools), "Failed to query free size of zPool(s) " + zPools, "Failed to query free size of zPools(s) " + zPools);
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData list(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { "zfs", "list", // no headers, single tab instead of spaces
"-H", // sizes in bytes
"-p", // columns: name, allocated space, available space, type
"-o", // columns: name, allocated space, available space, type
"name,used,volsize,type", "-t", "volume,snapshot" }, "Failed to list zfs volumes", "Failed to query 'zfs' info");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData listThinPools(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { "zfs", "list", // no headers, single tab instead of spaces
"-H", // sizes in bytes
"-p", // columns: name, available space, type
"-o", // columns: name, available space, type
"name,available,type", "-t", "filesystem" }, "Failed to list zfs filesystem types", "Failed to query 'zfs' info");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData listZpools(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { "zpool", "list", "-o", "name", "-H" }, "Failed to query list of zpools", "Failed to query list of zpools");
}
19
Source : ZfsCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData delete(ExtCmd extCmd, String zpool, String identifier) throws StorageException {
String fullQualifiedId = zpool + File.separator + identifier;
return genericExecutor(extCmd, new String[] { "zfs", "destroy", fullQualifiedId }, "Failed to delete zfs volume", "Failed to delete zfs volume '" + fullQualifiedId + "'", new RetryIfDeviceBusy());
}
19
Source : StltProviderUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static long getAllocatedSize(String blockdef, ExtCmd extCmd) throws StorageException {
return Commands.getBlockSizeInKib(extCmd, blockdef);
}
19
Source : StltProviderUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static long getAllocatedSize(VlmProviderObject<?> vlmData, ExtCmd extCmd) throws StorageException {
long size;
if (vlmData.exists()) {
size = getAllocatedSize(vlmData.getDevicePath(), extCmd);
} else {
throw new StorageException("Device does not exist.", "Device does not exist.", "The volume could not be found on the system.", null, null);
}
return size;
}
19
Source : MkfsUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static ExtCmd.OutputData makeXfs(ExtCmd extCmd, String devicePath, String additionalParams) throws StorageException {
return makeFs(extCmd, "xfs", devicePath, additionalParams);
}
19
Source : MkfsUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static ExtCmd.OutputData makeExt4(ExtCmd extCmd, String devicePath, String additionalParams) throws StorageException {
return makeFs(extCmd, "ext4", devicePath, additionalParams);
}
19
Source : LsBlkUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static List<LsBlkEntry> lsblk(ExtCmd extCmd) throws StorageException {
ExtCmd.OutputData outputData = Commands.genericExecutor(extCmd, new String[] { "lsblk", "-P", "-b", "--paths", "-o", Arrays.stream(LsBlkEntry.LsBlkFields.values()).map(LsBlkEntry.LsBlkFields::toString).collect(Collectors.joining(",")) }, "Failed execute lsblk", "Failed to execute lsblk");
return parseLsblkOutput(new String(outputData.stdoutData, StandardCharsets.UTF_8));
}
19
Source : DmStatCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static void create(ExtCmd extCmd, String devPath) throws StorageException {
genericExecutor(extCmd, getDmstatCreateCommand(devPath), "Failed to call dmstat create " + devPath, "Failed to call dmstat create");
}
19
Source : DmStatCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static void delete(ExtCmd extCmd, String devPath) throws StorageException {
genericExecutor(extCmd, getDmstatDeleteCommand(devPath), "Failed to call dmstat delete " + devPath, "Failed to call dmstat delete");
}
19
Source : Commands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static long getBlockSizeInKib(ExtCmd extCmd, String devicePath) throws StorageException {
long sizeKiB;
if (devicePath.startsWith(SPDK_PATH_PREFIX)) {
sizeKiB = SpdkUtils.getBlockSizeByName(extCmd, devicePath.split(SPDK_PATH_PREFIX)[1]);
} else {
OutputData output = genericExecutor(extCmd, new String[] { "blockdev", "--getsize64", devicePath }, "Failed to get block size of " + devicePath, "Failed to get block size of " + devicePath);
String outRaw = new String(output.stdoutData);
sizeKiB = SizeConv.convert(Long.parseLong(outRaw.trim()), SizeUnit.UNIT_B, SizeUnit.UNIT_KiB);
}
return sizeKiB;
}
19
Source : Commands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData wipeFs(ExtCmd extCmd, Collection<String> devicePaths) throws StorageException {
return genericExecutor(extCmd, StringUtils.concat(new String[] { "wipefs", "-a", "-f" }, devicePaths), "Failed to wipeFs of " + String.join(", ", devicePaths), "Failed to wipeFs of " + String.join(", ", devicePaths));
}
19
Source : Commands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData genericExecutor(ExtCmd extCmd, String[] command, String failMsgExitCode, String failMsgExc, RetryHandler retryHandler) throws StorageException {
return genericExecutor(extCmd, command, failMsgExitCode, failMsgExc, retryHandler, Collections.emptyList());
}
19
Source : Commands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static long getDeviceSizeInSectors(ExtCmd extCmd, String devicePath) throws StorageException {
OutputData output = genericExecutor(extCmd, new String[] { "blockdev", "--getsz", devicePath }, "Failed to get device size of " + devicePath, "Failed to get device size of " + devicePath);
String outRaw = new String(output.stdoutData);
return Long.parseLong(outRaw.trim());
}
19
Source : Commands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData genericExecutor(ExtCmd extCmd, String[] command, String failMsgExitCode, String failMsgExc) throws StorageException {
return genericExecutor(extCmd, command, failMsgExitCode, failMsgExc, NO_RETRY);
}
19
Source : SpdkUtils.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static List<String> lspci(ExtCmd extCmd) throws StorageException {
ExtCmd.OutputData outputData = Commands.genericExecutor(extCmd, new String[] { "lspci", "-mm", "-n", "-D" }, "Failed to execute lspci", "Failed to execute lspci");
return parseNvmeDrivesAddresses(new String(outputData.stdoutData, StandardCharsets.UTF_8));
}
19
Source : SpdkConfigReader.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static void checkVolumeGroupEntry(ExtCmd extCmd, Props props) throws StorageException {
String volumeGroup;
try {
volumeGroup = props.getProp(StorageConstants.CONFIG_LVM_VOLUME_GROUP_KEY).split("/")[0];
} catch (InvalidKeyException exc) {
throw new ImplementationError("Invalid hardcoded storPool prop key", exc);
}
if (volumeGroup != null) {
volumeGroup = volumeGroup.trim();
try {
Checks.nameCheck(volumeGroup, 1, Integer.MAX_VALUE, VALID_CHARS, VALID_INNER_CHARS);
} catch (InvalidNameException invalidNameExc) {
final String cause = String.format("Invalid name for volume group: %s", volumeGroup);
throw new StorageException("Invalid configuration, " + cause, null, cause, "Specify a valid and existing volume group name", null);
}
// throws an exception if volume group does not exist
SpdkUtils.checkVgExists(extCmd, volumeGroup);
}
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData lvolStoreRemove(ExtCmd extCmd, String lvolStoreName) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "destroy_lvol_store", "-l", lvolStoreName }, "Failed to remove lvol store", "Failed to remove lvol store '" + lvolStoreName + "'");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData nvmeBdevRemove(ExtCmd extCmd, String controllerName) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "delete_nvme_controller", controllerName }, "Failed to remove nvme bdev", "Failed to remove nvme bdev '" + controllerName + "'");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getNvmfSubsystems(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "get_nvmf_subsystems" }, "Failed to query nvmf subsystems", "Failed to query nvmf subsystems");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData resize(ExtCmd extCmd, String volumeGroup, String vlmId, long size) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "resize_lvol_bdev", volumeGroup + File.separator + vlmId, // KiB
String.valueOf(size / 1024) }, "Failed to resize lvol bdev", "Failed to resize lvol bdev '" + vlmId + "' in lvol store '" + volumeGroup + "' to size " + size);
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData delete(ExtCmd extCmd, String volumeGroup, String vlmId) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "destroy_lvol_bdev", volumeGroup + File.separator + vlmId }, "Failed to delete lvol bdev", "Failed to delete lvm volume '" + vlmId + "' from volume group '" + volumeGroup, new RetryIfDeviceBusy());
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData rename(ExtCmd extCmd, String volumeGroup, String vlmCurrentId, String vlmNewId) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "rename_lvol_bdev", volumeGroup + File.separator + vlmCurrentId, vlmNewId }, "Failed to rename lvm volume from '" + vlmCurrentId + "' to '" + vlmNewId + "'", "Failed to rename lvm volume from '" + vlmCurrentId + "' to '" + vlmNewId + "'", new RetryHandler() {
@Override
public boolean retry(OutputData outputData) {
return false;
}
@Override
public boolean skip(OutputData outData) {
boolean skip = false;
byte[] stdoutData = outData.stdoutData;
String output = new String(stdoutData);
if (output.contains("Lvol store group \"" + volumeGroup + "\" not found")) {
// well - resource is gone... with the whole volume-group
skip = true;
}
return skip;
}
});
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData createFat(ExtCmd extCmd, String volumeGroup, String vlmId, long size, String... additionalParameters) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "construct_lvol_bdev", vlmId, // KiB
String.valueOf(size / 1024), "--lvs-name", volumeGroup }, "Failed to create lvol bdev", "Failed to create new lvol bdev'" + vlmId + "' in lovl store '" + volumeGroup + "' with size " + size + "mb");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData lvsByName(ExtCmd extCmd, String name) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "get_bdevs", "--name", name }, "Failed to list bdevs", "Failed to query 'get_bdevs' info");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData listRaidBdevsAll(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "get_raid_bdevs", "all" }, "Failed to read RAID bdevs", "Failed to read RAID bdevs");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData createThin(ExtCmd extCmd, String volumeGroup, String thinPoolName, String vlmId, long size, String... additionalParameters) throws StorageException {
return genericExecutor(extCmd, StringUtils.concat(new String[] { SPDK_RPC_SCRIPT, "construct_lvol_bdev", vlmId, // KiB
String.valueOf(size / 1024), "--lvs-name", volumeGroup, "--thin-provision" }, additionalParameters), "Failed to create lvol bdev", "Failed to create new lvol bdev'" + vlmId + "' in lovl store '" + volumeGroup + "' with size " + size + "mb");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData lvolStoreCreate(ExtCmd extCmd, String bdevName, String lvolStoreName) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "construct_lvol_store", bdevName, lvolStoreName }, "Failed to create lvol store", "Failed to create new lvol store '" + lvolStoreName + "' on bdev '" + bdevName + "'");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData nvmeBdevCreate(ExtCmd extCmd, String pciAddress) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "construct_nvme_bdev", "--trtype", "PCIe", "--traddr", pciAddress, "--name", pciAddress }, "Failed to create nvme bdev", "Failed to create new nvme bdev with PCI address '" + pciAddress + "'");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData createTransport(ExtCmd extCmd, String type) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "nvmf_create_transport", "--trtype", type }, "Failed to create transport'" + type, "Failed to create transport '" + type + "'", new Commands.SkipExitCodeRetryHandler() {
@Override
public boolean retry(OutputData outputData) {
return false;
}
@Override
public boolean skip(OutputData outData) {
boolean skip = false;
byte[] stdoutData = outData.stdoutData;
String output = new String(stdoutData);
if (output.contains("already exists")) {
// transport type RDMA is already present
skip = true;
}
return skip;
}
});
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData getLvolStores(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "get_lvol_stores" }, "Failed to query lvol stores extent size", "Failed to query extent size of volume group(s)");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData nvmeRaidBdevRemove(ExtCmd extCmd, String raidBdevName) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "destroy_raid_bdev", raidBdevName }, "Failed to remove RAID nvme bdev", "Failed to remove RAID nvme bdev '" + raidBdevName + "'");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData lvs(ExtCmd extCmd) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "get_bdevs" }, "Failed to list bdevs", "Failed to query 'get_bdevs' info");
}
19
Source : SpdkCommands.java
with GNU General Public License v3.0
from LINBIT
with GNU General Public License v3.0
from LINBIT
public static OutputData nvmeRaidBdevCreate(ExtCmd extCmd, String raidBdevName, List<String> baseBdevs) throws StorageException {
return genericExecutor(extCmd, new String[] { SPDK_RPC_SCRIPT, "construct_raid_bdev", "--name", raidBdevName, // SPDK v19.07 supports only RAID 0
"--raid-level", // SPDK v19.07 supports only RAID 0
"0", "--strip-size_kb", "64", "--base-bdevs", String.join(" ", baseBdevs) }, "Failed to create RAID nvme bdev", "Failed to create new RAID nvme bdev '" + raidBdevName + "' from bdevs: " + String.join(", ", baseBdevs));
}
See More Examples