summaryrefslogtreecommitdiff
path: root/src/store/modules/HardwareStatus/MotherboardStore.js
blob: eecd3bc7efcb607ab37c4e329d747115a0608c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import api from '@/store/api';

const MotherboardStore = {
  namespaced: true,
  state: {
    motherboard: [],
    motherboardLastHour: [],
    limits: [],
  },
  getters: {
    motherboard: (state) => state.motherboard,
    motherboardLastHour: (state) => state.motherboardLastHour,
    limits: (state) => state.limits,
  },
  mutations: {
    setMotherboardDynamic: (state, data) => {
      state.motherboard = data;
    },
    setMotherboardDynamicLastHour: (state, data) => {
      state.motherboardLastHour = data;
    },
    setLimits: (state, data) => {
      state.limits = data;
    },
  },
  actions: {
    async patchLimits() {
      return await api
        .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal')
        .then(({ data: { Temperatures = [] } }) =>
          Temperatures.map((temperature) =>
            api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', {
              Temperatures: [
                {
                  MemberId: temperature.MemberId,
                  UpperThresholdNonCritical: 7,
                },
              ],
            })
          )
        )
        .catch((error) => console.log(error));
    },
    async getLimits({ commit }) {
      return await api
        .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal')
        .then(({ data: { Temperatures = [] } }) => {
          commit('setLimits', Temperatures);
        })
        .catch((error) => console.log(error));
    },
    async getMotherboardDynamic({ commit }, { lastHour }) {
      let url = null;
      if (lastHour) {
        url =
          '/redfish/v1/TelemetryService/MetricReports/other_temp&period=last_hour';
      } else {
        url = '/redfish/v1/TelemetryService/MetricReports/other_temp';
      }
      return await api
        .get(url)
        .then(({ data: { MetricValues = [] } }) => {
          if (lastHour) {
            commit('setMotherboardDynamicLastHour', MetricValues);
          } else {
            commit('setMotherboardDynamic', MetricValues);
          }
        })
        .catch((error) => console.log(error));
    },
  },
};

export default MotherboardStore;