mirror of
https://github.com/democratic-csi/democratic-csi.git
synced 2026-10-19 15:39:53 +02:00
prep work for aggregate drivers
This commit is contained in:
@@ -351,7 +351,10 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||
case "snapshot":
|
||||
try {
|
||||
let tmpDetachedClone = JSON.parse(
|
||||
call.request.parameters.detachedVolumesFromSnapshots
|
||||
driver.getParameterValue(
|
||||
call.request.parameters,
|
||||
"detachedVolumesFromSnapshots"
|
||||
)
|
||||
);
|
||||
if (typeof tmpDetachedClone === "boolean") {
|
||||
detachedClone = tmpDetachedClone;
|
||||
@@ -462,7 +465,10 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||
case "volume":
|
||||
try {
|
||||
let tmpDetachedClone = JSON.parse(
|
||||
call.request.parameters.detachedVolumesFromVolumes
|
||||
driver.getParameterValue(
|
||||
call.request.parameters,
|
||||
"detachedVolumesFromVolumes"
|
||||
)
|
||||
);
|
||||
if (typeof tmpDetachedClone === "boolean") {
|
||||
detachedClone = tmpDetachedClone;
|
||||
@@ -1357,7 +1363,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||
let detachedSnapshot = false;
|
||||
try {
|
||||
let tmpDetachedSnapshot = JSON.parse(
|
||||
call.request.parameters.detachedSnapshots
|
||||
driver.getParameterValue(call.request.parameters, "detachedSnapshots")
|
||||
); // snapshot class parameter
|
||||
if (typeof tmpDetachedSnapshot === "boolean") {
|
||||
detachedSnapshot = tmpDetachedSnapshot;
|
||||
|
||||
@@ -18,7 +18,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
|
||||
* into various calls such as GetControllerCapabilities etc
|
||||
*/
|
||||
getDriverZfsResourceType() {
|
||||
switch (this.ctx.args.driver) {
|
||||
switch (this.options.driver) {
|
||||
case "freenas-nfs":
|
||||
return "filesystem";
|
||||
case "freenas-iscsi":
|
||||
@@ -35,7 +35,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
|
||||
}
|
||||
|
||||
getDriverShareType() {
|
||||
switch (this.ctx.args.driver) {
|
||||
switch (this.options.driver) {
|
||||
case "freenas-nfs":
|
||||
return "nfs";
|
||||
case "freenas-iscsi":
|
||||
|
||||
@@ -21,6 +21,36 @@ class CsiBaseDriver {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* abstract way of retrieving values from parameters/secrets
|
||||
* in order of preference:
|
||||
* - democratic-csi.org/{instance_id}/{key}
|
||||
* - democratic-csi.org/{driver}/{key}
|
||||
* - {key}
|
||||
*
|
||||
* @param {*} parameters
|
||||
* @param {*} key
|
||||
*/
|
||||
getParameterValue(parameters, key) {
|
||||
const base_key = "democratic-csi.org";
|
||||
|
||||
if (
|
||||
this.options.instance_id &&
|
||||
parameters[`${base_key}/${this.options.instance_id}/${key}`]
|
||||
) {
|
||||
return parameters[`${base_key}/${this.options.instance_id}/${key}`];
|
||||
}
|
||||
|
||||
if (
|
||||
this.options.driver &&
|
||||
parameters[`${base_key}/${this.options.driver}/${key}`]
|
||||
) {
|
||||
return parameters[`${base_key}/${this.options.driver}/${key}`];
|
||||
}
|
||||
|
||||
return parameters[key];
|
||||
}
|
||||
|
||||
async GetPluginInfo(call) {
|
||||
return {
|
||||
name: this.ctx.args.csiName,
|
||||
|
||||
Reference in New Issue
Block a user