local-hostpath driver

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen
2022-02-22 18:10:54 -07:00
parent ee549cc694
commit d35feec00c
7 changed files with 121 additions and 4 deletions
@@ -0,0 +1,65 @@
const _ = require("lodash");
const { ControllerClientCommonDriver } = require("../controller-client-common");
const NODE_TOPOLOGY_KEY_NAME = "org.democratic-csi.topology/node";
/**
* Crude local-hostpath driver which simply creates directories to be mounted
* and uses rsync for cloning/snapshots
*/
class ControllerLocalHostpathDriver extends ControllerClientCommonDriver {
constructor(ctx, options) {
const i_caps = _.get(
options,
"service.identity.capabilities.service",
false
);
super(...arguments);
if (!i_caps) {
this.ctx.logger.debug("setting local-hostpath identity service caps");
options.service.identity.capabilities.service = [
//"UNKNOWN",
"CONTROLLER_SERVICE",
"VOLUME_ACCESSIBILITY_CONSTRAINTS",
];
}
}
getConfigKey() {
return "local-hostpath";
}
getVolumeContext(name) {
const driver = this;
const config_key = driver.getConfigKey();
return {
node_attach_driver: "hostpath",
path: driver.getShareVolumePath(name),
};
}
getFsTypes() {
return [];
}
/**
* Add node topologies
*
* @param {*} call
* @returns
*/
async NodeGetInfo(call) {
const response = await super.NodeGetInfo(...arguments);
response.accessible_topology = {
segments: {
[NODE_TOPOLOGY_KEY_NAME]: response.node_id,
},
};
return response;
}
}
module.exports.ControllerLocalHostpathDriver = ControllerLocalHostpathDriver;