Fix cannot get NTPServers
When we have 2 or more netdevs, if eth0 configured the StaticNTPServers
and eth1 not by default, the NTPServers will be empty.
We could merge all the NTPServers from all the interfaces, and remove
the duplicate ones(Already have).
Limitations(not this patch):
When setting the NTPServers, will set all the interfaces, cannot be
set individually.
Tested:
Only config the eth0's NTPServers, keep eth1's NTPServers empty.
```
~# curl -k -H "X-Auth-Token: $token" https://$bmc/redfish/v1/Managers/bmc/NetworkProtocol
{
...
"NTP": {
"NTPServers": [
"fdbd:dc00::10:8:8:14",
"fdbd:dc00::10:8:8:15",
"fdbd:dc00::10:8:8:16",
"10.8.8.14",
"10.8.8.15",
"10.8.8.16"
],
"ProtocolEnabled": true
},
}
```
Change-Id: Ie181bb117577bc46f87e714b87dcb7cd8f5145a8
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 00b7bfc..2621fd6 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -73,7 +73,8 @@
&propertyPair.second);
if (ntpServers != nullptr)
{
- ntpData = *ntpServers;
+ ntpData.insert(ntpData.end(), ntpServers->begin(),
+ ntpServers->end());
}
}
else if (propertyPair.first == "DomainName")
@@ -83,13 +84,15 @@
&propertyPair.second);
if (domainNames != nullptr)
{
- dnData = *domainNames;
+ dnData.insert(dnData.end(), domainNames->begin(),
+ domainNames->end());
}
}
}
}
}
stl_utils::removeDuplicate(ntpData);
+ stl_utils::removeDuplicate(dnData);
}
template <typename CallbackFunc>