summaryrefslogtreecommitdiff
path: root/src/store/modules/Configuration/NetworkSettingsStore.js
blob: f6912c87bce18043436e66eafd81ec8e036295a7 (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
import api from '../../api';

const NetworkSettingsStore = {
  namespaced: true,
  state: {
    ethernetData: []
  },
  getters: {
    ethernetData: state => state.ethernetData
  },
  mutations: {
    setEthernetData: (state, ethernetData) =>
      (state.ethernetData = ethernetData)
  },
  actions: {
    async getEthernetData({ commit }) {
      return await api
        .get('/redfish/v1/Managers/bmc/EthernetInterfaces')
        .then(response =>
          response.data.Members.map(
            ethernetInterface => ethernetInterface['@odata.id']
          )
        )
        .then(ethernetInterfaceIds =>
          api.all(
            ethernetInterfaceIds.map(ethernetInterface =>
              api.get(ethernetInterface)
            )
          )
        )
        .then(ethernetInterfaces => {
          const ethernetData = ethernetInterfaces.map(
            ethernetInterface => ethernetInterface.data
          );
          commit('setEthernetData', ethernetData);
        })
        .catch(error => {
          console.log('Network Data:', error);
        });
    }
  }
};

export default NetworkSettingsStore;