X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=netconf-server%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fnetconf%2Fserver%2FNetconfServerStarter.java;fp=netconf-server%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fnetconf%2Fserver%2FNetconfServerStarter.java;h=10ab6243922de6e613b4475842ffec268b11d892;hb=6d2eb103a838fee7fdbecc0c1fec2f954535c608;hp=47f8dab5140f4aa8047dc3bd0e5c2b881d7baab2;hpb=aa7991e2bb89e56479a79541a5d9b659ae619cd7;p=oam%2Ftr069-adapter.git diff --git a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetconfServerStarter.java b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetconfServerStarter.java index 47f8dab..10ab624 100644 --- a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetconfServerStarter.java +++ b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/server/NetconfServerStarter.java @@ -87,18 +87,6 @@ public class NetconfServerStarter { OperationsCreator operationsCreator = new CustomOperationsCreator(macID, swVersion, hwVersion); configuration.setOperationsCreator(operationsCreator); configuration.setGenerateConfigsTimeout((int) TimeUnit.MINUTES.toMillis(30)); - - String versionPath = versionManager.getNetconfYangSchemaPath(swVersion, hwVersion); - if (versionPath == null && swVersion != null) { - LOG.error("Failed to get version path for software version {}, calling base version", - swVersion); - versionPath = versionManager.getBaseNetconfYangSchemaPath(); - } else if (swVersion == null) { - LOG.error("Software version is null {}", swVersion); - return false; - } - String schemaCommonPath = schemaDirPath + "/common"; - String schemaVerPath = schemaDirPath + "/" + versionPath; if (portStr != null) { try { int port = Integer.parseInt(portStr); @@ -110,27 +98,21 @@ public class NetconfServerStarter { } configuration.setDeviceCount(1); configuration.setSsh(Boolean.TRUE); - File schemaDir = new File(schemaCommonPath); configuration.setCapabilities(Configuration.DEFAULT_BASE_CAPABILITIES_EXI); configuration.setIp("0.0.0.0"); - - File schemaVerDir = new File(schemaVerPath); - if (!schemaVerDir.isDirectory()) { - LOG.error("No folder path found for given version path {}", schemaVerDir.getAbsolutePath()); + + String versionPath = versionManager.getNetconfYangSchemaPath(swVersion, hwVersion); + if (versionPath == null && swVersion != null) { + LOG.error("Failed to get version path for software version {}, calling base version", + swVersion); + versionPath = versionManager.getBaseNetconfYangSchemaPath(); + } else if (swVersion == null) { + LOG.error("Software version is null {}", swVersion); return false; } - - try { - FileUtils.copyDirectory(schemaDir, schemaVerDir); - } catch (IOException e) { - LOG.error("Failed to copy directory " + e.getMessage()); - } + String schemaVerPath = schemaDirPath + File.separator + versionPath; + File schemaVerDir = new File(schemaVerPath); configuration.setSchemasDir(schemaVerDir); - boolean isSchemaLoaded = loadSchemas(schemaVerDir); - if (!isSchemaLoaded) { - LOG.debug("Failed to load schema for netconf server instance {}", macID); - return false; - } try (final NetconfDevice netconfDevice = new NetconfDevice(configuration)) { final List openDevices = netconfDevice.start(); @@ -164,7 +146,7 @@ public class NetconfServerStarter { return false; } - private boolean loadSchemas(File schemasDir) { + protected boolean loadSchemas(File schemasDir) { if (schemasDir != null) { if (!schemasDir.exists() || !schemasDir.isDirectory() || !schemasDir.canRead()) { LOG.error("Failed to load schema. schema location is not valid.");