mirror of
https://github.com/democratic-csi/democratic-csi.git
synced 2026-10-05 08:51:34 +02:00
local-hostpath driver
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
@@ -41,7 +41,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
|
||||
options.service.identity.capabilities.volume_expansion = [
|
||||
//"UNKNOWN",
|
||||
"ONLINE",
|
||||
//"ONLINE",
|
||||
//"OFFLINE"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -1,5 +1,8 @@
|
||||
const { FreeNASSshDriver } = require("./freenas/ssh");
|
||||
const { FreeNASApiDriver } = require("./freenas/api");
|
||||
const {
|
||||
ControllerLocalHostpathDriver,
|
||||
} = require("./controller-local-hostpath");
|
||||
const { ControllerZfsGenericDriver } = require("./controller-zfs-generic");
|
||||
const { ControllerZfsLocalDriver } = require("./controller-zfs-local");
|
||||
const {
|
||||
@@ -41,6 +44,8 @@ function factory(ctx, options) {
|
||||
return new ControllerSmbClientDriver(ctx, options);
|
||||
case "nfs-client":
|
||||
return new ControllerNfsClientDriver(ctx, options);
|
||||
case "local-hostpath":
|
||||
return new ControllerLocalHostpathDriver(ctx, options);
|
||||
case "lustre-client":
|
||||
return new ControllerLustreClientDriver(ctx, options);
|
||||
case "node-manual":
|
||||
|
||||
@@ -575,6 +575,17 @@ class CsiBaseDriver {
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "hostpath":
|
||||
result = await mount.pathIsMounted(staging_target_path);
|
||||
// if not mounted, mount
|
||||
if (!result) {
|
||||
await mount.bindMount(volume_context.path, staging_target_path);
|
||||
return {};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
||||
break;
|
||||
case "oneclient":
|
||||
let oneclient = new OneClient();
|
||||
@@ -1119,6 +1130,8 @@ class CsiBaseDriver {
|
||||
case "nfs":
|
||||
case "smb":
|
||||
case "lustre":
|
||||
case "oneclient":
|
||||
case "hostpath":
|
||||
case "iscsi":
|
||||
case "zfs-local":
|
||||
// ensure appropriate directories/files
|
||||
|
||||
Reference in New Issue
Block a user