better support for nvme-cli 1.x
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
6738ca4a7e
commit
bb5019bd7e
|
|
@ -980,6 +980,11 @@ class CsiBaseDriver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find namespace device
|
// find namespace device
|
||||||
|
|
||||||
|
// rescan in scenarios when login previously occurred but volumes never appeared
|
||||||
|
// must be the NVMe char device, not the namespace device
|
||||||
|
await nvmeof.rescanNamespace(controllerDevice);
|
||||||
|
|
||||||
let namespaceDevice;
|
let namespaceDevice;
|
||||||
try {
|
try {
|
||||||
await GeneralUtils.retry(15, 2000, async () => {
|
await GeneralUtils.retry(15, 2000, async () => {
|
||||||
|
|
@ -1012,10 +1017,6 @@ class CsiBaseDriver {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rescan in scenarios when login previously occurred but volumes never appeared
|
|
||||||
// must be the NVMe char device, not the namespace device
|
|
||||||
await nvmeof.rescanNamespace(controllerDevice);
|
|
||||||
|
|
||||||
// can take some time for device to show up, loop for some period
|
// can take some time for device to show up, loop for some period
|
||||||
result = await filesystem.pathExists(namespaceDevice);
|
result = await filesystem.pathExists(namespaceDevice);
|
||||||
let timer_start = Math.round(new Date().getTime() / 1000);
|
let timer_start = Math.round(new Date().getTime() / 1000);
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,7 @@ class NVMEoF {
|
||||||
const nvmeof = this;
|
const nvmeof = this;
|
||||||
transport = await nvmeof.parseTransport(transport);
|
transport = await nvmeof.parseTransport(transport);
|
||||||
let nativeMultipathEnabled = await nvmeof.nativeMultipathEnabled();
|
let nativeMultipathEnabled = await nvmeof.nativeMultipathEnabled();
|
||||||
|
|
||||||
if (nativeMultipathEnabled) {
|
if (nativeMultipathEnabled) {
|
||||||
let subsystem = await nvmeof.getSubsystemByNQN(nqn);
|
let subsystem = await nvmeof.getSubsystemByNQN(nqn);
|
||||||
if (subsystem) {
|
if (subsystem) {
|
||||||
|
|
@ -253,14 +254,34 @@ class NVMEoF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSubsystemByNQN(nqn) {
|
async getSubsystems() {
|
||||||
const nvmeof = this;
|
const nvmeof = this;
|
||||||
let result = await nvmeof.list(["-v"]);
|
let result = await nvmeof.list(["-v"]);
|
||||||
|
|
||||||
|
return nvmeof.getResultSubsystems(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getResultSubsystems(result) {
|
||||||
|
let subsystems = [];
|
||||||
|
|
||||||
for (let device of result.Devices) {
|
for (let device of result.Devices) {
|
||||||
for (let subsystem of device.Subsystems) {
|
if (Array.isArray(device.Subsystems)) {
|
||||||
if (subsystem.SubsystemNQN == nqn) {
|
subsystems = subsystems.concat(device.Subsystems);
|
||||||
return subsystem;
|
} else if (device.Subsystem) {
|
||||||
}
|
// nvme-cli 1.x support
|
||||||
|
subsystems.push(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return subsystems;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getSubsystemByNQN(nqn) {
|
||||||
|
const nvmeof = this;
|
||||||
|
const subsystems = await nvmeof.getSubsystems();
|
||||||
|
for (let subsystem of subsystems) {
|
||||||
|
if (subsystem.SubsystemNQN == nqn) {
|
||||||
|
return subsystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,12 +346,13 @@ class NVMEoF {
|
||||||
async nqnByNamespaceDeviceName(name) {
|
async nqnByNamespaceDeviceName(name) {
|
||||||
const nvmeof = this;
|
const nvmeof = this;
|
||||||
name = name.replace("/dev/", "");
|
name = name.replace("/dev/", "");
|
||||||
let result = await nvmeof.list(["-v"]);
|
|
||||||
let nativeMultipathEnabled = await nvmeof.nativeMultipathEnabled();
|
let nativeMultipathEnabled = await nvmeof.nativeMultipathEnabled();
|
||||||
|
const subsystems = await nvmeof.getSubsystems();
|
||||||
|
|
||||||
if (nativeMultipathEnabled) {
|
if (nativeMultipathEnabled) {
|
||||||
for (let device of result.Devices) {
|
// using per-subsystem namespace
|
||||||
for (let subsystem of device.Subsystems) {
|
for (let subsystem of subsystems) {
|
||||||
|
if (subsystem.Namespaces) {
|
||||||
for (let namespace of subsystem.Namespaces) {
|
for (let namespace of subsystem.Namespaces) {
|
||||||
if (namespace.NameSpace == name) {
|
if (namespace.NameSpace == name) {
|
||||||
return subsystem.SubsystemNQN;
|
return subsystem.SubsystemNQN;
|
||||||
|
|
@ -339,18 +361,23 @@ class NVMEoF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let device of result.Devices) {
|
// using per-controller namespace
|
||||||
for (let subsystem of device.Subsystems) {
|
for (let subsystem of subsystems) {
|
||||||
|
if (subsystem.Controllers) {
|
||||||
for (let controller of subsystem.Controllers) {
|
for (let controller of subsystem.Controllers) {
|
||||||
for (let namespace of controller.Namespaces) {
|
if (controller.Namespaces) {
|
||||||
if (namespace.NameSpace == name) {
|
for (let namespace of controller.Namespaces) {
|
||||||
return subsystem.SubsystemNQN;
|
if (namespace.NameSpace == name) {
|
||||||
|
return subsystem.SubsystemNQN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvmeof.logger.warn(`failed to find nqn for device: ${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
devicePathByModelNumberSerialNumber(modelNumber, serialNumber) {
|
devicePathByModelNumberSerialNumber(modelNumber, serialNumber) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue