summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-04-06 20:05:47 +0200
committerJannik Schönartz2021-04-06 20:05:47 +0200
commitd6f20839a5678c0c0d0fa4b0fddbbc54e483e9ab (patch)
tree56032e0a86458c5dd69aa42817da51093c0e11ac
parent[server/registration] Small initialization bug fix (diff)
downloadbas-d6f20839a5678c0c0d0fa4b0fddbbc54e483e9ab.tar.gz
bas-d6f20839a5678c0c0d0fa4b0fddbbc54e483e9ab.tar.xz
bas-d6f20839a5678c0c0d0fa4b0fddbbc54e483e9ab.zip
[server/registration] Fix stupid nesting -.-
-rw-r--r--server/api/registration.js64
1 files changed, 31 insertions, 33 deletions
diff --git a/server/api/registration.js b/server/api/registration.js
index d0289cc..ee1f15b 100644
--- a/server/api/registration.js
+++ b/server/api/registration.js
@@ -492,25 +492,23 @@ function getRecursiveParents (groupIds) {
* New mehthod for preparing the new json formatted hw information
*/
function parseHardwareInformation (data) {
- let result = {
- 'client': {
- 'parents': [], // TODO:
- 'type': '', // SERVER OR CLIENT
- 'uuid': '',
- 'networks': [], // { 'mac': '', 'ip': '' }
- 'system': {
- 'model': '',
- 'manufacturer': '',
- 'serialnumber': ''
- },
- 'cpus': [],
- 'ram': {
- 'modules': [],
- 'isEcc': false
- },
- 'drives': [],
- 'gpus': []
- }
+ let client = {
+ 'parents': [], // TODO:
+ 'type': '', // SERVER OR CLIENT
+ 'uuid': '',
+ 'networks': [], // { 'mac': '', 'ip': '' }
+ 'system': {
+ 'model': '',
+ 'manufacturer': '',
+ 'serialnumber': ''
+ },
+ 'cpus': [],
+ 'ram': {
+ 'modules': [],
+ 'isEcc': false
+ },
+ 'drives': [],
+ 'gpus': []
}
// TODO: Rack and Bay stuff
@@ -528,14 +526,14 @@ function parseHardwareInformation (data) {
for (let entry of filteredData) {
switch (entry.name) {
case 'System Information':
- result.client.system.model = entry.props['Product Name'].values[0]
- result.client.system.manufacturer = entry.props['Manufacturer'].values[0]
- result.client.system.serialnumber = entry.props['Serial Number'].values[0]
- result.client.uuid = entry.props['UUID'].values[0]
+ client.system.model = entry.props['Product Name'].values[0]
+ client.system.manufacturer = entry.props['Manufacturer'].values[0]
+ client.system.serialnumber = entry.props['Serial Number'].values[0]
+ client.uuid = entry.props['UUID'].values[0]
break
case 'Processor Information':
- result.client.cpus.push({
+ client.cpus.push({
'model': entry.props['Version'].values[0],
'manufacturer': entry.props['Manufacturer'].values[0],
'type': entry.props['Family'].values[0],
@@ -547,7 +545,7 @@ function parseHardwareInformation (data) {
case 'Memory Device':
if (entry.props['Size'].values[0] === 'No Module Installed') break
- result.client.ram.modules.push({
+ client.ram.modules.push({
'capacity': entry.props['Size'].values[0].split(' ')[0],
'unit': entry.props['Size'].values[0].split(' ')[1],
'manufacturer': entry.props['Manufacturer'].values[0],
@@ -560,7 +558,7 @@ function parseHardwareInformation (data) {
break
case 'Physical Memory Array':
- result.client.ram.isEcc = !!entry.props['Error Correction Type'].values[0].endsWith('ECC')
+ client.ram.isEcc = !!entry.props['Error Correction Type'].values[0].endsWith('ECC')
break
}
}
@@ -621,7 +619,7 @@ function parseHardwareInformation (data) {
if (data.smartctl[key]['serial_number']) drive.serial = data.smartctl[key]['serial_number']
if (data.smartctl[key]['firmware_version']) drive.firmware = data.smartctl[key]['firmware_version']
- result.client.drives.push(drive)
+ client.drives.push(drive)
}
/* lspci */
@@ -643,12 +641,12 @@ function parseHardwareInformation (data) {
else if (addr.family === 'inet6') network.ipv6 = addr.local
}
- result.client.networks.push(network)
+ client.networks.push(network)
}
/* net */
/* Get network information as fallback for ip */
- if (result.client.networks.length <= 0) {
+ if (client.networks.length <= 0) {
for (let key in data.net) {
let network = {
'name': key,
@@ -657,7 +655,7 @@ function parseHardwareInformation (data) {
'ipv6': data.net[key]['ipv6'],
'hostname': ''
}
- result.client.networks.push(network)
+ client.networks.push(network)
}
}
@@ -666,10 +664,10 @@ function parseHardwareInformation (data) {
/* lshw */
if (data.lshw && data.lshw.length > 0) {
/* Get display information (as fallback) */
- if (result.client.gpus && result.client.gpus.length === 0) {
+ if (client.gpus && client.gpus.length === 0) {
const gpus = data.lshw[0].children.filter(y => y.id === 'core')[0].children.filter(z => z.id === 'pci')[0].children.filter(w => w.id === 'display')
for (let gpu of gpus) {
- result.client.gpus.push({
+ client.gpus.push({
'manufacturer': gpu.vendor,
'model': gpu.product
/*,
@@ -681,7 +679,7 @@ function parseHardwareInformation (data) {
}
}
- return result
+ return client
}
/*