summaryrefslogtreecommitdiffstats
path: root/server/lib
diff options
context:
space:
mode:
authorJannik Schönartz2019-01-13 15:42:23 +0100
committerJannik Schönartz2019-01-13 15:42:23 +0100
commite47b84e50275234235d2d70eebe484443e86bfb3 (patch)
tree2fbda0c3163d52551600a4b64ce2548911f6e23e /server/lib
parent[webapp] add first version of a virtualized table for better performance (diff)
downloadbas-e47b84e50275234235d2d70eebe484443e86bfb3.tar.gz
bas-e47b84e50275234235d2d70eebe484443e86bfb3.tar.xz
bas-e47b84e50275234235d2d70eebe484443e86bfb3.zip
[server] Add ipxe efi support. Grep hw drive info
Grep drive info and upload it to idoit Add EFI / BIOS configs for building ipxe Add function to build efi ipxe version Add default.ipxe script
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/external-backends/backends/idoit-backend.js44
-rw-r--r--server/lib/shell.js16
2 files changed, 52 insertions, 8 deletions
diff --git a/server/lib/external-backends/backends/idoit-backend.js b/server/lib/external-backends/backends/idoit-backend.js
index 57a5929..ba99eb2 100644
--- a/server/lib/external-backends/backends/idoit-backend.js
+++ b/server/lib/external-backends/backends/idoit-backend.js
@@ -472,7 +472,7 @@ class IdoitBackend extends ExternalBackends {
* system: { model: <SYSTEM_MODEL>, manufacturer: <SYSTEM_MANUFACTURER>, serialnumber: <SYSTEM_SERIALNUMBER> },
* cpu: { model: <CPU_MODEL>, manufacturer: <CPU_MANUFACTURER>, type: <CPU_TYPE>, frequency: <CPU_FREQUENCY>, cores: <CPU_CORES> },
* ram: [{ title: <RAM_TITLE>, manufacturer: <RAM_MANUFACTURER>, type: <RAM_TYPE>, capacity: <RAM_CAPACITY>, unit: <RAM_UNIT> }, ...],
- * storage: {}
+ * drives: [{model: <DRIVE_MODEL>,}, serial: <DRIVE_SERIAL>, capacity: <DRIVE_CAPACITY>, unit: <DRIVE_UNIT>, type: <DRIVE_TYPE>, formfactor: <DRIVE_FORMFACTOR>, connection: <DRIVE_CONNECTION> ...]
* }
*/
async updateClient (credentials, client) {
@@ -564,7 +564,6 @@ class IdoitBackend extends ExternalBackends {
if (client.cpu) {
// TODO: Delete cpu if exists?
-
// Update the object.
bodies.push({
'version': '2.0',
@@ -587,7 +586,7 @@ class IdoitBackend extends ExternalBackends {
'id': 'update_cpu'
})
}
- console.log(client.ram)
+
if (client.ram) {
var counter = 1
for (var memory in client.ram) {
@@ -620,6 +619,45 @@ class IdoitBackend extends ExternalBackends {
}
}
+ if (client.drives) {
+ var counter = 1
+ for (var drive in client.drives) {
+ var d = client.drives[drive]
+ var id = 'create_drive_' + counter
+
+ // UNIT
+ var unit = 0
+ if (d.unit === 'GB') unit = 3
+ else if (d.unit === 'TB') unit = 4
+ else if (d.unit === 'MB') unit = 2
+ else if (d.unit === 'KB') unit = 1
+ else if (d.unit === 'B') unit = 0
+
+ // Update the object.
+ bodies.push({
+ 'version': '2.0',
+ 'method': 'cmdb.category.create',
+ 'params': {
+ 'objID': clientid,
+ 'category': 'C__CATG__STORAGE_DEVICE',
+ 'data': {
+ 'title': d.model,
+ 'type': d.type,
+ // 'manufacturer': ,
+ // 'model': ,
+ 'capacity': d.capacity,
+ 'unit': unit,
+ 'serial': d.serial,
+ 'connected': d.connection
+ },
+ 'apikey': c.apikey,
+ 'language': 'en'
+ },
+ 'id': id
+ })
+ }
+ }
+
var requestUpdate = await axios.post(c.url, bodies, config)
var result = {
diff --git a/server/lib/shell.js b/server/lib/shell.js
index 667fdeb..2b1ea0b 100644
--- a/server/lib/shell.js
+++ b/server/lib/shell.js
@@ -16,13 +16,19 @@ module.exports = {
// Remove the general config and paste in the own one
shell.rm(path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config', 'general.h'))
- shell.cp(path.join(__appdir, 'ipxe', 'general.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config'))
+ // shell.cp(path.join(__appdir, 'ipxe', 'general.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config'))
+ shell.cp(path.join(__appdir, 'ipxe', 'general_efi.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config', 'general.h'))
shell.rm(path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config', 'console.h'))
- shell.cp(path.join(__appdir, 'ipxe', 'console.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config'))
- // var make = 'make EMBED=' + path.join(__appdir, 'ipxe', 'main.ipxe');
- var make = 'make EMBED=' + path.join(__appdir, 'ipxe', 'main.ipxe') + ' TRUST=' + path.join(__appdir, 'bin', 'fullchain.pem')// + ' bin/undionly.kpxe'
+ // shell.cp(path.join(__appdir, 'ipxe', 'console.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config'))
+ shell.cp(path.join(__appdir, 'ipxe', 'console_efi.h'), path.join(__appdir, 'ipxe', 'ipxe', 'src', 'config', 'console.h'))
+ // PCBIOS Variant
+ // var make = 'make EMBED=' + path.join(__appdir, 'ipxe', 'main.ipxe') + ' TRUST=' + path.join(__appdir, 'bin', 'fullchain.pem')// + ' bin/undionly.kpxe'
+
+ // EFI Variant
+ var make = 'make bin-x86_64-efi/snponly.efi EMBED=' + path.join(__appdir, 'ipxe', 'main.ipxe') + ' TRUST=' + path.join(__appdir, 'bin', 'fullchain.pem')// + ' bin/undionly.kpxe'
+
+ // USB
// var make = 'make EMBED=' + path.join(__appdir, 'ipxe', 'reboot.ipxe') + ' TRUST=' + path.join(__appdir, 'bin', 'fullchain.pem') + ' bin/ipxe.usb'
- // shell.env.PATH = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin';
shell.env.DEBUG = ''
shell.exec(make, function (code, stdout, stderr) {
// shell.rm(path.join(__appdir, 'tftp', 'ipxe.0'))