Avoid writing duplicate DNS entries to config file

Currently, we store the dbus DNS values in a vector without checking
duplicate entries. which allows duplicate entries to be saved if the
user supplies same DNS server settings multiple times.

With this commit, we will check duplicate entries and remove them
to get a unique list of DNS values.

Tested By: PATCH -d '{"StaticNameServers":["10.4.5.60", "10.4.5.60"]}'
    https://${bmc_ip}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0

Change-Id: I0c18eb5fec36c4305f1ded4c5e57bbd046ca4576
Signed-off-by: nitinkotania <gitnkotania@gmail.com>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index 14a7e73..bac778f 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -464,6 +464,7 @@
 
 ServerList EthernetInterface::staticNameServers(ServerList value)
 {
+    std::vector<std::string> dnsUniqueValues;
     for (auto& ip : value)
     {
         try
@@ -477,9 +478,15 @@
             elog<InvalidArgument>(Argument::ARGUMENT_NAME("StaticNameserver"),
                                   Argument::ARGUMENT_VALUE(ip.c_str()));
         }
+        if (std::find(dnsUniqueValues.begin(), dnsUniqueValues.end(), ip) ==
+            dnsUniqueValues.end())
+        {
+            dnsUniqueValues.push_back(ip);
+        }
     }
 
-    value = EthernetInterfaceIntf::staticNameServers(std::move(value));
+    value =
+        EthernetInterfaceIntf::staticNameServers(std::move(dnsUniqueValues));
 
     writeConfigurationFile();
     manager.get().reloadConfigs();