|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Promise = require("bluebird");
|
|
|
|
const dlayer = require("dlayer");
|
|
|
|
const All = require("../packages/graphql-interface/symbols/all");
|
|
|
|
const loaders = require("./data-sources");
|
|
|
|
const types = require("./types");
|
|
|
|
const execLVM = require("../packages/exec-lvm");
|
|
|
|
const { validateValue } = require("@validatem/core");
|
|
|
|
const isString = require("@validatem/is-string");
|
|
|
|
const isBoolean = require("@validatem/is-boolean");
|
|
|
|
const required = require("@validatem/required");
|
|
|
|
const defaultTo = require("@validatem/default-to");
|
|
|
|
|
|
|
|
function typeFromSource(source, ids, factoryFunction) {
|
|
|
|
return Promise.try(() => {
|
|
|
|
if (ids != null) {
|
|
|
|
return source.loadMany(ids);
|
|
|
|
} else {
|
|
|
|
return source.load(All); // FIXME: Symbol
|
|
|
|
}
|
|
|
|
}).then((items) => {
|
|
|
|
return items.map((item) => factoryFunction(item));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function () {
|
|
|
|
return dlayer({
|
|
|
|
makeContext: function () {
|
|
|
|
return {
|
|
|
|
sources: loaders()
|
|
|
|
};
|
|
|
|
},
|
|
|
|
modules: [
|
|
|
|
require("../packages/sysquery-lvm"),
|
|
|
|
require("../packages/sysquery-core"),
|
|
|
|
],
|
|
|
|
schema: {
|
|
|
|
hardware: {
|
|
|
|
// drives: ({ paths }, { sources }) => {
|
|
|
|
// return typeFromSource(sources.smartctlScan, paths, (device) => types.Drive({ path: device.path }));
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
resources: {
|
|
|
|
images: {
|
|
|
|
installationMedia: [],
|
|
|
|
vmImages: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// let schemaTodo = {
|
|
|
|
// system: {
|
|
|
|
// hardware: { ... },
|
|
|
|
// lvm: {
|
|
|
|
// ...
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// resources: {
|
|
|
|
// storagePools: {
|
|
|
|
// name: "...",
|
|
|
|
// type: "lvm|folder",
|
|
|
|
// isLocal: true,
|
|
|
|
// folderPath: "...",
|
|
|
|
// lvmVolumeGroup: LVMVolumeGroup,
|
|
|
|
// $$update: {
|
|
|
|
// $arguments: {
|
|
|
|
// name: "..."
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// $$delete: {},
|
|
|
|
// $collection: {
|
|
|
|
// $$create: {
|
|
|
|
// $arguments: {
|
|
|
|
// name: "poolName",
|
|
|
|
// volumeGroup: "name",
|
|
|
|
// // or:
|
|
|
|
// folderPath: "path"
|
|
|
|
// }
|
|
|
|
// // standard fields for a storage pool entry go here, including LVMVolumeGroup resolution!
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// networkPools: { ... },
|
|
|
|
// storageVolumes: {
|
|
|
|
// id: 0,
|
|
|
|
// userID: 0,
|
|
|
|
// pool: StoragePool,
|
|
|
|
// poolID: 0, // the index/ID within the pool
|
|
|
|
// size: 0, // bytes-iec
|
|
|
|
// },
|
|
|
|
// instances: {
|
|
|
|
// id: 0,
|
|
|
|
// userID: 0,
|
|
|
|
// state: "running|stopped|creating",
|
|
|
|
// storageVolumes: StorageVolume, // in boot order
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// };
|