Restructure the code so that it is unit testable
Change-Id: I2af7a26d054522beae82f58769f8c2420a22eca2
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/network_manager.cpp b/network_manager.cpp
index a4a9b54..40fce1d 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -26,25 +26,31 @@
namespace fs = std::experimental::filesystem;
Manager::Manager(sdbusplus::bus::bus& bus, const char* objPath):
- details::VLANCreateIface(bus, objPath, true)
+ details::VLANCreateIface(bus, objPath, true),
+ bus(bus),
+ objectPath(objPath)
{
+}
+
+void Manager::createInterfaces()
+{
+
auto interfaceInfoList = getInterfaceAddrs();
for (const auto& intfInfo : interfaceInfoList)
-
{
-
- fs::path objectPath = std::string(OBJ_NETWORK);
- objectPath /= intfInfo.first;
+ fs::path objPath = objectPath;
+ objPath /= intfInfo.first;
this->interfaces.emplace(std::make_pair(
intfInfo.first,
std::make_unique<
phosphor::network::EthernetInterface>
(bus,
- objectPath.string(),
- false,
- intfInfo.second)));
+ objPath.string(),
+ false)));
+
+ interfaces[intfInfo.first]->setAddressList(intfInfo.second);
}
}