Fix duplicate NTP servers patch
Duplicate NTP servers value should not be patch.
Tested:
1. Patch duplicate NTP servers
curl -k -H "X-Auth-Token: $bmc_token" -XPATCH https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol -d '{"NTP":{"NTPServers":["9.9.9.9","9.9.9.9","1.1.1.1","9.9.9.9"]}}'
2. GET NTP servers information
curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol
{
"@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol",
"@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol",
"Description": "Manager Network Service",
"FQDN": "",
"HTTP": {
"Port": 0,
"ProtocolEnabled": false
},
"HTTPS": {
"Certificates": {
"@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"
},
"Port": 443,
"ProtocolEnabled": true
},
"HostName": "",
"IPMI": {
"Port": 623,
"ProtocolEnabled": true
},
"Id": "NetworkProtocol",
"NTP": {
"NTPServers": [
"1.1.1.1",
"9.9.9.9"
],
"ProtocolEnabled": false
},
Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: Idb63cf5e28d36a5df1aae9b0a7d53a1b7a9c8d91
diff --git a/http/http_client.hpp b/http/http_client.hpp
index caaaccb..72784f2 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -245,16 +245,14 @@
case ConnState::closed:
case ConnState::connectFailed:
case ConnState::sendFailed:
- case ConnState::recvFailed:
- {
+ case ConnState::recvFailed: {
// After establishing the connection, checkQueue() will
// get called and it will attempt to send data.
doConnect();
break;
}
case ConnState::connected:
- case ConnState::idle:
- {
+ case ConnState::idle: {
std::string data = requestDataQueue.front();
sendMessage(data);
break;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index a2ae1ea..2ce952d 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -460,6 +460,11 @@
if (ntpServers)
{
+ std::sort((*ntpServers).begin(), (*ntpServers).end());
+ (*ntpServers)
+ .erase(
+ std::unique((*ntpServers).begin(), (*ntpServers).end()),
+ (*ntpServers).end());
handleNTPServersPatch(*ntpServers, asyncResp);
}
}