From 752d9c18bb531544f28bdbfd00b5eb922e07d3d8 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Mon, 25 Mar 2019 05:43:55 +0000 Subject: [external-backends/idoit] Add server rack segmentation & add multiple ip support --- server/api/registration.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'server/api/registration.js') diff --git a/server/api/registration.js b/server/api/registration.js index 4891e31..20e8618 100644 --- a/server/api/registration.js +++ b/server/api/registration.js @@ -109,7 +109,7 @@ noAuthRouter.post('/group', (req, res) => { /* * Add method for adding a client or server. */ -noAuthRouter.postAsync('/', async (req, res) => { +noAuthRouter.postAsync('/clients', async (req, res) => { let client = req.body.client if (typeof client === 'string') client = JSON.parse(client) @@ -128,13 +128,16 @@ noAuthRouter.postAsync('/', async (req, res) => { // Client does not exist. if (!client.parents) client.parents = [] - const createClient = { name: client.name, description: client.type, ip: client.network.ip, mac: client.network.mac, uuid: client.uuid } + // TODO: Save all IPs? Maybe only primary ip? + // const createClient = { name: client.name, description: client.type, ip: client.network.ip, mac: client.network.mac, uuid: client.uuid } + const createClient = { name: client.name, description: client.type, ip: client.networks[0].ip, mac: client.networks[0].mac, uuid: client.uuid } if (client.type === 'CLIENT') createClient.registrationState = await getNextHookScript(client.parents) const newClient = await db.client.create(createClient) client.id = newClient.id // Add groups to the client. - if (client.parents.length === 0) client.parents = await ipHelper.getGroups(client.network.ip) + // if (client.parents.length === 0) client.parents = await ipHelper.getGroups(client.network.ip) + if (client.parents.length === 0) client.parents = await ipHelper.getGroups(client.networks[0].ip) client.parents.forEach(pid => { newClient.addGroup(pid) }) log({ category: 'CLIENT_REGISTRATION', description: 'Client added successfully.', clientId: newClient.id }) @@ -144,7 +147,7 @@ noAuthRouter.postAsync('/', async (req, res) => { else return res.send(result) }) -noAuthRouter.postAsync('/:uuid', async (req, res) => { +noAuthRouter.postAsync('/clients/:uuid', async (req, res) => { let client = req.body.client // Add the name to the ram modules. -- cgit v1.2.3-55-g7522