summaryrefslogtreecommitdiffstats
path: root/server/api/registration.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-03-25 06:43:55 +0100
committerJannik Schönartz2019-03-25 06:43:55 +0100
commit752d9c18bb531544f28bdbfd00b5eb922e07d3d8 (patch)
tree5c4773c2556b0a3aa928574c7ef63a996113c22d /server/api/registration.js
parenteslint fix (diff)
downloadbas-752d9c18bb531544f28bdbfd00b5eb922e07d3d8.tar.gz
bas-752d9c18bb531544f28bdbfd00b5eb922e07d3d8.tar.xz
bas-752d9c18bb531544f28bdbfd00b5eb922e07d3d8.zip
[external-backends/idoit] Add server rack segmentation & add multiple ip support
Diffstat (limited to 'server/api/registration.js')
-rw-r--r--server/api/registration.js11
1 files changed, 7 insertions, 4 deletions
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.