Device Software version management
[oam/tr069-adapter.git] / netconf-server / src / main / java / org / commscope / tr069adapter / netconf / server / NetConfServerManagerImpl.java
index ed1164e..e17596c 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.Map.Entry;\r
 import java.util.concurrent.ExecutorService;\r
 import java.util.concurrent.Executors;\r
-\r
 import org.commscope.tr069adapter.acs.common.OperationDetails;\r
 import org.commscope.tr069adapter.acs.common.ParameterDTO;\r
 import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode;\r
@@ -95,7 +94,8 @@ public class NetConfServerManagerImpl {
     LOG.debug("Restarting netconf servers during startup is completed.");\r
   }\r
 \r
-  public NetConfServerDetails createServer(String deviceId, String enodeBName) {\r
+  public NetConfServerDetails createServer(String deviceId, String enodeBName, String swVersion,\r
+      String hwVersion) {\r
     NetConfServerDetails result = new NetConfServerDetails();\r
     NetConfServerDetailsEntity entity = null;\r
     if (deviceId != null) {\r
@@ -116,6 +116,8 @@ public class NetConfServerManagerImpl {
 \r
       // update the ENB Name if Changed\r
       entity.setEnodeBName(enodeBName);\r
+      entity.setSwVersion(swVersion);\r
+      entity.setHwVersion(hwVersion);\r
       netconfDAO.save(entity);\r
       result = getNetConfServerDetails(deviceId, entity);\r
       return result;\r
@@ -133,7 +135,7 @@ public class NetConfServerManagerImpl {
         LOG.debug("Successfully reserved a port for deviceID={} ,port={}", deviceId, port);\r
 \r
         // start the server\r
-        boolean isServerStarted = ncServerStarter.startServer(port, deviceId);\r
+        boolean isServerStarted = ncServerStarter.startServer(port, deviceId, swVersion, hwVersion);\r
         boolean isPortInUse = serverPortAllocator.isServerPortInUse(port);\r
 \r
         if (!isServerStarted || !isPortInUse) {\r
@@ -150,6 +152,8 @@ public class NetConfServerManagerImpl {
       entity.setDeviceId(deviceId);\r
       entity.setListenPort(port);\r
       entity.setEnodeBName(enodeBName);\r
+      entity.setSwVersion(swVersion);\r
+      entity.setHwVersion(hwVersion);\r
       netconfDAO.save(entity);\r
 \r
       result = getNetConfServerDetails(deviceId, entity);\r
@@ -172,11 +176,27 @@ public class NetConfServerManagerImpl {
     return result;\r
   }\r
 \r
+  public NetConfServerDetails restartServer(String deviceId, String enodeBName, String swVersion,\r
+      String hwVersion) {\r
+\r
+    NetConfServerDetailsEntity entity = null;\r
+    if (deviceId != null) {\r
+      entity = netconfDAO.findByDeviceId(deviceId);\r
+    }\r
+    if (entity != null) {\r
+      boolean result = this.ncServerStarter.stopServer(deviceId);\r
+      restartServersOnStartup(entity);\r
+    }\r
+\r
+    return null;\r
+  }\r
+\r
+\r
   public boolean restartServersOnStartup(NetConfServerDetailsEntity entity) {\r
     boolean isSuccess = false;\r
 \r
-    boolean isServerStarted =\r
-        ncServerStarter.startServer(entity.getListenPort(), entity.getDeviceId());\r
+    boolean isServerStarted = ncServerStarter.startServer(entity.getListenPort(),\r
+        entity.getDeviceId(), entity.getSwVersion(), entity.getHwVersion());\r
     if (isServerStarted) {\r
       LOG.info("Successfully restarted NETCONF server {}  on port {}  upon application startup.",\r
           entity.getDeviceId(), entity.getListenPort());\r
@@ -215,6 +235,8 @@ public class NetConfServerManagerImpl {
     result.setDeviceId(deviceId);\r
     result.setListenPort(entity.getListenPort());\r
     result.setEnodeBName(entity.getEnodeBName());\r
+    result.setSwVersion(entity.getSwVersion());\r
+    result.setHwVersion(entity.getHwVersion());\r
     String netconfListenAddress = getServiceHost();\r
     if (netconfListenAddress == null) {\r
       netconfListenAddress = config.getNetconfServerIP();\r