// net-host.js // Copyright (C) 2024 DTP Technologies, LLC // All Rights Reserved 'use strict'; import mongoose from 'mongoose'; const Schema = mongoose.Schema; const NETHOST_STATUS_LIST = [ 'starting', 'active', 'shutdown', 'inactive', 'crashed', ]; 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: NETHOST_STATUS_LIST, 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 }, node: { type: String, required: true }, platform: { type: String, required: true }, release: { type: String, required: true }, version: { type: String, required: true }, network: { type: [NetworkInterfaceSchema] }, }); export default mongoose.model('NetHost', NetHostSchema);