Skip to content

Commit 8c71e7d

Browse files
committed
WIP: systems_logservices_hostlogger.hpp - support for multi-host
Add support for multi-host for all GET and POST method requests under /redfish/v1/Systems/{computerSystemId}/LogServices/HostLogger/ redfish resource. Testing: TBD Change-Id: I026be8106f2accbb77d8d40749f502f3162ad04b Signed-off-by: Oliver Brewka <oliver.brewka@9elements.com>
1 parent 6759619 commit 8c71e7d

File tree

1 file changed

+38
-51
lines changed

1 file changed

+38
-51
lines changed

redfish-core/lib/systems_logservices_hostlogger.hpp

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ inline bool getHostLoggerEntries(
9696
return true;
9797
}
9898

99-
inline void fillHostLoggerEntryJson(std::string_view logEntryID,
100-
std::string_view msg,
101-
nlohmann::json::object_t& logEntryJson)
99+
inline void fillHostLoggerEntryJson(
100+
const std::string& systemName, std::string_view logEntryID,
101+
std::string_view msg, nlohmann::json::object_t& logEntryJson)
102102
{
103103
// Fill in the log entry with the gathered data.
104104
logEntryJson["@odata.type"] = "#LogEntry.v1_9_0.LogEntry";
105105
logEntryJson["@odata.id"] = boost::urls::format(
106-
"/redfish/v1/Systems/{}/LogServices/HostLogger/Entries/{}",
107-
BMCWEB_REDFISH_SYSTEM_URI_NAME, logEntryID);
106+
"/redfish/v1/Systems/{}/LogServices/HostLogger/Entries/{}", systemName,
107+
logEntryID);
108108
logEntryJson["Name"] = "Host Logger Entry";
109109
logEntryJson["Id"] = logEntryID;
110110
logEntryJson["Message"] = msg;
@@ -122,29 +122,24 @@ inline void handleSystemsLogServicesHostloggerGet(
122122
{
123123
return;
124124
}
125-
if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
126-
{
127-
// Option currently returns no systems. TBD
128-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
129-
systemName);
130-
return;
131-
}
132-
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
125+
126+
if (!BMCWEB_REDFISH_SYSTEM_URI_NAME.empty())
133127
{
134-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
135-
systemName);
136-
return;
128+
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
129+
{
130+
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
131+
systemName);
132+
return;
133+
}
137134
}
138-
asyncResp->res.jsonValue["@odata.id"] =
139-
std::format("/redfish/v1/Systems/{}/LogServices/HostLogger",
140-
BMCWEB_REDFISH_SYSTEM_URI_NAME);
135+
asyncResp->res.jsonValue["@odata.id"] = std::format(
136+
"/redfish/v1/Systems/{}/LogServices/HostLogger", systemName);
141137
asyncResp->res.jsonValue["@odata.type"] = "#LogService.v1_2_0.LogService";
142138
asyncResp->res.jsonValue["Name"] = "Host Logger Service";
143139
asyncResp->res.jsonValue["Description"] = "Host Logger Service";
144140
asyncResp->res.jsonValue["Id"] = "HostLogger";
145-
asyncResp->res.jsonValue["Entries"]["@odata.id"] =
146-
std::format("/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
147-
BMCWEB_REDFISH_SYSTEM_URI_NAME);
141+
asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
142+
"/redfish/v1/Systems/{}/LogServices/HostLogger/Entries", systemName);
148143
}
149144

150145
inline void handleSystemsLogServicesHostloggerEntriesGet(
@@ -162,22 +157,17 @@ inline void handleSystemsLogServicesHostloggerEntriesGet(
162157
{
163158
return;
164159
}
165-
if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
166-
{
167-
// Option currently returns no systems. TBD
168-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
169-
systemName);
170-
return;
171-
}
172-
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
160+
if (!BMCWEB_REDFISH_SYSTEM_URI_NAME.empty())
173161
{
174-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
175-
systemName);
176-
return;
162+
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
163+
{
164+
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
165+
systemName);
166+
return;
167+
}
177168
}
178-
asyncResp->res.jsonValue["@odata.id"] =
179-
std::format("/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
180-
BMCWEB_REDFISH_SYSTEM_URI_NAME);
169+
asyncResp->res.jsonValue["@odata.id"] = std::format(
170+
"/redfish/v1/Systems/{}/LogServices/HostLogger/Entries", systemName);
181171
asyncResp->res.jsonValue["@odata.type"] =
182172
"#LogEntryCollection.LogEntryCollection";
183173
asyncResp->res.jsonValue["Name"] = "HostLogger Entries";
@@ -217,8 +207,8 @@ inline void handleSystemsLogServicesHostloggerEntriesGet(
217207
for (size_t i = 0; i < logEntries.size(); i++)
218208
{
219209
nlohmann::json::object_t hostLogEntry;
220-
fillHostLoggerEntryJson(std::to_string(skip + i), logEntries[i],
221-
hostLogEntry);
210+
fillHostLoggerEntryJson(systemName, std::to_string(skip + i),
211+
logEntries[i], hostLogEntry);
222212
logEntryArray.emplace_back(std::move(hostLogEntry));
223213
}
224214

@@ -228,7 +218,7 @@ inline void handleSystemsLogServicesHostloggerEntriesGet(
228218
asyncResp->res.jsonValue["Members@odata.nextLink"] =
229219
std::format(
230220
"/redfish/v1/Systems/{}/LogServices/HostLogger/Entries?$skip=",
231-
BMCWEB_REDFISH_SYSTEM_URI_NAME) +
221+
systemName) +
232222
std::to_string(skip + top);
233223
}
234224
}
@@ -243,18 +233,14 @@ inline void handleSystemsLogServicesHostloggerEntriesEntryGet(
243233
{
244234
return;
245235
}
246-
if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
236+
if (!BMCWEB_REDFISH_SYSTEM_URI_NAME.empty())
247237
{
248-
// Option currently returns no systems. TBD
249-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
250-
systemName);
251-
return;
252-
}
253-
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
254-
{
255-
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
256-
systemName);
257-
return;
238+
if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
239+
{
240+
messages::resourceNotFound(asyncResp->res, "ComputerSystem",
241+
systemName);
242+
return;
243+
}
258244
}
259245
std::string_view targetID = param;
260246

@@ -290,7 +276,8 @@ inline void handleSystemsLogServicesHostloggerEntriesEntryGet(
290276
if (!logEntries.empty())
291277
{
292278
nlohmann::json::object_t hostLogEntry;
293-
fillHostLoggerEntryJson(targetID, logEntries[0], hostLogEntry);
279+
fillHostLoggerEntryJson(systemName, targetID, logEntries[0],
280+
hostLogEntry);
294281
asyncResp->res.jsonValue.update(hostLogEntry);
295282
return;
296283
}

0 commit comments

Comments
 (0)