qnodes.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 集群节点表
  7. const qnodes = {
  8. node: { type: String },
  9. state: { type: String },
  10. power_state: { type: String },
  11. np: { type: String },
  12. ntype: { type: String },
  13. jobs: { type: String },
  14. status: { type: String },
  15. macaddr: { type: String },
  16. cpuclock: { type: String },
  17. varattr: { type: String },
  18. energy_used: { type: String },
  19. mem: { type: String },
  20. vmem: { type: String },
  21. walltime: { type: String },
  22. session_id: { type: String },
  23. size: { type: String },
  24. netload: { type: String },
  25. gres: { type: String },
  26. loadave: { type: String },
  27. ncpus: { type: String },
  28. physmem: { type: String },
  29. availmem: { type: String },
  30. totmem: { type: String },
  31. idletime: { type: String },
  32. nusers: { type: String },
  33. nsessions: { type: String },
  34. sessions: { type: String },
  35. uname: { type: String },
  36. opsys: { type: String },
  37. mom_service_port: { type: String },
  38. mom_manager_port: { type: String },
  39. time: { type: String },
  40. remark: { type: String, maxLength: 200 },
  41. create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
  42. };
  43. const schema = new Schema(qnodes, { toJSON: { virtuals: true } });
  44. schema.index({ id: 1 });
  45. schema.index({ time: 1 });
  46. schema.index({ 'meta.createdAt': 1 });
  47. schema.plugin(metaPlugin);
  48. module.exports = app => {
  49. const { mongoose } = app;
  50. return mongoose.model('Qnodes', schema, 'qnodes');
  51. };