implement custom connect args use transport query string(s)

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen 2023-01-11 17:53:42 -07:00
parent fc875eb2f2
commit 43284bb5a2
2 changed files with 20 additions and 14 deletions

12
package-lock.json generated
View File

@ -74,9 +74,9 @@
}
},
"node_modules/@grpc/grpc-js": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.8.2.tgz",
"integrity": "sha512-5cqCjUvDKJWHGeu1prlrFOUmjuML0NequZKJ38PsCkfwIqPnZq4Q9burPP3It7/+46wpl0KsqVN3s6Te3B9Qtw==",
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.7.3.tgz",
"integrity": "sha512-H9l79u4kJ2PVSxUNA08HMYAnUBLj9v6KjYQ7SQ71hOZcEXhShE/y5iQCesP8+6/Ik/7i2O0a10bPquIcYfufog==",
"dependencies": {
"@grpc/proto-loader": "^0.7.0",
"@types/node": ">=12.12.47"
@ -2955,9 +2955,9 @@
}
},
"@grpc/grpc-js": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.8.2.tgz",
"integrity": "sha512-5cqCjUvDKJWHGeu1prlrFOUmjuML0NequZKJ38PsCkfwIqPnZq4Q9burPP3It7/+46wpl0KsqVN3s6Te3B9Qtw==",
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.7.3.tgz",
"integrity": "sha512-H9l79u4kJ2PVSxUNA08HMYAnUBLj9v6KjYQ7SQ71hOZcEXhShE/y5iQCesP8+6/Ik/7i2O0a10bPquIcYfufog==",
"requires": {
"@grpc/proto-loader": "^0.7.0",
"@types/node": ">=12.12.47"

View File

@ -1,6 +1,7 @@
const cp = require("child_process");
const { hostname_lookup, trimchar } = require("./general");
const URI = require("uri-js");
const querystring = require("querystring");
const DEFAULT_TIMEOUT = process.env.NVMEOF_DEFAULT_TIMEOUT || 30000;
@ -102,6 +103,17 @@ class NVMEoF {
transport_args.push("--trsvcid", transport.service);
}
if (transport.args) {
for (let arg in transport.args) {
let value = transport.args[arg];
if (!arg.startsWith("-")) {
arg = `--${arg}`;
}
transport_args.push(arg, value);
}
}
args.unshift("connect", "--nqn", nqn, ...transport_args);
try {
@ -208,6 +220,7 @@ class NVMEoF {
transport = transport.trim();
const parsed = URI.parse(transport);
let args = querystring.parse(parsed.query);
let type = parsed.scheme;
let address = parsed.host;
@ -256,6 +269,7 @@ class NVMEoF {
type,
address,
service,
args,
};
}
@ -482,14 +496,6 @@ class NVMEoF {
return `/dev/disk/by-id/nvme-${modelNumber}_${serialNumber}`;
}
devicePathByPortalIQNLUN(portal, iqn, lun) {
const parsedPortal = this.parsePortal(portal);
const portalHost = parsedPortal.host
.replaceAll("[", "")
.replaceAll("]", "");
return `/dev/disk/by-path/ip-${portalHost}:${parsedPortal.port}-iscsi-${iqn}-lun-${lun}`;
}
exec(command, args, options = {}) {
if (!options.hasOwnProperty("timeout")) {
options.timeout = DEFAULT_TIMEOUT;