handle file missing for nvme multipath

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen 2023-06-20 07:36:54 -06:00
parent a3df4bcca0
commit a9e5ff07d6
1 changed files with 28 additions and 3 deletions

View File

@ -29,6 +29,9 @@ class NVMEoF {
nvmeof.logger = nvmeof.options.logger; nvmeof.logger = nvmeof.options.logger;
} else { } else {
nvmeof.logger = console; nvmeof.logger = console;
console.verbose = function() {
console.log(...arguments);
}
} }
} }
@ -273,11 +276,33 @@ class NVMEoF {
}; };
} }
async pathExists(path) {
const nvmeof = this;
try {
await nvmeof.exec("stat", [
path,
]);
return true;
} catch (err) {
return false;
}
}
async nativeMultipathEnabled() { async nativeMultipathEnabled() {
const nvmeof = this; const nvmeof = this;
let result = await nvmeof.exec("cat", [ let result;
"/sys/module/nvme_core/parameters/multipath",
]); try {
result = await nvmeof.exec("cat", [
"/sys/module/nvme_core/parameters/multipath",
]);
} catch (err) {
if (err.code == 1 && err.stderr.includes("No such file or directory")) {
return false;
}
throw err;
}
return result.stdout.trim() == "Y"; return result.stdout.trim() == "Y";
} }