Remove gateway properties in SystemConfiguration

Now default gateway are per-interface properties, the system-wide one
in the SystemConfiguration interface is deprecated. Updating the value
also makes no difference, it will never be written to configuration.
This patch removes the code of initializing and updating them.

Change #52785 removes the properties in phosphor-dbus-interfaces yaml,
it is recommended to be merged after this change.

Tested:
In SystemConfiguration interface, DefaultGateway and DefaultGateway6 are
still there, but writing them only updates the displayed value on DBus.
No code in phosphor-networkd is called.

Change-Id: I58ac52c5318943941dcc92abede7763bddbca596
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index b2ca45d..b4a63bc 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -180,7 +180,7 @@
 
     // create the system conf object.
     systemConf = std::make_unique<phosphor::network::SystemConfiguration>(
-        bus, objPath.string(), *this);
+        bus, objPath.string());
     // create the dhcp conf object.
     objPath /= "dhcp";
     dhcpConf = std::make_unique<phosphor::network::dhcp::Configuration>(
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index ae7d270..b430bfc 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -2,8 +2,6 @@
 
 #include "system_configuration.hpp"
 
-#include "network_manager.hpp"
-
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -23,36 +21,16 @@
 
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-using InvalidArgumentMetadata = xyz::openbmc_project::Common::InvalidArgument;
 
 using SystemConfigIntf =
     sdbusplus::xyz::openbmc_project::Network::server::SystemConfiguration;
 
 SystemConfiguration::SystemConfiguration(sdbusplus::bus::bus& bus,
-                                         const std::string& objPath,
-                                         Manager& parent) :
+                                         const std::string& objPath) :
     Iface(bus, objPath.c_str(), Iface::action::defer_emit),
-    bus(bus), manager(parent)
+    bus(bus)
 {
-    auto name = getHostNameFromSystem();
-
-    SystemConfigIntf::hostName(name);
-    const auto& gatewayList = manager.getRouteTable().getDefaultGateway();
-    const auto& gateway6List = manager.getRouteTable().getDefaultGateway6();
-    // Assign first entry of gateway list
-    std::string gateway;
-    std::string gateway6;
-    if (!gatewayList.empty())
-    {
-        gateway = gatewayList.begin()->second;
-    }
-    if (!gateway6List.empty())
-    {
-        gateway6 = gateway6List.begin()->second;
-    }
-
-    SystemConfigIntf::defaultGateway(gateway);
-    SystemConfigIntf::defaultGateway6(gateway6);
+    SystemConfigIntf::hostName(getHostNameFromSystem());
 
     this->emit_object_added();
 }
@@ -103,53 +81,5 @@
     return "";
 }
 
-std::string SystemConfiguration::defaultGateway(std::string gateway)
-{
-    auto gw = SystemConfigIntf::defaultGateway();
-    if (gw == gateway)
-    {
-        return gw;
-    }
-
-    if (!isValidIP(AF_INET, gateway))
-    {
-        log<level::ERR>("Not a valid v4 Gateway",
-                        entry("GATEWAY=%s", gateway.c_str()));
-        elog<InvalidArgument>(
-            InvalidArgumentMetadata::ARGUMENT_NAME("GATEWAY"),
-            InvalidArgumentMetadata::ARGUMENT_VALUE(gateway.c_str()));
-    }
-    gw = SystemConfigIntf::defaultGateway(gateway);
-
-    manager.writeToConfigurationFile();
-    manager.reloadConfigs();
-
-    return gw;
-}
-
-std::string SystemConfiguration::defaultGateway6(std::string gateway)
-{
-    auto gw = SystemConfigIntf::defaultGateway6();
-    if (gw == gateway)
-    {
-        return gw;
-    }
-
-    if (!isValidIP(AF_INET6, gateway))
-    {
-        log<level::ERR>("Not a valid v6 Gateway",
-                        entry("GATEWAY=%s", gateway.c_str()));
-        elog<InvalidArgument>(
-            InvalidArgumentMetadata::ARGUMENT_NAME("GATEWAY"),
-            InvalidArgumentMetadata::ARGUMENT_VALUE(gateway.c_str()));
-    }
-    gw = SystemConfigIntf::defaultGateway6(gateway);
-
-    manager.writeToConfigurationFile();
-    manager.reloadConfigs();
-
-    return gw;
-}
-
 } // namespace network
 } // namespace phosphor
diff --git a/src/system_configuration.hpp b/src/system_configuration.hpp
index a29309c..0bc1dab 100644
--- a/src/system_configuration.hpp
+++ b/src/system_configuration.hpp
@@ -37,28 +37,13 @@
      *  @param[in] objPath - Path to attach at.
      *  @param[in] parent - Parent object.
      */
-    SystemConfiguration(sdbusplus::bus::bus& bus, const std::string& objPath,
-                        Manager& parent);
+    SystemConfiguration(sdbusplus::bus::bus& bus, const std::string& objPath);
 
     /** @brief set the hostname of the system.
      *  @param[in] name - host name of the system.
      */
     std::string hostName(std::string name) override;
 
-    /** @brief set the default v4 gateway of the system.
-     *  @param[in] gateway - default v4 gateway of the system.
-     */
-    std::string defaultGateway(std::string gateway) override;
-
-    using SystemConfigIntf::defaultGateway;
-
-    /** @brief set the default v6 gateway of the system.
-     *  @param[in] gateway - default v6 gateway of the system.
-     */
-    std::string defaultGateway6(std::string gateway) override;
-
-    using SystemConfigIntf::defaultGateway6;
-
   private:
     /** @brief get the hostname from the system by doing
      *         dbus call to hostnamed service.
@@ -67,9 +52,6 @@
 
     /** @brief Persistent sdbusplus DBus bus connection. */
     sdbusplus::bus::bus& bus;
-
-    /** @brief Network Manager object. */
-    Manager& manager;
 };
 
 } // namespace network