diskLayout fix on VM (windows)
This commit is contained in:
parent
1dd4028123
commit
1ed7115168
@ -1001,74 +1001,69 @@ function diskLayout(callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
util.wmic('diskdrive get /value').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
const size = util.getValue(lines, 'Size', '=').trim();
|
||||
const status = util.getValue(lines, 'Status', '=').trim().toLowerCase();
|
||||
if (size) {
|
||||
result.push({
|
||||
device: '',
|
||||
type: device.indexOf('SSD') > -1 ? 'SSD' : 'HD', // just a starting point ... better: MSFT_PhysicalDisk - Media Type ... see below
|
||||
name: util.getValue(lines, 'Caption', '='),
|
||||
vendor: util.getValue(lines, 'Manufacturer', '='),
|
||||
size: parseInt(size),
|
||||
bytesPerSector: parseInt(util.getValue(lines, 'BytesPerSector', '=')),
|
||||
totalCylinders: parseInt(util.getValue(lines, 'TotalCylinders', '=')),
|
||||
totalHeads: parseInt(util.getValue(lines, 'TotalHeads', '=')),
|
||||
totalSectors: parseInt(util.getValue(lines, 'TotalSectors', '=')),
|
||||
totalTracks: parseInt(util.getValue(lines, 'TotalTracks', '=')),
|
||||
tracksPerCylinder: parseInt(util.getValue(lines, 'TracksPerCylinder', '=')),
|
||||
sectorsPerTrack: parseInt(util.getValue(lines, 'SectorsPerTrack', '=')),
|
||||
firmwareRevision: util.getValue(lines, 'FirmwareRevision', '=').trim(),
|
||||
serialNum: util.getValue(lines, 'SerialNumber', '=').trim(),
|
||||
interfaceType: util.getValue(lines, 'InterfaceType', '=').trim(),
|
||||
smartStatus: (status === 'ok' ? 'Ok' : (status === 'degraded' ? 'Degraded' : (status === 'pred fail' ? 'Predicted Failure' : 'Unknown')))
|
||||
});
|
||||
}
|
||||
});
|
||||
util.powerShell('Get-PhysicalDisk | Format-List')
|
||||
.then(data => {
|
||||
let devices = data.split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
const serialNum = util.getValue(lines, 'SerialNumber', ':').trim();
|
||||
const name = util.getValue(lines, 'FriendlyName', ':').trim();
|
||||
const size = util.getValue(lines, 'Size', ':').trim();
|
||||
const interfaceType = util.getValue(lines, 'BusType', ':').trim();
|
||||
let mediaType = util.getValue(lines, 'MediaType', ':').trim();
|
||||
if (mediaType === '3' || mediaType === 'HDD') { mediaType = 'HD'; }
|
||||
if (mediaType === '4') { mediaType = 'SSD'; }
|
||||
if (mediaType === '5') { mediaType = 'SCM'; }
|
||||
if (size) {
|
||||
let i = util.findObjectByKey(result, 'serialNum', serialNum);
|
||||
if (i === -1) {
|
||||
i = util.findObjectByKey(result, 'name', name);
|
||||
}
|
||||
if (i != -1) {
|
||||
result[i].type = mediaType;
|
||||
result[i].interfaceType = interfaceType;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
})
|
||||
.catch(() => {
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
const size = util.getValue(lines, 'Size', '=').trim();
|
||||
const status = util.getValue(lines, 'Status', '=').trim().toLowerCase();
|
||||
if (size) {
|
||||
result.push({
|
||||
device: '',
|
||||
type: device.indexOf('SSD') > -1 ? 'SSD' : 'HD', // just a starting point ... better: MSFT_PhysicalDisk - Media Type ... see below
|
||||
name: util.getValue(lines, 'Caption', '='),
|
||||
vendor: util.getValue(lines, 'Manufacturer', '='),
|
||||
size: parseInt(size),
|
||||
bytesPerSector: parseInt(util.getValue(lines, 'BytesPerSector', '=')),
|
||||
totalCylinders: parseInt(util.getValue(lines, 'TotalCylinders', '=')),
|
||||
totalHeads: parseInt(util.getValue(lines, 'TotalHeads', '=')),
|
||||
totalSectors: parseInt(util.getValue(lines, 'TotalSectors', '=')),
|
||||
totalTracks: parseInt(util.getValue(lines, 'TotalTracks', '=')),
|
||||
tracksPerCylinder: parseInt(util.getValue(lines, 'TracksPerCylinder', '=')),
|
||||
sectorsPerTrack: parseInt(util.getValue(lines, 'SectorsPerTrack', '=')),
|
||||
firmwareRevision: util.getValue(lines, 'FirmwareRevision', '=').trim(),
|
||||
serialNum: util.getValue(lines, 'SerialNumber', '=').trim(),
|
||||
interfaceType: util.getValue(lines, 'InterfaceType', '=').trim(),
|
||||
smartStatus: (status === 'ok' ? 'Ok' : (status === 'degraded' ? 'Degraded' : (status === 'pred fail' ? 'Predicted Failure' : 'Unknown')))
|
||||
});
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
util.powerShell('Get-PhysicalDisk | Format-List')
|
||||
.then(data => {
|
||||
let devices = data.split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
const serialNum = util.getValue(lines, 'SerialNumber', ':').trim();
|
||||
const name = util.getValue(lines, 'FriendlyName', ':').trim().replace('Msft ', 'Microsoft');
|
||||
const size = util.getValue(lines, 'Size', ':').trim();
|
||||
const model = util.getValue(lines, 'Model', ':').trim();
|
||||
const interfaceType = util.getValue(lines, 'BusType', ':').trim();
|
||||
let mediaType = util.getValue(lines, 'MediaType', ':').trim();
|
||||
if (mediaType === '3' || mediaType === 'HDD') { mediaType = 'HD'; }
|
||||
if (mediaType === '4') { mediaType = 'SSD'; }
|
||||
if (mediaType === '5') { mediaType = 'SCM'; }
|
||||
if (mediaType === 'Unspecified' && model.toLowerCase().indexOf('virtual') > -1) { mediaType = 'Virtual'; }
|
||||
if (size) {
|
||||
let i = util.findObjectByKey(result, 'serialNum', serialNum);
|
||||
if (i === -1 || serialNum === '') {
|
||||
i = util.findObjectByKey(result, 'name', name);
|
||||
}
|
||||
if (i != -1) {
|
||||
result[i].type = mediaType;
|
||||
result[i].interfaceType = interfaceType;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
})
|
||||
.catch(() => {
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if (callback) { callback(result); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user