Restart the network through networkManager

Extend the refresh timer once we get the Dbus request which
requires network restart.

Detaching the network restart from the writeConfiguration func.
Write the configuration file for the vlan interface in
writeConfiguration func.

During creation of vlan,vlan interface should come up with
dhcp as false.

Change-Id: Iadc7b44554aca412d211d13e9569cc601ad04074
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index bcb8f6c..7c4e8bb 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -134,7 +134,7 @@
                         prefixLength,
                         gateway));
 
-    writeConfigurationFile();
+    manager.writeToConfigurationFile();
 }
 
 
@@ -246,7 +246,7 @@
         return;
     }
     this->addrs.erase(it);
-    writeConfigurationFile();
+    manager.writeToConfigurationFile();
 }
 
 void EthernetInterface::deleteVLANObject(const std::string& interface)
@@ -282,9 +282,6 @@
     }
     // delete the interface
     vlanInterfaces.erase(it);
-    // restart the systemd-networkd
-
-    restartSystemdUnit("systemd-networkd.service");
 
     // TODO  systemd doesn't delete the virtual network interface
     // even after deleting all the related configuartion.
@@ -297,6 +294,8 @@
     {
         commit<InternalFailure>();
     }
+
+    manager.writeToConfigurationFile();
 }
 
 std::string EthernetInterface::generateObjectPath(IP::Protocol addressType,
@@ -323,7 +322,7 @@
     }
 
     EthernetInterfaceIntf::dHCPEnabled(value);
-    writeConfigurationFile();
+    manager.writeToConfigurationFile();
     return value;
 }
 
@@ -364,19 +363,18 @@
     auto vlanIntf = std::make_unique<phosphor::network::VlanInterface>(
                         bus,
                         path.c_str(),
-                        EthernetInterfaceIntf::dHCPEnabled(),
+                        false,
                         id,
                         *this,
                         manager);
 
     // write the device file for the vlan interface.
     vlanIntf->writeDeviceFile();
-    vlanIntf->writeConfigurationFile();
 
     this->vlanInterfaces.emplace(vlanInterfaceName,
                                  std::move(vlanIntf));
     // write the new vlan device entry to the configuration(network) file.
-    writeConfigurationFile();
+    manager.writeToConfigurationFile();
 }
 
 // Need to merge the below function with the code which writes the
@@ -391,6 +389,15 @@
     using AddressOrigin =
         sdbusplus::xyz::openbmc_project::Network::server::IP::AddressOrigin;
     namespace fs = std::experimental::filesystem;
+
+    // if there is vlan interafce then write the configuration file
+    // for vlan also.
+
+    for (const auto& intf: vlanInterfaces)
+    {
+        intf.second->writeConfigurationFile();
+    }
+
     fs::path confPath = manager.getConfDir();
 
     std::string fileName = systemd::config::networkFilePrefix + interfaceName() +
@@ -429,7 +436,6 @@
         // configured as dhcp.
         writeDHCPSection(stream);
         stream.close();
-        restartSystemdUnit("systemd-networkd.service");
         return;
     }
 
@@ -475,7 +481,6 @@
     }
 
     stream.close();
-    restartSystemdUnit("systemd-networkd.service");
 }
 
 void EthernetInterface::writeDHCPSection(std::fstream& stream)