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/api/types/block-device.js

44 lines
1007 B
JavaScript

"use strict";
const {createDataObject, LocalProperties, ID} = require("../../graphql/data-object");
const deviceNameFromPath = require("../../device-name-from-path");
const mapValue = require("../../map-value");
module.exports = function (_types) {
return function BlockDevice({ name, path }) {
if (name != null) {
path = `/dev/${name}`;
} else if (path != null) {
name = deviceNameFromPath(path);
}
/* FIXME: parent */
return createDataObject({
[LocalProperties]: {
path: path
},
lsblk: {
[ID]: name,
name: "name",
type: (device) => {
return mapValue(device.type, {
partition: "PARTITION",
disk: "DISK",
loopDevice: "LOOP_DEVICE"
});
},
size: "size",
mountpoint: "mountpoint",
deviceNumber: "deviceNumber",
removable: "removable",
readOnly: "readOnly",
children: (device) => {
return device.children.map((child) => {
return BlockDevice({ name: child.name });
});
}
}
});
};
};