diff --git a/docs/storage-class-parameters.md b/docs/storage-class-parameters.md index da50195..b9a6bd9 100644 --- a/docs/storage-class-parameters.md +++ b/docs/storage-class-parameters.md @@ -16,7 +16,6 @@ metadata: parameters: fsType: ext4 # The following options affect the LUN representing the volume - volume: /volume2 # Optional. Override the volume on which the LUN will be created. lunType: BLUN # Btrfs thin provisioning lunType: BLUN_THICK # Btrfs thick provisioning lunType: THIN # Ext4 thin provisioning @@ -34,10 +33,18 @@ parameters: # The following options affect the iSCSI target headerDigenst: false dataDigest: false - maxSessions: 1 # Note that this option requires a compatible filesystem + maxSessions: 1 # Note that this option requires a compatible filesystem. Use 0 for unlimited sessions (default). maxRecieveSegmentBytes: 262144 maxSendSegmentBytes: 262144 -... + lunTemplate: | + # This inline yaml object will be passed to the Synology API when creating the LUN. Use this for custom options. + dev_attribs: + - dev_attrib: emulate_caw + enable: 1 + targetTemplate: | + # This inline yaml object will be passed to the Synology API when creating the target. Use this for custom + # options. + max_sessions: 0 ``` About extended features: @@ -61,6 +68,10 @@ parameters: # Note that AppConsistent snapshots require a working Synology Storage Console. Otherwise both values will have # equivalent behavior. consistency: AppConsistent # Or CrashConsistent + lunSnapshotTemplate: | + # This inline yaml object will be passed to the Synology API when creating the snapshot. Use this for custom + # options. + is_locked: true ... ``` diff --git a/examples/synology-iscsi.yaml b/examples/synology-iscsi.yaml index 64629cb..0fba420 100644 --- a/examples/synology-iscsi.yaml +++ b/examples/synology-iscsi.yaml @@ -10,8 +10,7 @@ httpConnection: session: "democratic-csi" serialize: true -# choose the default volume for your system. The default value is /volume1. -# This can also be overridden by StorageClasses +# Choose the DSM volume this driver operates on. The default value is /volume1. # synology: # volume: /volume1 diff --git a/src/driver/controller-synology/http/index.js b/src/driver/controller-synology/http/index.js index 03d6013..9e00362 100644 --- a/src/driver/controller-synology/http/index.js +++ b/src/driver/controller-synology/http/index.js @@ -39,12 +39,7 @@ class SynologyError extends GrpcError { class SynologyHttpClient { constructor(options = {}) { - this.options = Object.assign({ - protocol: "https", - port: 5001, - allowInsecure: false, - session: "democratic-csi" - }, JSON.parse(JSON.stringify(options))); + this.options = JSON.parse(JSON.stringify(options)); this.logger = console; this.doLoginMutex = new Mutex(); this.apiSerializeMutex = new Mutex(); diff --git a/src/driver/controller-synology/index.js b/src/driver/controller-synology/index.js index 6670422..e1da1bf 100644 --- a/src/driver/controller-synology/index.js +++ b/src/driver/controller-synology/index.js @@ -4,6 +4,7 @@ const registry = require("../../utils/registry"); const SynologyHttpClient = require("./http").SynologyHttpClient; const semver = require("semver"); const sleep = require("../../utils/general").sleep; +const yaml = require("js-yaml"); const __REGISTRY_NS__ = "ControllerSynologyDriver"; @@ -181,8 +182,8 @@ class ControllerSynologyDriver extends CsiBaseDriver { * @param {String} parameters.volume - The volume specified by the StorageClass * @returns {String} The location of the volume. */ - getLocation({volume}) { - let location = volume ?? this.options?.synology?.volume + getLocation() { + let location = this.options?.synology?.volume; if (location === undefined) { location = "volume1" } @@ -469,7 +470,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { await httpClient.CreateClonedVolume( src_lun_uuid, iscsiName, - driver.getLocation(normalizedParameters), + driver.getLocation(), normalizedParameters.description ); } @@ -490,9 +491,9 @@ class ControllerSynologyDriver extends CsiBaseDriver { } } else { // create lun - data = Object.assign({}, driver.options.iscsi.lunTemplate, { + data = Object.assign({}, driver.options.iscsi.lunTemplate, yaml.load(normalizedParameters.lunTemplate), { name: iscsiName, - location: driver.getLocation(normalizedParameters), + location: driver.getLocation(), size: capacity_bytes }); data.type = normalizedParameters.lunType ?? data.type; @@ -550,7 +551,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { // create target let iqn = driver.options.iscsi.baseiqn + iscsiName; - data = Object.assign({}, driver.options.iscsi.targetTemplate, { + data = Object.assign({}, driver.options.iscsi.targetTemplate, yaml.load(normalizedParameters.targetTemplate), { name: iscsiName, iqn, }); @@ -887,8 +888,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { async GetCapacity(call) { const driver = this; const httpClient = await driver.getHttpClient(); - const normalizedParameters = driver.getNormalizedParameters(call.request.parameters) - const location = driver.getLocation(normalizedParameters); + const location = driver.getLocation(); if (!location) { throw new GrpcError( @@ -1001,7 +1001,7 @@ class ControllerSynologyDriver extends CsiBaseDriver { snapshot = await httpClient.GetSnapshotByLunUUIDAndName(lun.uuid, name); if (!snapshot) { const normalizedParameters = driver.getNormalizedParameters(call.request.parameters); - let data = Object.assign({}, driver.options.iscsi.lunSnapshotTemplate, { + let data = Object.assign({}, driver.options.iscsi.lunSnapshotTemplate, yaml.load(normalizedParameters.lunSnapshotTemplate), { src_lun_uuid: lun.uuid, taken_by: "democratic-csi", description: name, //check