summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-04-13 15:35:33 +0200
committerJannik Schönartz2021-04-13 15:35:33 +0200
commitf1f72232ce10c035a990687ec5161e4727a49804 (patch)
tree029b1639a6a0c6702866708682ec2e4d8d5a8ade
parent[server/registration] Fix stupid nesting -.- (diff)
downloadbas-f1f72232ce10c035a990687ec5161e4727a49804.tar.gz
bas-f1f72232ce10c035a990687ec5161e4727a49804.tar.xz
bas-f1f72232ce10c035a990687ec5161e4727a49804.zip
[server/registration] parse lspci to get gpu info, add additional values in lspci
-rw-r--r--server/api/registration.js19
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js13
2 files changed, 22 insertions, 10 deletions
diff --git a/server/api/registration.js b/server/api/registration.js
index ee1f15b..4897bb5 100644
--- a/server/api/registration.js
+++ b/server/api/registration.js
@@ -12,7 +12,8 @@ const config = require(path.join(__appdir, 'config', 'config'))
const url = config.https.host // + ':' + config.https.port
const log = require(path.join(__appdir, 'lib', 'log'))
const HttpResponse = require(path.join(__appdir, 'lib', 'httpresponse'))
-// const pci = require(path.join(__appdir, 'lib', 'pci')) // This is needed for parsing vendor/product codes (not required for now)
+// This is needed for parsing vendor/product codes
+const pci = require(path.join(__appdir, 'lib', 'pci'))
// Permission check middleware
router.all(['', '/hooks', '/:y', '/hooks/:x'], async (req, res, next) => {
@@ -338,7 +339,7 @@ noAuthRouter.postAsync('/clients/:uuid', async (req, res) => {
let client = {}
if (req.body.version && req.body.version >= 2) {
/* New hardware collection script */
- client = parseHardwareInformation(req.body)
+ client = await parseHardwareInformation(req.body)
} else {
/* OLD SCRIPT */
client = req.body.client
@@ -491,7 +492,7 @@ function getRecursiveParents (groupIds) {
/*
* New mehthod for preparing the new json formatted hw information
*/
-function parseHardwareInformation (data) {
+async function parseHardwareInformation (data) {
let client = {
'parents': [], // TODO:
'type': '', // SERVER OR CLIENT
@@ -569,7 +570,7 @@ function parseHardwareInformation (data) {
let drive = {
'model': '',
'family': '', // NEW
- 'firmware': '', // NEW maybe save in desc?
+ 'firmware': '',
'serial': '', // TODO: Update this to serialnumber to unify (also need to be changed in the idoit backend then)
'capacity': '',
'unit': '',
@@ -623,6 +624,16 @@ function parseHardwareInformation (data) {
}
/* lspci */
+ for (let obj of data.lspci) {
+ /* GPU */
+ if (obj.class === '0300') {
+ const parsedPci = await pci.parseIds(obj.vendor, obj.device)
+ client.gpus.push({
+ 'manufacturer': parsedPci.vendor.name,
+ 'model': parsedPci.vendor.device.name
+ })
+ }
+ }
/* ip */
for (let ip of data.ip) {
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index ddbab3e..1711c9c 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -590,9 +590,8 @@ class IdoitBackend extends ExternalBackends {
if (client.cpus) {
let counter = 1
for (let cpu of client.cpus) {
- // Add KB and TB
- if (cpu.unit === 'MB') cpu.unit = 2
- else if (cpu.unit === 'GB') cpu.unit = 3
+ if (cpu.unit === 'MHz') cpu.unit = 2
+ else if (cpu.unit === 'GHz') cpu.unit = 3
let params = {
'object': client.id,
@@ -603,7 +602,7 @@ class IdoitBackend extends ExternalBackends {
'title': cpu.model,
'type': cpu.type,
'frequency': parseFloat(cpu.frequency),
- 'frequency_unit': 3,
+ 'frequency_unit': cpu.unit,
'cores': parseInt(cpu.cores)
},
'apikey': c.apikey
@@ -649,11 +648,12 @@ class IdoitBackend extends ExternalBackends {
'objID': client.id,
'category': 'C__CATG__MEMORY',
'data': {
- 'title': module.type,
+ 'title': module.model,
'manufacturer': module.manufacturer,
'type': module.type,
'capacity': parseFloat(module.capacity),
- 'unit': module.unit
+ 'unit': module.unit,
+ 'description': `Serialnumber: ${module.serialnumber}\nFormfactor: ${module.formfactor}\nSpeed: ${module.speed}`
},
'apikey': c.apikey
}
@@ -687,6 +687,7 @@ class IdoitBackend extends ExternalBackends {
'category_id': counter,
'title': drive.model,
'type': drive.type,
+ 'firmware': drive.firmware,
// 'manufacturer': ,
// 'model': ,
'capacity': parseFloat(drive.capacity),