You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
3 years ago
|
// net-host.js
|
||
|
// Copyright (C) 2021 Digital Telepresence, LLC
|
||
|
// License: Apache-2.0
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
const mongoose = require('mongoose');
|
||
|
|
||
|
const Schema = mongoose.Schema;
|
||
|
|
||
|
const CpuInfoSchema = new Schema({
|
||
|
model: { type: String },
|
||
|
speed: { type: Number },
|
||
|
});
|
||
|
|
||
|
const NetworkInterfaceSchema = new Schema({
|
||
|
iface: { type: String, required: true },
|
||
|
speed: { type: Number },
|
||
|
mac: { type: String },
|
||
|
ip4: { type: String },
|
||
|
ip4subnet: { type: String },
|
||
|
ip6: { type: String },
|
||
|
ip6subnet: { type: String },
|
||
|
flags: {
|
||
|
internal: { type: Boolean },
|
||
|
virtual: { type: Boolean },
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const NetHostSchema = new Schema({
|
||
|
created: { type: Date, default: Date.now, required: true, index: 1 },
|
||
|
updated: { type: Date },
|
||
|
status: { type: String, enum: ['starting', 'active', 'shutdown', 'inactive', 'crashed'], required: true, index: 1 },
|
||
|
hostname: { type: String, required: true, index: 1 },
|
||
|
arch: { type: String, required: true },
|
||
|
cpus: { type: [CpuInfoSchema], required: true },
|
||
|
totalmem: { type: Number, required: true },
|
||
|
freemem: { type: Number, required: true },
|
||
|
platform: { type: String, required: true },
|
||
|
release: { type: String, required: true },
|
||
|
version: { type: String, required: true },
|
||
|
network: { type: [NetworkInterfaceSchema] },
|
||
|
});
|
||
|
|
||
|
module.exports = mongoose.model('NetHost', NetHostSchema);
|