prep work for aggregate drivers
This commit is contained in:
parent
cb0032ed77
commit
ff63654455
|
|
@ -53,5 +53,10 @@ COPY --chown=csi:csi . .
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
|
||||||
|
# remove build deps
|
||||||
|
#RUN apt-get update && \
|
||||||
|
# apt-get purge -y python make gcc g++ && \
|
||||||
|
# rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
EXPOSE 50051
|
EXPOSE 50051
|
||||||
ENTRYPOINT [ "bin/democratic-csi" ]
|
ENTRYPOINT [ "bin/democratic-csi" ]
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,6 @@ const args = require("yargs")
|
||||||
.env("DEMOCRATIC_CSI")
|
.env("DEMOCRATIC_CSI")
|
||||||
.scriptName("democratic-csi")
|
.scriptName("democratic-csi")
|
||||||
.usage("$0 [options]")
|
.usage("$0 [options]")
|
||||||
.option("driver", {
|
|
||||||
alias: "d",
|
|
||||||
describe: "driver",
|
|
||||||
choices: ["freenas-nfs", "freenas-iscsi"]
|
|
||||||
})
|
|
||||||
.demandOption(["driver"], "driver is required")
|
|
||||||
.option("driver-config-file", {
|
.option("driver-config-file", {
|
||||||
describe: "provide a path to driver config file",
|
describe: "provide a path to driver config file",
|
||||||
config: true,
|
config: true,
|
||||||
|
|
@ -105,7 +99,7 @@ const { FreeNASDriver } = require("../src/driver/freenas");
|
||||||
logger.info("initializing csi driver: %s", args.driver);
|
logger.info("initializing csi driver: %s", args.driver);
|
||||||
|
|
||||||
let driver;
|
let driver;
|
||||||
switch (args.driver) {
|
switch (options.driver) {
|
||||||
case "freenas-nfs":
|
case "freenas-nfs":
|
||||||
case "freenas-iscsi":
|
case "freenas-iscsi":
|
||||||
driver = new FreeNASDriver({ logger, args, cache, package }, options);
|
driver = new FreeNASDriver({ logger, args, cache, package }, options);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
driver: freenas-iscsi
|
||||||
|
instance_id:
|
||||||
httpConnection:
|
httpConnection:
|
||||||
protocol: http
|
protocol: http
|
||||||
host: server address
|
host: server address
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
driver: freenas-nfs
|
||||||
|
instance_id:
|
||||||
httpConnection:
|
httpConnection:
|
||||||
protocol: http
|
protocol: http
|
||||||
host: server address
|
host: server address
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,10 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
case "snapshot":
|
case "snapshot":
|
||||||
try {
|
try {
|
||||||
let tmpDetachedClone = JSON.parse(
|
let tmpDetachedClone = JSON.parse(
|
||||||
call.request.parameters.detachedVolumesFromSnapshots
|
driver.getParameterValue(
|
||||||
|
call.request.parameters,
|
||||||
|
"detachedVolumesFromSnapshots"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (typeof tmpDetachedClone === "boolean") {
|
if (typeof tmpDetachedClone === "boolean") {
|
||||||
detachedClone = tmpDetachedClone;
|
detachedClone = tmpDetachedClone;
|
||||||
|
|
@ -462,7 +465,10 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
case "volume":
|
case "volume":
|
||||||
try {
|
try {
|
||||||
let tmpDetachedClone = JSON.parse(
|
let tmpDetachedClone = JSON.parse(
|
||||||
call.request.parameters.detachedVolumesFromVolumes
|
driver.getParameterValue(
|
||||||
|
call.request.parameters,
|
||||||
|
"detachedVolumesFromVolumes"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (typeof tmpDetachedClone === "boolean") {
|
if (typeof tmpDetachedClone === "boolean") {
|
||||||
detachedClone = tmpDetachedClone;
|
detachedClone = tmpDetachedClone;
|
||||||
|
|
@ -1357,7 +1363,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
let detachedSnapshot = false;
|
let detachedSnapshot = false;
|
||||||
try {
|
try {
|
||||||
let tmpDetachedSnapshot = JSON.parse(
|
let tmpDetachedSnapshot = JSON.parse(
|
||||||
call.request.parameters.detachedSnapshots
|
driver.getParameterValue(call.request.parameters, "detachedSnapshots")
|
||||||
); // snapshot class parameter
|
); // snapshot class parameter
|
||||||
if (typeof tmpDetachedSnapshot === "boolean") {
|
if (typeof tmpDetachedSnapshot === "boolean") {
|
||||||
detachedSnapshot = tmpDetachedSnapshot;
|
detachedSnapshot = tmpDetachedSnapshot;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
|
||||||
* into various calls such as GetControllerCapabilities etc
|
* into various calls such as GetControllerCapabilities etc
|
||||||
*/
|
*/
|
||||||
getDriverZfsResourceType() {
|
getDriverZfsResourceType() {
|
||||||
switch (this.ctx.args.driver) {
|
switch (this.options.driver) {
|
||||||
case "freenas-nfs":
|
case "freenas-nfs":
|
||||||
return "filesystem";
|
return "filesystem";
|
||||||
case "freenas-iscsi":
|
case "freenas-iscsi":
|
||||||
|
|
@ -35,7 +35,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDriverShareType() {
|
getDriverShareType() {
|
||||||
switch (this.ctx.args.driver) {
|
switch (this.options.driver) {
|
||||||
case "freenas-nfs":
|
case "freenas-nfs":
|
||||||
return "nfs";
|
return "nfs";
|
||||||
case "freenas-iscsi":
|
case "freenas-iscsi":
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,36 @@ class CsiBaseDriver {
|
||||||
this.options = options;
|
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) {
|
async GetPluginInfo(call) {
|
||||||
return {
|
return {
|
||||||
name: this.ctx.args.csiName,
|
name: this.ctx.args.csiName,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue