From f1f72232ce10c035a990687ec5161e4727a49804 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 13 Apr 2021 13:35:33 +0000 Subject: [server/registration] parse lspci to get gpu info, add additional values in lspci --- server/api/registration.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'server/api') 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) { -- cgit v1.2.3-55-g7522