summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0008-systems-Fix-for-Processor-Summary-Model.patch
blob: d210e380822a76b8d175af9bbe12fb8a7d57120a (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From ea3f3da3b29c7ecca34c12f94ce1e0364cbf9d7c Mon Sep 17 00:00:00 2001
From: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Date: Fri, 29 May 2020 00:50:46 +0000
Subject: [PATCH] systems: Fix for Processor Summary Model

Issue: Processor summary is not showing model name as expected from
       Redfish

Fix: Add condition to fetch valid model name in processor summary

Tested:
1. Verified redfish validator passed
2. Get system details from Redfish
GET: https://<BMC-IP>/redfish/v1/Systems/system/
Before fix:
Response:
  "ProcessorSummary": {
    "Count": 2,
    "Model": "Unknown Processor Family",
    "Status": {
      "Health": "OK",
      "HealthRollup": "OK",
      "State": "Enabled"
    }
  },

After fix:
Response:
  "ProcessorSummary": {
    "Count": 1,
    "Model": "Intel Xeon processor",
    "Status": {
      "Health": "OK",
      "HealthRollup": "OK",
      "State": "Enabled"
    }
  },

Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I4af7132135aef26556839fabada623728b52be8b
---
 redfish-core/lib/systems.hpp | 73 +++++++++++++++++++++++-------------
 1 file changed, 46 insertions(+), 27 deletions(-)

diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 2baeaa7..884fbb6 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -325,40 +325,59 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
 
                                     if (properties.size() > 0)
                                     {
+                                        const uint32_t* processorId = nullptr;
+                                        const std::string* procFamily = nullptr;
+                                        nlohmann::json& procSummary =
+                                            aResp->res.jsonValue["ProcessorSumm"
+                                                                 "ary"];
+                                        nlohmann::json& procCount =
+                                            procSummary["Count"];
+
+                                        auto procCountPtr = procCount.get_ptr<
+                                            nlohmann::json::
+                                                number_integer_t*>();
+                                        if (procCountPtr == nullptr)
+                                        {
+                                            messages::internalError(aResp->res);
+                                            return;
+                                        }
                                         for (const auto& property : properties)
                                         {
+
+                                            if (property.first == "ProcessorId")
+                                            {
+                                                processorId =
+                                                    std::get_if<uint32_t>(
+                                                        &property.second);
+                                                if (nullptr != procFamily)
+                                                    break;
+                                                continue;
+                                            }
+
                                             if (property.first ==
                                                 "ProcessorFamily")
                                             {
-                                                const std::string* value =
+                                                procFamily =
                                                     std::get_if<std::string>(
                                                         &property.second);
-                                                if (value != nullptr)
-                                                {
-                                                    nlohmann::json&
-                                                        procSummary =
-                                                            aResp->res.jsonValue
-                                                                ["ProcessorSumm"
-                                                                 "ary"];
-                                                    nlohmann::json& procCount =
-                                                        procSummary["Count"];
-
-                                                    auto procCountPtr =
-                                                        procCount.get_ptr<
-                                                            nlohmann::json::
-                                                                number_integer_t*>();
-                                                    if (procCountPtr != nullptr)
-                                                    {
-                                                        // shouldn't be possible
-                                                        // to be nullptr
-                                                        *procCountPtr += 1;
-                                                    }
-                                                    procSummary["Status"]
-                                                               ["State"] =
-                                                                   "Enabled";
-                                                    procSummary["Model"] =
-                                                        *value;
-                                                }
+                                                if (nullptr != processorId)
+                                                    break;
+                                                continue;
+                                            }
+                                        }
+
+                                        if (procFamily != nullptr &&
+                                            processorId != nullptr)
+                                        {
+                                            if (procCountPtr != nullptr &&
+                                                *processorId != 0)
+                                            {
+                                                *procCountPtr += 1;
+                                                procSummary["Status"]["State"] =
+                                                    "Enabled";
+
+                                                procSummary["Model"] =
+                                                    *procFamily;
                                             }
                                         }
                                     }
-- 
2.17.1