diff options
Diffstat (limited to 'sdnr')
191 files changed, 8528 insertions, 5283 deletions
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java index 4a640a35f..77267e793 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java @@ -18,6 +18,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + + package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper; import java.io.IOException; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java index 7c48bf8a1..63e265bd1 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java @@ -146,7 +146,7 @@ public interface DatabaseClient { * @param query query to select item to update * @return esId which was updated or null if failed */ - public String doUpdate(String dataTypeName, String json, QueryBuilder query); + public boolean doUpdate(String dataTypeName, String json, QueryBuilder query); /** * diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java index 50a8244cb..6fb26f541 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java @@ -17,23 +17,13 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.common.database; -import java.io.FileInputStream; import java.io.IOException; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; - -import javax.net.ssl.SSLContext; - import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; -import org.apache.http.ssl.SSLContexts; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; @@ -98,57 +88,57 @@ public class ExtRestClient { } } - private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback { - - private final String certFilename; - - SSLCercAuthHttpClientConfigCallback(String certfile) { - this.certFilename = certfile; - } - - @Override - public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { - if (this.certFilename == null) { - return httpClientBuilder; - } - - char[] keystorePass = "MY PASSWORD".toCharArray(); - - FileInputStream fis = null; - - // Loading KEYSTORE in JKS format - KeyStore keyStorePci = null; - try { - keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType()); - } catch (KeyStoreException e1) { - LOG.warn("unable to load keystore: {}",e1); - } - if (keyStorePci != null) { - try { - fis = new FileInputStream(this.certFilename); - keyStorePci.load(fis, keystorePass); - } catch (Exception e) { - LOG.error("Error loading keystore: " + this.certFilename); - } finally { - if (fis != null) { - try { - fis.close(); - } catch (IOException e) { - - } - } - } - } - SSLContext sslcontext=null; - try { - sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build(); - } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException - | KeyStoreException e) { - LOG.warn("unable to load sslcontext: {}",e); - } - return httpClientBuilder.setSSLContext(sslcontext); - } - } +// private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback { +// +// private final String certFilename; +// +// SSLCercAuthHttpClientConfigCallback(String certfile) { +// this.certFilename = certfile; +// } +// +// @Override +// public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { +// if (this.certFilename == null) { +// return httpClientBuilder; +// } +// +// char[] keystorePass = "MY PASSWORD".toCharArray(); +// +// FileInputStream fis = null; +// +// // Loading KEYSTORE in JKS format +// KeyStore keyStorePci = null; +// try { +// keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType()); +// } catch (KeyStoreException e1) { +// LOG.warn("unable to load keystore: {}",e1); +// } +// if (keyStorePci != null) { +// try { +// fis = new FileInputStream(this.certFilename); +// keyStorePci.load(fis, keystorePass); +// } catch (Exception e) { +// LOG.error("Error loading keystore: " + this.certFilename); +// } finally { +// if (fis != null) { +// try { +// fis.close(); +// } catch (IOException e) { +// +// } +// } +// } +// } +// SSLContext sslcontext=null; +// try { +// sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build(); +// } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException +// | KeyStoreException e) { +// LOG.warn("unable to load sslcontext: {}",e); +// } +// return httpClientBuilder.setSSLContext(sslcontext); +// } +// } private RestClient client; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java index 56402bdfc..9a04f0dfd 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java @@ -64,19 +64,16 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A this(hosts,REFRESH_AFTER_REWRITE_DEFAULT); } public HtDatabaseClient(HostInfo[] hosts, boolean refreshAfterWrite) { - super(hosts); - this.doRefreshAfterWrite = refreshAfterWrite; + this(hosts,refreshAfterWrite,null,null); + } + public HtDatabaseClient(HostInfo[] hosts,String username,String password) { + this(hosts,REFRESH_AFTER_REWRITE_DEFAULT,username,password); } - public HtDatabaseClient(HostInfo[] hosts, boolean refreshAfterWrite,String username,String password) { super(hosts,username,password); this.doRefreshAfterWrite = refreshAfterWrite; } - public HtDatabaseClient(HostInfo[] hosts,String username,String password) { - this(hosts,REFRESH_AFTER_REWRITE_DEFAULT,username,password); - } - - + /*---------------------------------- * Functions @@ -236,7 +233,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A @Override public String doUpdateOrCreate(String dataTypeName, String esId, String json) { - return this.doUpdateOrCreate(dataTypeName, esId, json,null); + return this.doUpdateOrCreate(dataTypeName, esId, json,null); } @@ -262,7 +259,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A return success ? esId : null; } @Override - public String doUpdate(String dataTypeName, String json, QueryBuilder query) { + public boolean doUpdate(String dataTypeName, String json, QueryBuilder query) { boolean success = false; UpdateByQueryRequest request = new UpdateByQueryRequest(dataTypeName, dataTypeName ); request.source(new JSONObject(json),query); @@ -275,7 +272,7 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A if(this.doRefreshAfterWrite) { this.doRefresh(dataTypeName); } - return success?"":null; + return success; } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java index e86c5c36b..b6df2620b 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java @@ -21,12 +21,14 @@ import org.json.JSONObject; public class SearchHit { - private String index; - private String type; - private String id; - private JSONObject source; + private final String index; + private final String type; + private final String id; + private final JSONObject source; + private final JSONObject raw; public SearchHit(JSONObject o) { + this.raw = o; this.index=o.getString("_index"); this.type = o.getString("_type"); this.id = o.getString("_id"); @@ -43,8 +45,18 @@ public class SearchHit { return this.id; } + public JSONObject getSource() { + return this.source; + } public String getSourceAsString() { return this.source.toString(); } + /** + * @return + */ + public JSONObject getRaw() { + return this.raw; + } + } diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java index ff513ea97..63c1f15ba 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java @@ -21,7 +21,6 @@ * ============LICENSE_END======================================================= * */ - package org.onap.ccsdk.features.sdnr.wt.common.file; import java.io.File; diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java index 8242d35d4..b65984a58 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java @@ -100,10 +100,9 @@ public abstract class BaseServlet extends HttpServlet { sc.init(null, trustCerts, new java.security.SecureRandom()); } - private boolean trustInsecure; - private boolean isCorsEnabled; - public BaseServlet(boolean trustInsecure) { - this.trustInsecure = trustInsecure; + protected abstract boolean trustInsecure(); + protected abstract boolean isCorsEnabled(); + public BaseServlet() { this.trysslSetup(true); } @@ -118,11 +117,11 @@ public abstract class BaseServlet extends HttpServlet { */ private void trysslSetup(boolean force) { // if trustall config has changed - if (force || this.doTrustAll() != this.trustInsecure) { - this.trustAll(this.trustInsecure); + if (force || this.doTrustAll() != this.trustInsecure()) { + this.trustAll(this.trustInsecure()); // resetup ssl config try { - setupSslTrustAll(this.trustInsecure); + setupSslTrustAll(this.trustInsecure()); } catch (Exception e) { LOG.error("problem setting up SSL: {}", e.getMessage()); } @@ -347,7 +346,7 @@ public abstract class BaseServlet extends HttpServlet { resp.setHeader(entry.getKey(), v); s += String.format("%s:%s;", entry.getKey(), v); } - if (this.isCorsEnabled) { + if (this.isCorsEnabled()) { resp.setHeader("Access-Control-Allow-Origin", "*"); // resp.setHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE"); resp.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization"); diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/FileWatchdog.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/FileWatchdog.java deleted file mode 100644 index 2830d688e..000000000 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/FileWatchdog.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END======================================================= - * - */ - -package org.onap.ccsdk.features.sdnr.wt.common.util; - -import java.io.File; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Check every now and then that a certain file has not changed. If it has, then call the - * {@link #doOnChange} method. - * - * @author JunHo Yoon - * @since 3.1.1 - */ -public abstract class FileWatchdog extends Thread { - private static final Logger LOGGER = LoggerFactory.getLogger(FileWatchdog.class); - /** - * The default delay between every file modification check, set to 60 seconds. - */ - public static final long DEFAULT_DELAY = 60000; - /** - * The name of the file to observe for changes. - */ - private final String filename; - - /** - * The delay to observe between every check. By default set {@link #DEFAULT_DELAY}. - */ - private long delay = DEFAULT_DELAY; - - private final File file; - private long lastModified = 0; - private boolean warnedAlready = false; - - protected FileWatchdog(String filename) { - this.filename = filename; - file = new File(filename); - setDaemon(true); - checkAndConfigure(); - } - - /** - * Set the delay to observe between each check of the file changes. - * - * @param delay the frequency of file watch. - */ - public void setDelay(long delay) { - this.delay = delay; - } - - /** - * abstract method to be run when the file is changed. - */ - protected abstract void doOnChange(); - - protected void checkAndConfigure() { - boolean fileExists; - try { - fileExists = file.exists(); - } catch (SecurityException e) { - LOGGER.warn("Was not allowed to read check file existence, file:[{}].",filename); - this.interrupt(); // there is no point in continuing - return; - } - - if (fileExists) { - long l = file.lastModified(); // this can also throw a - if (lastModified == 0) { - lastModified = l; // is very unlikely. - } - if (l > lastModified) { // however, if we reached this point this - lastModified = l; // is very unlikely. - doOnChange(); - warnedAlready = false; - } - } else { - if (!warnedAlready) { - LOGGER.debug("[{}] does not exist.", filename); - warnedAlready = true; - } - } - } - - @Override - public void run() { - while (!isInterrupted()) { - checkAndConfigure(); - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - LOGGER.debug("Interrupted sleep. {}", e.getMessage()); - Thread.currentThread().interrupt(); - } - } - LOGGER.debug("Stoppen file watchdog for file {}", filename); - } -} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java index af3979c50..47fe9d4f6 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.IOException; @@ -77,6 +78,8 @@ public class TestBaseHttpClient { fail(e.getMessage()); } assertNotNull(response); + assertTrue(response.isSuccess()); + System.out.println(response.toString()); assertEquals(RESPONSE_POST, response.body); try { response= httpClient.sendRequest(TESTURI, HTTPMETHOD_PUT, "{}", headers ); diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java new file mode 100644 index 000000000..ee602ce28 --- /dev/null +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.common.test; + +import java.io.IOException; + +import javax.servlet.ServletException; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.test.helper.HelpServlet; +import org.onap.ccsdk.features.sdnr.wt.common.test.helper.HelpServletBase; + +/** + * @author Michael Dürre + * + */ +public class TestBaseServlet extends HelpServletBase{ + + private static final int PORT = 40003; + public TestBaseServlet() { + super("/base",PORT); + } + + @Test + public void test() throws ServletException, IOException { + + String query = "{\"query\":{\"match_all\":{}}}"; + HelpServlet servlet = new HelpServlet(PORT); + this.setServlet(servlet); + // test disabled message + String expectedResponse = "offline"; + testrequest(HTTPMETHOD_GET, query, expectedResponse, false); + testrequest(HTTPMETHOD_POST, query, expectedResponse, false); + testrequest(HTTPMETHOD_PUT, query, expectedResponse, false); + testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false); + servlet.setOffline(false); + // initEsTestWebserver(port); + testrequest(HTTPMETHOD_GET, query, HelpServletBase.RESPONSE_GET, true); + testrequest(HTTPMETHOD_POST, query, HelpServletBase.RESPONSE_POST, true); + testrequest(HTTPMETHOD_PUT, query, HelpServletBase.RESPONSE_PUT, true); + testrequest(HTTPMETHOD_DELETE, query, HelpServletBase.RESPONSE_DELETE, true); + testrequest(HTTPMETHOD_OPTIONS, query, "", false); + // stopTestWebserver(); + } + @Before + public void init() throws IOException{ + HelpServletBase.initEsTestWebserver(PORT); + } + @After + public void deinit() { + HelpServletBase.stopTestWebserver(); + } +} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java index 0d46b4d20..e39998008 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java @@ -22,9 +22,11 @@ import static org.junit.Assert.*; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.IsEsObject; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; +import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; public class TestDbClient { @@ -56,16 +58,99 @@ public class TestDbClient { //Update esId= dbClient.doUpdateOrCreate(IDX, ID, JSON2); assertEquals("update response not successfull",ID,esId); - //Verify + //check that update with null fails + assertNull("update with id null should not be possible",dbClient.doUpdateOrCreate(IDX,null,JSON2)); + //Verify update result = dbClient.doReadByQueryJsonData( IDX, QueryBuilders.matchQuery("_id", ID)); assertEquals("amount of results is wrong",1,result.getTotal()); assertEquals("data not valid", JSON2,result.getHits().get(0).getSourceAsString()); + //test second read + String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() { + + @Override + public void setEsId(String id) { + + } + + @Override + public String getEsId() { + return ID; + } + }); + //test all read + result = dbClient.doReadAllJsonData(IDX); + assertNotNull("all read not working",result); + + assertEquals("read works not as expected", JSON2,resStr); //Delete - boolean del=dbClient.doRemove(IDX, ID); + boolean del=dbClient.doRemove(IDX, new IsEsObject() { + + @Override + public void setEsId(String id) { + + } + @Override + public String getEsId() { + return ID; + } + }); assertTrue("item not deleted",del); //Verify result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID)); assertEquals("amount of results is wrong",0,result.getTotal()); + + + + } + @Test + public void testCRUD2() { + final String IDX = "test23-knmoinsd"; + final String ID = "abcddd"; + final String JSON = "{\"data\":{\"inner\":\"more\"}}"; + final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}"; + //Create + String esId=dbClient.doWriteRaw(IDX, ID, JSON); + assertEquals("inserted id is wrong",ID,esId); + //Read + SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID)); + assertEquals("amount of results is wrong",1,result.getTotal()); + assertEquals("data not valid", JSON,result.getHits().get(0).getSourceAsString()); + QueryBuilder matchQuery = QueryBuilders.matchQuery("_id", ID); + //Update + assertTrue("update response not successfull",dbClient.doUpdate(IDX, JSON2,matchQuery )); + //check that update with null fails + assertNull("update with id null should not be possible",dbClient.doUpdateOrCreate(IDX,null,JSON2)); + //Verify update + result = dbClient.doReadByQueryJsonData( IDX, QueryBuilders.matchQuery("_id", ID)); + assertEquals("amount of results is wrong",1,result.getTotal()); + assertEquals("data not valid", JSON2,result.getHits().get(0).getSourceAsString()); + //test second read + String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() { + + @Override + public void setEsId(String id) { + + } + + @Override + public String getEsId() { + return ID; + } + }); + //test all read + result = dbClient.doReadAllJsonData(IDX); + assertNotNull("all read not working",result); + + assertEquals("read works not as expected", JSON2,resStr); + //Delete + int del=dbClient.doRemove(IDX, matchQuery); + assertTrue("item not deleted",del>0); + //Verify + result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID)); + assertEquals("amount of results is wrong",0,result.getTotal()); + + + } } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java new file mode 100644 index 000000000..2e8cda0ef --- /dev/null +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java @@ -0,0 +1,126 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps.sdnr.wt.apigateway + * ================================================================================ + * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.ccsdk.features.sdnr.wt.common.test.helper; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.ccsdk.features.sdnr.wt.common.http.BaseServlet; + +public class HelpServlet extends BaseServlet implements IPublicServlet{ + + /** + * + */ + private static final long serialVersionUID = 1L; + public static final String RESPONSE_GET = "This is the response get"; + public static final String RESPONSE_POST = "This is the response post"; + public static final String RESPONSE_PUT = "This is the response put"; + public static final String RESPONSE_DELETE = "This is the response delete"; + public static final String RESPONSE_OPTIONS = "This is the response options"; + private static final String HOST = "localhost"; + private int port; + private boolean isoff; + + /** + * @param port + */ + public HelpServlet(int port) { + this.port = port; + this.isoff=true; + } + @Override + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doGet(req, resp); + } + @Override + public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doPost(req, resp); + } + @Override + public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doPut(req, resp); + } + @Override + public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setStatus(200); + } + @Override + public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doDelete(req, resp); + } + @Override + protected String getOfflineResponse() { + return "offline"; + } + @Override + protected boolean isOff() { + return this.isoff; + } + @Override + protected boolean doTrustAll() { + // TODO Auto-generated method stub + return false; + } + @Override + protected void trustAll(boolean trust) { + // TODO Auto-generated method stub + + } + @Override + protected String getRemoteUrl(String uri) { + if (uri.startsWith("/")) { + uri = uri.substring(1); + } + if (uri.startsWith("base")) { + uri = uri.substring("base".length()); + } + if (uri.startsWith("/")) { + uri = uri.substring(1); + } + String base = "http://" + HOST + ":" + this.port; + if (!base.endsWith("/")) { + base += "/"; + } + + return base + uri; + } + @Override + protected boolean trustInsecure() { + // TODO Auto-generated method stub + return false; + } + @Override + protected boolean isCorsEnabled() { + // TODO Auto-generated method stub + return false; + } + /** + * @param b + */ + public void setOffline(boolean b) { + this.isoff = b; + + } +} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java new file mode 100644 index 000000000..b0db4f0e6 --- /dev/null +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java @@ -0,0 +1,228 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps.sdnr.wt.apigateway + * ================================================================================ + * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.ccsdk.features.sdnr.wt.common.test.helper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.StringWriter; +import java.net.InetSocketAddress; +import java.util.Enumeration; +import java.util.Map; +import java.util.Vector; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.After; +import org.junit.Before; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +public class HelpServletBase { + + public static final String RESPONSE_GET = "This is the response get"; + public static final String RESPONSE_POST = "This is the response post"; + public static final String RESPONSE_PUT = "This is the response put"; + public static final String RESPONSE_DELETE = "This is the response delete"; + public static final String RESPONSE_OPTIONS = "This is the response options"; + + public static final String HTTPMETHOD_GET = "GET"; + public static final String HTTPMETHOD_POST = "POST"; + public static final String HTTPMETHOD_PUT = "PUT"; + public static final String HTTPMETHOD_DELETE = "DELETE"; + public static final String HTTPMETHOD_OPTIONS = "OPTIONS"; + private IPublicServlet servlet; + private static HttpServer server; + private static ExecutorService httpThreadPool; + + public final String HOST = "localhost"; + protected static int testPort; + private final String baseUri; + protected static final String LR = "\n"; + + public HelpServletBase(String baseuri, int port) { + this.baseUri=baseuri; + testPort = port; + } + + public void setServlet(IPublicServlet s) + { + this.servlet=s; + } + + protected void testrequest(String method, String data, String expectedResponse, boolean exact) { + this.testrequest("/mwtn/test",method, data, expectedResponse, exact, null); + } + protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact) { + this.testrequest(uri,method, data, expectedResponse, exact, null); + } + + protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact, + Map<String, String> headersToCheck) { + + HttpServletRequest mockRequest = mock(HttpServletRequest.class); + HttpServletResponse mockResponse = mock(HttpServletResponse.class); + + StringWriter out = new StringWriter(); + ServletOutputStream printOut = new ServletOutputStream() { + + @Override + public void write(int arg0) throws IOException { + out.write(arg0); + } + }; + ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes()); + ServletInputStream inputStream= new ServletInputStream() { + @Override + public int read() throws IOException { + return bis.read(); + } + }; + Vector<String> headers=new Vector<String>(); + headers.addElement("Accept"); + headers.add("User-Agent"); + Enumeration<String> headerNames = headers.elements(); + try { + when(mockRequest.getRequestURI()).thenReturn(this.baseUri+uri); + when(mockRequest.getHeaderNames()).thenReturn(headerNames); + when(mockRequest.getHeader("Accept")).thenReturn("application/json"); + when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc"); + when(mockRequest.getInputStream()).thenReturn(inputStream); + when(mockResponse.getOutputStream()).thenReturn(printOut); + System.out.println("do a " + method + " request"); + if (method == HTTPMETHOD_GET) + this.servlet.doGet(mockRequest, mockResponse); + else if (method == HTTPMETHOD_POST) + this.servlet.doPost(mockRequest, mockResponse); + else if (method == HTTPMETHOD_PUT) + this.servlet.doPut(mockRequest, mockResponse); + else if (method == HTTPMETHOD_DELETE) + this.servlet.doDelete(mockRequest, mockResponse); + else if (method == HTTPMETHOD_OPTIONS) + this.servlet.doOptions(mockRequest, mockResponse); + else + fail("http request method " + method + " test not implemented"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } + + verify(mockResponse).setStatus(200); + if (exact) + assertEquals(expectedResponse, out.toString()); + else + assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse)); + // currently unable to check extra headers + if (headersToCheck != null) { + + } + } + @Before + private void init() throws IOException{ + + + initEsTestWebserver(testPort); + } + @After + private void deinit() { + stopTestWebserver(); + } + + public static void initEsTestWebserver(int port) throws IOException { + initEsTestWebserver(port, "/mwtn/test"); + } + public static void initEsTestWebserver(int port,String baseUri) throws IOException { + server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0); + httpThreadPool = Executors.newFixedThreadPool(5); + server.setExecutor(httpThreadPool); + server.createContext(baseUri, new MyHandler()); + //server.createContext("/", new MyRootHandler()); + server.setExecutor(null); // creates a default executor + server.start(); + System.out.println("http server started"); + } + + public static void stopTestWebserver() { + if (server != null) { + server.stop(0); + httpThreadPool.shutdownNow(); + System.out.println("http server stopped" ); + } + } + + + + public static class MyHandler implements HttpHandler { + @Override + public void handle(HttpExchange t) throws IOException { + String method = t.getRequestMethod(); + System.out.println(String.format("req received: %s %s" ,method,t.getRequestURI())); + OutputStream os = null; + try { + if (method.equals(HTTPMETHOD_GET)) { + t.sendResponseHeaders(200, RESPONSE_GET.length()); + os = t.getResponseBody(); + os.write(RESPONSE_GET.getBytes()); + } else if (method.equals(HTTPMETHOD_POST)) { + t.sendResponseHeaders(200, RESPONSE_POST.length()); + os = t.getResponseBody(); + os.write(RESPONSE_POST.getBytes()); + } else if (method.equals(HTTPMETHOD_PUT)) { + t.sendResponseHeaders(200, RESPONSE_PUT.length()); + os = t.getResponseBody(); + os.write(RESPONSE_PUT.getBytes()); + } else if (method.equals(HTTPMETHOD_DELETE)) { + t.sendResponseHeaders(200, RESPONSE_DELETE.length()); + os = t.getResponseBody(); + os.write(RESPONSE_DELETE.getBytes()); + } else if (method.equals(HTTPMETHOD_OPTIONS)) { + t.sendResponseHeaders(200, RESPONSE_OPTIONS.length()); + //os = t.getResponseBody(); + //os.write(RESPONSE_OPTIONS.getBytes()); + } else { + t.sendResponseHeaders(404, 0); + } + System.out.println("req handled successful"); + + } catch (Exception e) { + System.out.println(e.getMessage()); + } + finally { + if (os != null) + { + os.close(); + } + } + } + } +} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java new file mode 100644 index 000000000..9d5ac4fc0 --- /dev/null +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.features.sdnr.wt.common.test.helper; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public interface IPublicServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException; + public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException; + public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException; + public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ; + public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ; +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java index 63d92b64d..1192950e6 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java @@ -371,7 +371,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid * @return QueryBuilder for older elements related to timestamp */ private static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) { - return new RangeQueryBuilder("event.timeStamp").lte(netconfTimeStamp); + return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp); } } private static class EsFaultLogDevicemanager { diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java index bc61e81e5..9e576857b 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java @@ -61,32 +61,35 @@ public class MediatorServerDataProvider implements AutoCloseable { @Override public void run() { isRunning = true; - SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll(); - List<Data> data = result.getHits(); - for (Data item : data) { - MediatorServerDataProvider.this.entries.put(item.getId(), item); - } + runIt(); isRunning = false; } }; + private void runIt() { + SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll(); + List<Data> data = result.getHits(); + for (Data item : data) { + MediatorServerDataProvider.this.entries.put(item.getId(), item); + } + } + + /** + * + * @param dbServerId + * @return url or null if not exists + */ public String getHostUrl(String dbServerId) { Data info = this.entries.getOrDefault(dbServerId, null); return info == null ? null : info.getUrl(); } public boolean triggerReloadSync() { - new Thread(onTick).start(); - int i = 20; - while (isRunning && i-- > 0) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + if (!isRunning) { + runIt(); } - return i > 0; + return true; } @Override diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java index 2b3ebd86e..fbdc9d825 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java @@ -163,43 +163,43 @@ public class SystemInfo { printValue(sb, "Garbage collector", maxNameLen, val); } - if (showMemoryPools) { - List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans(); - sb.append("Memory Pools\n"); - printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size())); - String spaces4 = " "; - for (MemoryPoolMXBean pool : memoryPools) { - String name = pool.getName(); - MemoryType type = pool.getType(); - printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name); - - // PeakUsage/CurrentUsage - MemoryUsage peakUsage = pool.getPeakUsage(); - MemoryUsage usage = pool.getUsage(); - - if (usage != null && peakUsage != null) { - long init = peakUsage.getInit(); - long used = peakUsage.getUsed(); - long committed = peakUsage.getCommitted(); - long max = peakUsage.getMax(); - sb.append(spaces4 + spaces4 + "Peak Usage\n"); - printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init)); - printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used)); - printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed)); - printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max)); - - init = usage.getInit(); - used = usage.getUsed(); - committed = usage.getCommitted(); - max = usage.getMax(); - sb.append(spaces4 + spaces4 + "Current Usage\n"); - printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init)); - printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used)); - printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed)); - printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max)); - } - } - } +// if (showMemoryPools) { +// List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans(); +// sb.append("Memory Pools\n"); +// printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size())); +// String spaces4 = " "; +// for (MemoryPoolMXBean pool : memoryPools) { +// String name = pool.getName(); +// MemoryType type = pool.getType(); +// printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name); +// +// // PeakUsage/CurrentUsage +// MemoryUsage peakUsage = pool.getPeakUsage(); +// MemoryUsage usage = pool.getUsage(); +// +// if (usage != null && peakUsage != null) { +// long init = peakUsage.getInit(); +// long used = peakUsage.getUsed(); +// long committed = peakUsage.getCommitted(); +// long max = peakUsage.getMax(); +// sb.append(spaces4 + spaces4 + "Peak Usage\n"); +// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max)); +// +// init = usage.getInit(); +// used = usage.getUsed(); +// committed = usage.getCommitted(); +// max = usage.getMax(); +// sb.append(spaces4 + spaces4 + "Current Usage\n"); +// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed)); +// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max)); +// } +// } +// } sb.append("Classes\n"); printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount())); diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java index b119b80d4..3fd74b09d 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java @@ -190,7 +190,7 @@ public class EsDataObjectReaderWriter<T extends DataObject> { * @param esId * @return String with esId or null */ - public @Nullable <S extends DataObject> String update(S object, QueryBuilder query) { + public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) { if (writeInterfaceClazz.isInstance(object)) { try { String json = yangtoolsMapper.writeValueAsString(object); @@ -202,7 +202,7 @@ public class EsDataObjectReaderWriter<T extends DataObject> { LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null", writeInterfaceClazz.getName()); } - return null; + return false; } /** * Write/ update partial child object to database with specific id Write if not diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java index d097d8284..d3d9dbf25 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java @@ -204,7 +204,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { * @param query for write of specific attributes * @return json string with new Object */ - public @Nullable <S extends DataObject> String update(S object, QueryBuilder query) { + public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) { if (object != null && writeInterfaceClazz.isInstance(object)) { try { String json = yangtoolsMapper.writeValueAsString(object); @@ -216,7 +216,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> { LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null", writeInterfaceClazz.getName()); } - return null; + return false; } /** * Write/ update partial child object to database with specific id Write if not diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java index cdcbb4912..6a42d0f21 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java @@ -39,9 +39,9 @@ public class MsServlet extends BaseServlet { private static final long serialVersionUID = -5361461082028405171L; private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline"; private static boolean trustAll = false; - private MediatorServerDataProvider entryProvider; + private static MediatorServerDataProvider entryProvider; public MsServlet() { - super(false); + super(); } @Override @@ -59,7 +59,7 @@ public class MsServlet extends BaseServlet { public void triggerReloadDatabaseEntries() { LOG.debug("external reload triggered"); - this.entryProvider.triggerReloadSync(); + entryProvider.triggerReloadSync(); } @Override @@ -85,7 +85,7 @@ public class MsServlet extends BaseServlet { } protected String getBaseUrl(String dbServerId) { - return this.entryProvider.getHostUrl(dbServerId); + return entryProvider.getHostUrl(dbServerId); } @Override protected boolean doTrustAll() { @@ -97,6 +97,16 @@ public class MsServlet extends BaseServlet { } public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) { - this.entryProvider = mediatorServerDataProvider; + entryProvider = mediatorServerDataProvider; + } + + @Override + protected boolean trustInsecure() { + return trustAll; + } + + @Override + protected boolean isCorsEnabled() { + return false; } } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java index fc9ae5085..a846cd8f3 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java @@ -98,7 +98,7 @@ public class EsConfig implements Configuration, IEsConfig { public boolean hasBasicAuthCredentials() { return this.getBasicAuthUsername()!=null && this.getBasicAuthPassword()!=null && - this.getBasicAuthUsername()!="" && this.getBasicAuthPassword()!="" ; + !this.getBasicAuthUsername().isEmpty() && !this.getBasicAuthPassword().isEmpty() ; } public String getBasicAuthUsername() { return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME); diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java index 748ad51c6..d898644c9 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java @@ -114,7 +114,7 @@ public class TestCRUDforDatabase { private static ElasticSearchDataProvider dbProvider; private static HtDatabaseClient dbRawProvider; - private static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer + public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) }; @BeforeClass @@ -125,7 +125,7 @@ public class TestCRUDforDatabase { dbRawProvider = new HtDatabaseClient(hosts); } - private static void trySleep(long ms) { + public static void trySleep(long ms) { try { Thread.sleep(ms); } catch (Exception e) { @@ -133,7 +133,7 @@ public class TestCRUDforDatabase { } } - private static void trySleep() { + public static void trySleep() { trySleep(0); } @@ -1183,8 +1183,8 @@ public class TestCRUDforDatabase { // == UPDATE ============================== - String shouldbeEmpty = dbRawProvider.doUpdate(Entity.Historicalperformance24h.getName(), "{'uuid-interface':'LTP-TEST-MWP-097'}", QueryBuilders.termQuery("_id", aDbId)); - assertEquals("",shouldbeEmpty); + boolean success = dbRawProvider.doUpdate(Entity.Historicalperformance24h.getName(), "{'uuid-interface':'LTP-TEST-MWP-097'}", QueryBuilders.termQuery("_id", aDbId)); + assertTrue("update dbentry not succeeded",success); try { readltpResult = dbProvider.readPmdata24hLtpList(readLtp); } catch (Exception e) { diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java new file mode 100644 index 000000000..850d80e1a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java @@ -0,0 +1,316 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; +import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; +import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; +import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtDatabaseEventsService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionLogStatus; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntityBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; + +/** + * @author Michael Dürre + * + */ +public class TestEventService { + private static ElasticSearchDataProvider dbProvider; + private static HtDatabaseClient dbRawProvider; + private static HtDatabaseEventsService service = null; + + private static final String NODEID = "node1"; + private static final String NODEID2 = "node2"; + private static final String OBJECTREFID1 = "objid1"; + private static final String OBJECTREFID2 = "objid2"; + + @BeforeClass + public static void init() throws Exception { + + dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts); + dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS); + dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts); + + try { + service = new HtDatabaseEventsService(dbRawProvider, dbProvider); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void testClearFaultsCurrent() { + + service.clearFaultsCurrentOfNode(NODEID); + service.clearFaultsCurrentOfNode(NODEID2); + + List<String> nodeIds = service.getAllNodesWithCurrentAlarms(); + if (nodeIds.size() > 0) { + for (String nodeId : nodeIds) { + service.clearFaultsCurrentOfNode(nodeId); + } + } + service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abc", SeverityType.Major)); + service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abcde", SeverityType.Major)); + service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.Major)); + service.updateFaultCurrent(createFault(NODEID2, OBJECTREFID2, "abcde", SeverityType.Major)); + nodeIds = service.getAllNodesWithCurrentAlarms(); + assertTrue(nodeIds.size() == 2); + service.clearFaultsCurrentOfNodeWithObjectId(NODEID, OBJECTREFID1); + nodeIds = service.getAllNodesWithCurrentAlarms(); + assertTrue(nodeIds.size() == 2); + service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.NonAlarmed)); + nodeIds = service.getAllNodesWithCurrentAlarms(); + assertTrue(nodeIds.size() == 1); + } + + private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem, + SeverityType severity) { + return createFault(nodeId, objectRefId, problem, severity, NetconfTimeStampImpl.getConverter().getTimeStamp()); + } + + /** + * @param nODENAME + * @param problem + * @param ts + * @param severity + * @return + */ + private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem, + SeverityType severity, DateAndTime ts) { + return new FaultcurrentBuilder().setNodeId(nodeId).setObjectId(objectRefId).setTimestamp(ts) + .setSeverity(severity).setProblem(problem).build(); + } + + @Test + public void testIndexClean() { + Date now = new Date(); + service.doIndexClean(now); + clearDbEntity(Entity.Eventlog); + clearDbEntity(Entity.Faultlog); + TestCRUDforDatabase.trySleep(1000); + service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "abc", 1)); + service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "avasvas", 2)); + + service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 1)); + service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 2)); + service.writeFaultLog(createFaultLog(NODEID2, OBJECTREFID2, "problem", SeverityType.Major, 1)); + TestCRUDforDatabase.trySleep(100); + now = new Date(); + int numOlds = service.getNumberOfOldObjects(now); + assertEquals(5, numOlds); + TestCRUDforDatabase.trySleep(100); + service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 3)); + service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 5)); + service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 6)); + numOlds = service.getNumberOfOldObjects(now); + assertEquals(5, numOlds); + now = new Date(); + numOlds = service.getNumberOfOldObjects(now); + assertEquals(8, numOlds); + service.doIndexClean(now); + numOlds = service.getNumberOfOldObjects(now); + assertEquals(0, numOlds); + + } + + @Test + public void testPm() { + final String IFNAME1 = "if1"; + final String SCNID1 = "scn1"; + List<PmdataEntity> list = Arrays.asList(createPmData(NODEID, IFNAME1, SCNID1), + createPmData(NODEID, IFNAME1, SCNID1), createPmData(NODEID, IFNAME1, SCNID1), + createPmData(NODEID, IFNAME1, SCNID1) + + ); + service.doWritePerformanceData(list); + } + + /** + * @param ifname + * @param ifUuid + * @param scannerId + * @param nodename3 + * @return + */ + private static PmdataEntity createPmData(String nodeId, String ifUuid, String scannerId) { + return new PmdataEntityBuilder().setNodeName(nodeId).setGranularityPeriod(GranularityPeriodType.Period15Min) + .setUuidInterface(ifUuid).setScannerId(scannerId).setLayerProtocolName("NETCONF") + .setPerformanceData(null).setSuspectIntervalFlag(true) + .setTimeStamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).build(); + } + + @Test + public void testNeConnection() { + service.removeNetworkConnection(NODEID); + service.removeNetworkConnection(NODEID2); + + clearDbEntity(Entity.NetworkelementConnection); + List<NetworkElementConnectionEntity> nes = service.getNetworkElementConnections(); + assertEquals(0, nes.size()); + service.updateNetworkConnection22(createNeConnection(NODEID, NetworkElementDeviceType.Unknown), NODEID); + service.updateNetworkConnection22(createNeConnection(NODEID2, NetworkElementDeviceType.ORAN), NODEID2); + nes = service.getNetworkElementConnections(); + assertEquals(2, nes.size()); + service.updateNetworkConnectionDeviceType(createNeConnection(NODEID, NetworkElementDeviceType.Wireless), + NODEID); + nes = service.getNetworkElementConnections(); + assertEquals(2, nes.size()); + boolean found = false; + for (NetworkElementConnectionEntity ne : nes) { + if (NODEID.equals(ne.getNodeId()) && ne.getDeviceType() == NetworkElementDeviceType.Wireless) { + found = true; + } + } + assertTrue(found); + + } + + @Test + public void testConnectionLog() { + clearDbEntity(Entity.Connectionlog); + service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted)); + service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted)); + assertEquals(2, getDbEntityEntries(Entity.Connectionlog).getTotal()); + } + + /** + * @param nodeId + * @param status + * @return + */ + private static ConnectionlogEntity createConnectionLog(String nodeId, ConnectionLogStatus status) { + return new ConnectionlogBuilder().setNodeId(nodeId) + .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setStatus(status).build(); + } + + @Test + public void testInventory() { + clearDbEntity(Entity.Inventoryequipment); + service.writeInventory(createEquipment(NODEID, "uuid1")); + service.writeInventory(createEquipment(NODEID, "uuid2")); + service.writeInventory(createEquipment(NODEID2, "uuid3")); + service.writeInventory(createEquipment(NODEID2, "uuid4")); + service.writeInventory(createEquipment(NODEID2, "uuid5")); + assertEquals(5, getDbEntityEntries(Entity.Inventoryequipment).getTotal()); + } + + private static SearchResult<SearchHit> getDbEntityEntries(Entity entity) { + return dbRawProvider.doReadAllJsonData(entity.getName()); + } + + private static void clearDbEntity(Entity entity) { + DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName()); + query.setQuery(QueryBuilders.matchAllQuery().toJSON()); + try { + dbRawProvider.deleteByQuery(query); + } catch (IOException e) { + e.printStackTrace(); + } + TestCRUDforDatabase.trySleep(1000); + } + + /** + * @param nodeId + * @param uuid + * @return + */ + private Inventory createEquipment(String nodeId, String uuid) { + return new InventoryBuilder().setNodeId(nodeId).setParentUuid("").setDescription("desc") + .setManufacturerName("manu").setUuid(uuid).build(); + } + + /** + * @param devType + * @param nodename3 + * @return + */ + private static NetworkElementConnectionEntity createNeConnection(String nodeId, NetworkElementDeviceType devType) { + return new NetworkElementConnectionBuilder().setNodeId(nodeId).setHost("host").setPort(1234L) + .setCoreModelCapability("123").setStatus(ConnectionLogStatus.Connected).setDeviceType(devType) + .setIsRequired(true).build(); + } + + /** + * @param nodeId + * @param objectId + * @param problem + * @param severity + * @param counter + * @return + */ + private static FaultlogEntity createFaultLog(String nodeId, String objectId, String problem, SeverityType severity, + int counter) { + return new FaultlogBuilder().setNodeId(nodeId).setObjectId(objectId).setProblem(problem).setSeverity(severity) + .setCounter(counter).setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()) + .setSourceType(SourceType.Netconf).build(); + } + + /** + * @param nodeId + * @param objectId + * @param attributeName + * @param newValue + * @param counter + * @return + */ + private static EventlogEntity createEventLog(String nodeId, String objectId, String attributeName, String newValue, + int counter) { + return new EventlogBuilder().setNodeId(nodeId).setObjectId(objectId).setAttributeName(attributeName) + .setNewValue(newValue).setCounter(counter) + .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setSourceType(SourceType.Netconf) + .build(); + } +} diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java index 94381b6a3..5ce8fcc0b 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java @@ -17,23 +17,47 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.List; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Sortorder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.SortorderBuilder; public class TestFilterConversion { private static final String PROPERTY = "node-id"; + private static final String PROPERTY2 = "_id"; + private static final String PROPERTY3 = "timestamp"; @Test public void testQuestionMark() { - List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build()); - QueryBuilder query = QueryByFilter.fromFilter(filters ); + List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build()); + QueryBuilder query = QueryByFilter.fromFilter(filters); + System.out.println(query.toJSON()); + assertTrue(query.toJSON().contains("{1,1}")); + assertNotNull(QueryByFilter.getFilter(filters, PROPERTY)); + assertNull(QueryByFilter.getFilter(filters, PROPERTY2)); + filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(), + new FilterBuilder().setProperty(PROPERTY2).setFiltervalue("abc").build()); + query = QueryByFilter.fromFilter(filters); System.out.println(query.toJSON()); + assertNotNull(QueryByFilter.getFilter(filters, PROPERTY2)); + filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(), + new FilterBuilder().setProperty(PROPERTY3).setFiltervalue("<2019-06-13T15:00:12.0Z").build()); + query = QueryByFilter.fromFilter(filters); + List<Sortorder> sortorder = Arrays + .asList(new SortorderBuilder().setProperty(PROPERTY).setSortorder(SortOrder.Ascending).build()); + QueryByFilter.setSortOrder(query, sortorder); + assertNotNull(QueryByFilter.getSortOrder(sortorder, PROPERTY)); } } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java new file mode 100644 index 000000000..eae301a34 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; + +import static org.junit.Assert.fail; + +import java.util.Set; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DataProviderService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.RpcService; + +import net.bytebuddy.implementation.bytecode.StackSize; + +/** + * @author Michael Dürre + * + */ +public class TestImplementation { + + @Test + public void test() { + DataProviderImpl impl = new DataProviderImpl(); + impl.setRpcProviderService(new RpcProviderService() { + + @Override + public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, + T implementation, Set<InstanceIdentifier<?>> paths) { + // TODO Auto-generated method stub + return null; + } + + @Override + public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, + T implementation) { + // TODO Auto-generated method stub + return null; + } + }); + impl.setMediatorServerServlet(new MsServlet()); + impl.setAboutServlet(new AboutHttpServlet()); + try { + impl.init(); + } catch (Exception e) { + e.printStackTrace(); + fail("failed to init impl: "+e.getMessage()); + } + + impl.setStatus(StatusKey.CLUSTER_SIZE, "3"); + impl.setReadyStatus(true); + try { + impl.close(); + } catch (Exception e) { + e.printStackTrace(); + fail("failed to close impl: "+e.getMessage()); + } + } + +} diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceService.java new file mode 100644 index 000000000..bd91219c8 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceService.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtDatabaseEventsService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtDatabaseMaintenanceService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceEntity; + +/** + * - Handling of inital values for Maintenance mode. + */ +public class TestMaintenanceService { + + private static ElasticSearchDataProvider dbProvider; + private static HtDatabaseClient dbRawProvider; + private static HtDatabaseMaintenance service = null; + + private static final String NODEID = "node1"; + private static final String NODEID2 = "node2"; + @BeforeClass + public static void init() throws Exception { + + dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts); + dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS); + dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts); + service = dbProvider.getHtDatabaseMaintenance(); + } + @Test + public void test() { + clearDbEntity(Entity.Maintenancemode); + MaintenanceEntity obj = service.createIfNotExists(NODEID); + assertNotNull(obj); + obj = service.createIfNotExists(NODEID2); + assertNotNull(obj); + obj = service.getMaintenance(NODEID); + assertNotNull(obj); + List<MaintenanceEntity> list = service.getAll(); + assertEquals(2,list.size()); + service.deleteIfNotRequired(NODEID); + obj = service.getMaintenance(NODEID); + assertNull(obj); + + + obj = service.setMaintenance(createMaintenance(NODEID,true)); + + + } + /** + * @param nodeId + * @param active + * @return + */ + private static MaintenanceEntity createMaintenance(String nodeId, Boolean active) { + return new MaintenanceBuilder().setNodeId(nodeId).setActive(active).setProblem("problem").setObjectIdRef("idref").build(); + } + private static void clearDbEntity(Entity entity) { + DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName()); + query.setQuery(QueryBuilders.matchAllQuery().toJSON()); + try { + dbRawProvider.deleteByQuery(query); + } catch (IOException e) { + e.printStackTrace(); + } + TestCRUDforDatabase.trySleep(1000); + } + +} diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java new file mode 100644 index 000000000..20c0da596 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; + +/** + * @author Michael Dürre + * + */ +public class TestMediatorServerService { + private static final String SERVERID = null; + private static ElasticSearchDataProvider dbProvider; + private static HtDatabaseClient dbRawProvider; + private static MediatorServerDataProvider service = null; + + + @BeforeClass + public static void init() throws Exception { + + dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts); + dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS); + dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts); + service = new MediatorServerDataProvider(TestCRUDforDatabase.hosts); + + + } + @Test + public void test() { + clearDbEntity(Entity.MediatorServer); + System.out.println(service.triggerReloadSync()); + String dbServerId="abc"; + String host = service.getHostUrl(dbServerId); + assertNull(host); + final String NAME="ms1"; + final String HOST = "http://10.20.30.40:7070"; + CreateMediatorServerOutputBuilder output = null; + try { + output = dbProvider.createMediatorServer(new CreateMediatorServerInputBuilder().setName(NAME).setUrl(HOST).build()); + } catch (IOException e) { + e.printStackTrace(); + fail("unable to create ms entry: "+e.getMessage()); + } + System.out.println(service.triggerReloadSync()); + host = service.getHostUrl(output.getId()); + assertEquals(HOST, host); + + } + + private static void clearDbEntity(Entity entity) { + DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName()); + query.setQuery(QueryBuilders.matchAllQuery().toJSON()); + try { + dbRawProvider.deleteByQuery(query); + } catch (IOException e) { + e.printStackTrace(); + } + TestCRUDforDatabase.trySleep(1000); + } +} diff --git a/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang b/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang index ca52678dd..4272892a7 100644 --- a/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang +++ b/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang @@ -1,15 +1,37 @@ module devicemanager-gran { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-gran"; - prefix "devicemanager-gran"; - description - "DeviceManager 3gpp Api Module"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-gran"; + prefix devicemanager-gran; + + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + O-RAN1: <https://wiki.o-ran-sc.org/display/OAM/Operations+and+Maintenance"; + + description + "DeviceManager 3gpp Api Module - revision "2019-11-29" { - description - "Initial revision"; - } + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. - } + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2019-11-29 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } +} diff --git a/sdnr/wt/devicemanager-gran/provider/pom.xml b/sdnr/wt/devicemanager-gran/provider/pom.xml index b8ef8637f..6cd317f01 100644 --- a/sdnr/wt/devicemanager-gran/provider/pom.xml +++ b/sdnr/wt/devicemanager-gran/provider/pom.xml @@ -131,29 +131,6 @@ </excludes> </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generateDTOs</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>bash</executable> - <arguments> - <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh - </argument> - <argument>initfile</argument> - <argument>-f</argument> - <argument>${project.build.directory}/EsInit.script</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> diff --git a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java index 077f02c4e..0f7266061 100644 --- a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java +++ b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java @@ -39,7 +39,7 @@ public class GRanNetworkElement implements NetworkElement { @SuppressWarnings("unused") private final DataProvider databaseService; - GRanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { + public GRanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { log.info("Create {}",GRanNetworkElement.class.getSimpleName()); this.netconfAccessor = netconfAccess; this.databaseService = databaseService; @@ -52,10 +52,12 @@ public class GRanNetworkElement implements NetworkElement { @Override public void deregister() { + log.info("deRegister actions should be here"); } @Override public void warmstart() { + log.info("Warmstart actions should be here"); } @Override diff --git a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/impl/DeviceManagerGRanImpl.java b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/impl/DeviceManagerGRanImpl.java index d85515bb4..961a9b7ff 100644 --- a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/impl/DeviceManagerGRanImpl.java +++ b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/impl/DeviceManagerGRanImpl.java @@ -17,7 +17,6 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.impl; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; @@ -28,12 +27,10 @@ public class DeviceManagerGRanImpl implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerGRanImpl.class); private static final String APPLICATION_NAME = "DeviceManagerGRan"; - private static final String CONFIGURATIONFILE = "etc/devicemanager-gran.properties"; - + private NetconfNetworkElementService netconfNetworkElementService; private Boolean devicemanagerInitializationOk; - private DataProvider dataProvider; private FactoryRegistration<GRanNetworkElementFactory> factoryRegistration; // Blueprint 1 @@ -43,7 +40,7 @@ public class DeviceManagerGRanImpl implements AutoCloseable { netconfNetworkElementService = null; factoryRegistration = null; - dataProvider = null; + } public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { this.netconfNetworkElementService = netconfNetworkElementService; @@ -54,8 +51,6 @@ public class DeviceManagerGRanImpl implements AutoCloseable { LOG.info("Session Initiated start {}", APPLICATION_NAME); // Intialization factoryRegistration = netconfNetworkElementService.registerNetworkElementFactory(new GRanNetworkElementFactory()); - dataProvider = netconfNetworkElementService.getServiceProvider().getDataProvider(); - netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); this.devicemanagerInitializationOk = true; diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java index e086c0ca0..c008986e0 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,29 +15,34 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test; -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.impl.DeviceManagerGRanImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; -public class OnfNetworkElementFactory implements NetworkElementFactory { +public class TestDeviceManagerGRanImpl { + GRanNetworkElementFactory factory = new GRanNetworkElementFactory(); + DeviceManagerServiceProvider serviceProvider; + + @Test + public void test() throws Exception { + serviceProvider = mock(DeviceManagerServiceProvider.class); + NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class); + when(netconfNetworkElementService.registerNetworkElementFactory(factory)).thenReturn(null); + when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider); + + DeviceManagerGRanImpl devMgrGRan = new DeviceManagerGRanImpl(); + + devMgrGRan.setNetconfNetworkElementService(netconfNetworkElementService); + devMgrGRan.init(); + devMgrGRan.close(); + + } - private static final Logger log = LoggerFactory.getLogger(OnfNetworkElementFactory.class); - - @Override - public Optional<NetworkElement> create(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { - if (acessor.getCapabilites().isSupportingNamespace(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement.QNAME)) { - log.info("Create device {} ",OnfNetworkElement.class.getName()); - return Optional.of(new OnfNetworkElement(acessor, serviceProvider.getDataProvider())); - } else { - return Optional.empty(); - } - } } diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java new file mode 100644 index 000000000..ac232a008 --- /dev/null +++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElement; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class TestGRanNetworkElement { + + private static final String NODEID = "node1"; + + @Test + public void test() { + NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); + DataProvider databaseService = mock(DataProvider.class); + + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + + GRanNetworkElement gRanNe = new GRanNetworkElement(netconfAccessor, databaseService); + assertEquals(3, gRanNe.getDeviceType().getIntValue()); + assertEquals("RAN3GPP", gRanNe.getDeviceType().getName()); + assertEquals(NODEID, gRanNe.getNodeId().getValue()); + + gRanNe.register(); + gRanNe.deregister(); + gRanNe.warmstart(); + gRanNe.getAcessor(); + gRanNe.getService(null); + + } + + +} diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java new file mode 100644 index 000000000..db25465eb --- /dev/null +++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.top.rev180731.TopGrp; + + +public class TestGRanNetworkElementFactory { + + Capabilities capabilities; + NetconfAccessor netconfAccessor; + DeviceManagerServiceProvider devMgrService; + + @SuppressWarnings("unused") + @Before + public void init() { + capabilities = mock(Capabilities.class); + netconfAccessor = mock(NetconfAccessor.class); + devMgrService = mock(DeviceManagerServiceProvider.class); + + when(netconfAccessor.getCapabilites()).thenReturn(capabilities); + when(devMgrService.getDataProvider()).thenReturn(null); + + } + + @Test + public void testCreate() throws Exception { + when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(true); + + GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory(); + assertTrue((gRanNeFactory.create(netconfAccessor, devMgrService)).isPresent()); + } + + @Test + public void testCreateNone() throws Exception { + when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(false); + + GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory(); + assertTrue(!(gRanNeFactory.create(netconfAccessor, devMgrService).isPresent())); + } + +} diff --git a/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang b/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang index 11a3e83ef..2a943658b 100644 --- a/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang +++ b/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang @@ -1,15 +1,37 @@ module devicemanager-onf { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-onf"; - prefix "devicemanager-onf"; - description - "DeviceManager Open Network Foundation Api Module"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-onf"; + prefix devicemanager-onf; + + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + O-RAN: <https://wiki.o-ran-sc.org/display/OAM/Operations+and+Maintenance"; + + description + "DeviceManager Open Network Foundation Api Module + + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. - revision "2019-12-09" { - description - "Initial revision"; - } + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - } + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2019-12-09 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/pom.xml b/sdnr/wt/devicemanager-onf/provider/pom.xml index 031c20416..63db46fe1 100644 --- a/sdnr/wt/devicemanager-onf/provider/pom.xml +++ b/sdnr/wt/devicemanager-onf/provider/pom.xml @@ -107,28 +107,6 @@ </excludes> </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generateDTOs</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>bash</executable> - <arguments> - <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument> - <argument>initfile</argument> - <argument>-f</argument> - <argument>${project.build.directory}/EsInit.script</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java index 18e3c0b10..4993b5e4a 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java @@ -82,13 +82,13 @@ public class ExtendedEquipment { // General inventoryBuilder.setNodeId(getNodeId()); inventoryBuilder.setParentUuid(getParentUuid()); - inventoryBuilder.setTreeLevel(new Long(getTreeLevel())); + inventoryBuilder.setTreeLevel(Long.valueOf(getTreeLevel())); - if (equipment != null) { - inventoryBuilder.setUuid(equipment.getUuid().getValue()); + if (getEquipment() != null) { + inventoryBuilder.setUuid(getEquipment().getUuid().getValue()); // -- String list with ids of holders List<String> containerHolderKeyList = new ArrayList<>(); - List<ContainedHolder> containerHolderList = equipment.getContainedHolder(); + List<ContainedHolder> containerHolderList = getEquipment().getContainedHolder(); if (containerHolderList != null) { for (ContainedHolder containerHolder : containerHolderList) { containerHolderKeyList.add(containerHolder.getUuid().getValue()); @@ -97,7 +97,7 @@ public class ExtendedEquipment { inventoryBuilder.setContainedHolder(containerHolderKeyList); // -- Manufacturer related things - ManufacturedThing mThing = equipment.getManufacturedThing(); + ManufacturedThing mThing = getEquipment().getManufacturedThing(); if (mThing != null) { ManufacturerProperties mProperties = mThing.getManufacturerProperties(); if (mProperties != null) { @@ -117,7 +117,7 @@ public class ExtendedEquipment { String manufacturedDateString = mInstance.getManufactureDate(); if (manufacturedDateString != null && !manufacturedDateString.isEmpty()) { try { - inventoryBuilder.setDate(mInstance.getManufactureDate()); + inventoryBuilder.setDate(manufacturedDateString); } catch (IllegalArgumentException e) { LOG.debug("Format problem", e); } diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java index b2d4404c8..c67efe3df 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java @@ -63,11 +63,11 @@ public class ONFCoreNetworkElement12Equipment { private final @NonNull List<ExtendedEquipment> globalEquipmentList; public ONFCoreNetworkElement12Equipment(NetconfAccessor acessor, NetworkElementCoreData coreData, Capabilities capabilities) { - LOG.debug("Initialize " + ONFCoreNetworkElement12Equipment.class.getName()); + LOG.debug("Initialize class: {} " + ONFCoreNetworkElement12Equipment.class.getName()); this.acessor = acessor; this.coreData = coreData; if (capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)) { - this.equipmentPac = new WrapperEquipmentPacRev170402(acessor, coreData); + this.equipmentPac = new WrapperEquipmentPacRev170402(acessor); LOG.debug("Equipement pac supported {}", WrapperEquipmentPacRev170402.QNAME); } else { this.equipmentPac = null; @@ -264,10 +264,9 @@ public class ONFCoreNetworkElement12Equipment { InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier.builder(Equipment.class, new EquipmentKey(interfacePacUuid)).build(); - Equipment res = getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + return getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, equipmentIID); - return res; } /** @@ -285,10 +284,9 @@ public class ONFCoreNetworkElement12Equipment { InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier.builder(Equipment.class).build(); - Equipment res = getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + return getGenericTransactionUtils().readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, equipmentIID); - return res; } /** diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java index 6da673766..229f88cfa 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java @@ -45,7 +45,7 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { private final NetconfAccessor acessor; - public WrapperEquipmentPacRev170402(NetconfAccessor acessor, NetworkElementCoreData coreData) { + public WrapperEquipmentPacRev170402(NetconfAccessor acessor) { this.acessor = acessor; } @@ -67,9 +67,7 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { final Class<EquipmentPac> clazzPac = EquipmentPac.class; final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class; final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), acessor.getNodeId(), interfacePacUuid.getValue()); @@ -83,7 +81,7 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { EquipmentCurrentProblems problems = getGenericTransactionUtils().readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, interfaceIID); if (problems == null) { - LOG.debug("DBRead Id {} no {}", interfacePacUuid, clazzProblems, clazzProblems.getName()); + LOG.debug("DBRead Id {} no {} name {}", interfacePacUuid, clazzProblems, clazzProblems.getName()); } else { // -- Specific part 3 for (CurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) { diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java index fc321a5e1..d200530fc 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/Helper.java @@ -29,10 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.r */ public class Helper { - private static @NonNull UniversalId DEFAULT_UniversalId = new UniversalId("Default"); - private static @NonNull LayerProtocolName DEFAULT_LayerProtocolName = new LayerProtocolName("default"); - private static @NonNull GranularityPeriodType DEFAULT_GranularityPeriodType = GranularityPeriodType.Unknown; - private static @NonNull String DEFAULT_String = ""; + private static final @NonNull UniversalId DEFAULT_UniversalId = new UniversalId("Default"); + private static final @NonNull LayerProtocolName DEFAULT_LayerProtocolName = new LayerProtocolName("default"); + private static final @NonNull GranularityPeriodType DEFAULT_GranularityPeriodType = GranularityPeriodType.Unknown; + private static final @NonNull String DEFAULT_String = ""; public static @NonNull UniversalId nnGetUniversalId(@Nullable UniversalId x) { return x == null ? DEFAULT_UniversalId : x; diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java index 79124969c..08783ecef 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java @@ -86,7 +86,6 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw public static final QName QNAME = MwAirInterfacePac.QNAME; - //private NetworkElementCoreData coreData; private final NotificationService microwaveModelListener; private final NetconfAccessor acessor; private final TransactionUtils genericTransactionUtils; @@ -129,19 +128,19 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw FaultData resultList) { switch (lpName) { - case MWAirInterface: + case MWAIRINTERFACE: readTheFaultsOfMwAirInterfacePac(uuid, resultList); break; - case EthernetContainer12: + case ETHERNETCONTAINER12: readTheFaultsOfMwEthernetContainerPac(uuid, resultList); break; - case TDMContainer: + case TDMCONTAINER: readTheFaultsOfMwTdmContainerPac(uuid, resultList); break; - case Structure: + case STRUCTURE: if (lpClass == MwHybridMwStructurePac.class) { readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); @@ -155,10 +154,10 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); } break; - case Ethernet: + case ETHERNET: // No alarms supported break; - case EthernetContainer10: + case ETHERNETCONTAINER10: default: LOG.warn("Unassigned or not expected lp in model {}", lpName); } @@ -167,31 +166,12 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw @Override public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { PerformanceDataLtp res = new PerformanceDataLtp(); - res = readAirInterfacePerformanceData(lp, res); - res = readEthernetContainerPerformanceData(lp, res); + readAirInterfacePerformanceData(lp, res); + readEthernetContainerPerformanceData(lp, res); return res; } -// @Override -// public @NonNull List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { -// switch (lpName) { -// case MWAirInterface: -// return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); -// -// case EthernetContainer12: -// return readTheHistoricalPerformanceDataOfEthernetContainer(lp); -// -// case EthernetContainer10: -// case EthernetPhysical: -// case Ethernet: -// case TDMContainer: -// case Structure: -// case Unknown: -// LOG.debug("Do not read HistoricalPM data for {} {}", lpName, getUuid(lp)); -// break; -// } -// return new ArrayList<>(); -// } + @Override public Class<?> getClassForLtpExtension(QName qName) { Class<?> res = null; @@ -266,12 +246,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) { final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; - // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; - // final Class<AirInterfaceCurrentProblems> clazzProblems = - // AirInterfaceCurrentProblems.class; - // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = - // AirInterfaceCurrentProblemTypeG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -306,13 +281,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) { final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; - // final Class<MwEthernetContainerPacKey> clazzPacKey = - // MwEthernetContainerPacKey.class; - // final Class<EthernetContainerCurrentProblems> clazzProblems = - // EthernetContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -344,12 +313,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; - // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = - // MwAirInterfaceDiversityPacKey.class; final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; - // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = - // AirInterfaceDiversityCurrentProblemTypeG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -380,12 +345,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; - // final Class<MwPureEthernetStructurePacKey> clazzPacKey = - // MwPureEthernetStructurePacKey.class; final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; - // final Class<StructureCurrentProblemTypeG> clazzProblem = - // StructureCurrentProblemTypeG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -415,12 +376,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) { final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; - // final Class<MwHybridMwStructurePacKey> clazzPacKey = - // MwHybridMwStructurePacKey.class; final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; - // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = - // HybridMwStructureCurrentProblemsG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -460,9 +417,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + String mountpointId = acessor.getNodeId().getValue(); LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -492,63 +447,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw return resultList; } - /*----------------------------------------------------------------------------- - * Performance related data - */ - -// /** -// * PM MwAirInterfacePac -// * -// * @param lp -// * @return -// */ -// private @NonNull List<ExtendedAirInterfaceHistoricalPerformanceType12> readTheHistoricalPerformanceDataOfMwAirInterfacePac( -// Lp lp) { -// -// List<ExtendedAirInterfaceHistoricalPerformanceType12> resultList = new ArrayList<>(); -// LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), lp.getUuid()); -// // ---- -// UniversalId mwAirInterfacePacuuId = lp.getUuid(); -// // Step 2.1: construct data and the relative iid -// InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier -// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) -// .child(AirInterfaceConfiguration.class).build(); -// AirInterfaceConfiguration airConfiguration = genericTransactionUtils.readData(coreData.getDataBroker(), -// LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); -// -// if (airConfiguration == null) { -// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); -// -// } else { -// // Step 2.2: construct data and the relative iid -// InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier -// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) -// .child(AirInterfaceHistoricalPerformances.class).build(); -// -// // Step 2.3: read to the config data store -// AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData( -// coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); -// -// if (airHistoricalPerformanceData == null) { -// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", -// mwAirInterfacePacuuId); -// } else { -// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList -// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData -// .nonnullHistoricalPerformanceDataList(); -// LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, -// airHistPMList.size()); -// for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData -// .nonnullHistoricalPerformanceDataList()) { -// resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType12(pmRecord, airConfiguration)); -// } -// } -// } -// LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size()); -// return resultList; -// } - - /** + /** * Read and add performance data * @param lp to read from * @param result Object to be filled with data @@ -598,39 +497,6 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw return result; } -// private @NonNull List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) { -// -// final String myName = "MWEthernetContainerPac"; -// -// List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>(); -// LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, lp.getUuid()); -// // ---- -// UniversalId ethContainerPacuuId = lp.getUuid(); -// // Step 2.2: construct data and the relative iid -// InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier -// .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) -// .child(EthernetContainerHistoricalPerformances.class).build(); -// -// // Step 2.3: read to the config data store -// EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = genericTransactionUtils -// .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); -// -// if (ethContainerHistoricalPerformanceData == null) { -// LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); -// } else { -// // import -// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList -// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList -// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData -// .nonnullHistoricalPerformanceDataList(); -// LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); -// for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { -// resultList.add(pmRecord); -// } -// } -// LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size()); -// return resultList; -// } private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) { final String myName = "MWEthernetContainerPac"; @@ -663,11 +529,6 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw return result; } -// private static String getUuid(Lp lp) { -// UniversalId uuid = lp.getUuid(); -// return uuid != null ? uuid.getValue() : null; -// } - private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) { Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res = @@ -675,7 +536,4 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed); } - - - } diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java index ed3019cec..bee11b6be 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java @@ -133,19 +133,19 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { switch (lpName) { - case MWAirInterface: + case MWAIRINTERFACE: readTheFaultsOfMwAirInterfacePac(uuid, resultList); break; - case EthernetContainer12: + case ETHERNETCONTAINER12: readTheFaultsOfMwEthernetContainerPac(uuid, resultList); break; - case TDMContainer: + case TDMCONTAINER: readTheFaultsOfMwTdmContainerPac(uuid, resultList); break; - case Structure: + case STRUCTURE: if (lpClass == MwHybridMwStructurePac.class) { readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); @@ -159,10 +159,10 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); } break; - case Ethernet: + case ETHERNET: // No alarms supported break; - case EthernetContainer10: + case ETHERNETCONTAINER10: default: LOG.warn("Unassigned or not expected lp in model {}", lpName); } @@ -172,47 +172,26 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { PerformanceDataLtp res = new PerformanceDataLtp(); switch (lpName) { - case MWAirInterface: - res = readAirInterfacePerformanceData(lp, res); + case MWAIRINTERFACE: + readAirInterfacePerformanceData(lp, res); break; - case EthernetContainer12: - res = readEthernetContainerPerformanceData(lp, res); + case ETHERNETCONTAINER12: + readEthernetContainerPerformanceData(lp, res); break; - case EthernetContainer10: - case EthernetPhysical: - case Ethernet: - case TDMContainer: - case Structure: - case Unknown: + case ETHERNETCONTAINER10: + case ETHERNETPHYSICAL: + case ETHERNET: + case TDMCONTAINER: + case STRUCTURE: + case UNKNOWN: LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); break; } return res; } -// @Override -// public @NonNull List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { -// switch (lpName) { -// case MWAirInterface: -// return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); -// -// case EthernetContainer12: -// return readTheHistoricalPerformanceDataOfEthernetContainer(lp); -// -// case EthernetContainer10: -// case EthernetPhysical: -// case Ethernet: -// case TDMContainer: -// case Structure: -// case Unknown: -// LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); -// break; -// } -// return new ArrayList<>(); -// } - @Override public Class<?> getClassForLtpExtension(QName qName) { Class<?> res = null; @@ -288,12 +267,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; - // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; - // final Class<AirInterfaceCurrentProblems> clazzProblems = - // AirInterfaceCurrentProblems.class; - // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = - // AirInterfaceCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -327,13 +301,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; - // final Class<MwEthernetContainerPacKey> clazzPacKey = - // MwEthernetContainerPacKey.class; - // final Class<EthernetContainerCurrentProblems> clazzProblems = - // EthernetContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -364,12 +332,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; - // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = - // MwAirInterfaceDiversityPacKey.class; final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; - // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = - // AirInterfaceDiversityCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -399,12 +363,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; - // final Class<MwPureEthernetStructurePacKey> clazzPacKey = - // MwPureEthernetStructurePacKey.class; final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; - // final Class<StructureCurrentProblemTypeG> clazzProblem = - // StructureCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -434,12 +394,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; - // final Class<MwHybridMwStructurePacKey> clazzPacKey = - // MwHybridMwStructurePacKey.class; final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; - // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = - // HybridMwStructureCurrentProblemsG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -479,9 +435,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -510,96 +464,6 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw return resultList; } - /*----------------------------------------------------------------------------- - * Performance related data - */ - -// /** -// * PM MwAirInterfacePac -// * -// * @param lp -// * @return -// */ -// private @NonNull List<ExtendedAirInterfaceHistoricalPerformanceType1211> readTheHistoricalPerformanceDataOfMwAirInterfacePac( -// Lp lp) { -// -// String uuId = Helper.nnGetUniversalId(lp.getUuid()).getValue(); -// -// List<ExtendedAirInterfaceHistoricalPerformanceType1211> resultList = new ArrayList<>(); -// LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId); -// // ---- -// UniversalId mwAirInterfacePacuuId = new UniversalId(uuId); -// // Step 2.1: construct data and the relative iid -// InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier -// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) -// .child(AirInterfaceConfiguration.class).build(); -// AirInterfaceConfiguration airConfiguration = genericTransactionUtil.readData(coreData.getDataBroker(), -// LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID); -// -// if (airConfiguration == null) { -// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId); -// -// } else { -// // Step 2.2: construct data and the relative iid -// InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier -// .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId)) -// .child(AirInterfaceHistoricalPerformances.class).build(); -// -// // Step 2.3: read to the config data store -// AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtil.readData( -// coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); -// -// if (airHistoricalPerformanceData == null) { -// LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", -// mwAirInterfacePacuuId); -// } else { -// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData -// .nonnullHistoricalPerformanceDataList(); -// LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId, -// airHistPMList.size()); -// for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistPMList) { -// resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211(pmRecord, airConfiguration)); -// } -// } -// } -// LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size()); -// return resultList; -// } - -// private @NonNull List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) { -// -// final String myName = "MWEthernetContainerPac"; -// String uuId = Helper.nnGetUniversalId(lp.getUuid()).getValue(); -// -// List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>(); -// LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId); -// // ---- -// UniversalId ethContainerPacuuId = new UniversalId(uuId); -// // Step 2.2: construct data and the relative iid -// InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier -// .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId)) -// .child(EthernetContainerHistoricalPerformances.class).build(); -// -// // Step 2.3: read to the config data store -// EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = genericTransactionUtil -// .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID); -// -// if (ethContainerHistoricalPerformanceData == null) { -// LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId); -// } else { -// // import -// // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList -// List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData -// .nonnullHistoricalPerformanceDataList(); -// LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); -// for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) { -// resultList.add(pmRecord); -// } -// } -// LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size()); -// return resultList; -// } - /** * Read and add performance data * @param lp to read from diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java index dc2c4e995..633f24d96 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java @@ -132,19 +132,19 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { switch (lpName) { - case MWAirInterface: + case MWAIRINTERFACE: readTheFaultsOfMwAirInterfacePac(uuid, resultList); break; - case EthernetContainer12: + case ETHERNETCONTAINER12: readTheFaultsOfMwEthernetContainerPac(uuid, resultList); break; - case TDMContainer: + case TDMCONTAINER: readTheFaultsOfMwTdmContainerPac(uuid, resultList); break; - case Structure: + case STRUCTURE: if (lpClass == MwHybridMwStructurePac.class) { readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); @@ -158,10 +158,10 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); } break; - case Ethernet: + case ETHERNET: // No alarms supported break; - case EthernetContainer10: + case ETHERNETCONTAINER10: default: LOG.warn("Unassigned or not expected lp in model {}", lpName); } @@ -171,18 +171,18 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) { PerformanceDataLtp res = new PerformanceDataLtp(); switch (lpName) { - case MWAirInterface: + case MWAIRINTERFACE: return readAirInterfacePerformanceData(lp, res); - case EthernetContainer12: + case ETHERNETCONTAINER12: return readEthernetContainerPerformanceData(lp, res); - case EthernetContainer10: - case EthernetPhysical: - case Ethernet: - case TDMContainer: - case Structure: - case Unknown: + case ETHERNETCONTAINER10: + case ETHERNETPHYSICAL: + case ETHERNET: + case TDMCONTAINER: + case STRUCTURE: + case UNKNOWN: LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue()); } return res; @@ -263,12 +263,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class; - // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class; - // final Class<AirInterfaceCurrentProblems> clazzProblems = - // AirInterfaceCurrentProblems.class; - // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem = - // AirInterfaceCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -304,13 +299,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class; - // final Class<MwEthernetContainerPacKey> clazzPacKey = - // MwEthernetContainerPacKey.class; - // final Class<EthernetContainerCurrentProblems> clazzProblems = - // EthernetContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -343,12 +332,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; - // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey = - // MwAirInterfaceDiversityPacKey.class; final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; - // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem = - // AirInterfaceDiversityCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -380,12 +365,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; - // final Class<MwPureEthernetStructurePacKey> clazzPacKey = - // MwPureEthernetStructurePacKey.class; final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; - // final Class<StructureCurrentProblemTypeG> clazzProblem = - // StructureCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -417,12 +398,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw FaultData resultList) { final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; - // final Class<MwHybridMwStructurePacKey> clazzPacKey = - // MwHybridMwStructurePacKey.class; final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; - // final Class<HybridMwStructureCurrentProblemsG> clazzProblem = - // HybridMwStructureCurrentProblemsG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); @@ -464,9 +441,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; - // final Class<ContainerCurrentProblemTypeG> clazzProblem = - // ContainerCurrentProblemTypeG.class; - + LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), mountpointId, interfacePacUuid.getValue()); diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java index 056247941..04c3bc57b 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java @@ -26,20 +26,18 @@ import org.slf4j.LoggerFactory; public class DeviceManagerOnfImpl implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnfImpl.class); - private static final String APPLICATION_NAME = "DeviceManagerOnf"; - private static final String CONFIGURATIONFILE = "etc/devicemanager-onf.properties"; - + private static final String APPLICATIONNAME = "DeviceManagerOnf"; private NetconfNetworkElementService netconfNetworkElementService; private HtDatabaseClient htDatabaseClient; private Boolean devicemanagerInitializationOk = false; - private FactoryRegistration<ONFCoreNetworkElementFactory> resORan; + private FactoryRegistration<ONFCoreNetworkElementFactory> resOnf; // Blueprint begin public DeviceManagerOnfImpl() { - LOG.info("Creating provider for {}", APPLICATION_NAME); - resORan = null; + LOG.info("Creating provider for {}", APPLICATIONNAME); + resOnf = null; } public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { @@ -48,12 +46,12 @@ public class DeviceManagerOnfImpl implements AutoCloseable { public void init() throws Exception { - LOG.info("Session Initiated start {}", APPLICATION_NAME); + LOG.info("Session Initiated start {}", APPLICATIONNAME); - resORan = netconfNetworkElementService.registerNetworkElementFactory(new ONFCoreNetworkElementFactory()); + resOnf = netconfNetworkElementService.registerNetworkElementFactory(new ONFCoreNetworkElementFactory()); - netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); + netconfNetworkElementService.writeToEventLog(APPLICATIONNAME, "startup", "done"); this.devicemanagerInitializationOk = true; LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); @@ -64,7 +62,7 @@ public class DeviceManagerOnfImpl implements AutoCloseable { public void close() throws Exception { LOG.info("closing ..."); close(htDatabaseClient); - close(resORan); + close(resOnf); LOG.info("closing done"); } diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java deleted file mode 100644 index e2371de74..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl; - -import java.util.List; -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.mdsal.binding.api.NotificationService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - */ -public class OnfNetworkElement implements NetworkElement { - - private static final Logger log = LoggerFactory.getLogger(OnfNetworkElement.class); - - private final NetconfAccessor netconfAccessor; - - private final DataProvider databaseService; - - private @NonNull final OnfListener ranListener; - - private ListenerRegistration<NotificationListener> ranListenerRegistrationResult; - - OnfNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { - log.info("Create {}",OnfNetworkElement.class.getSimpleName()); - this.netconfAccessor = netconfAccess; - this.databaseService = databaseService; - - this.ranListenerRegistrationResult = null; - this.ranListener = new OnfListener(); - - } - - public void initialReadFromNetworkElement() { - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.ORAN; - } - - private void doRegisterNotificationListener(MountPoint mountPoint) { - log.info("Begin register listener for Mountpoint {}", mountPoint.getIdentifier().toString()); - final Optional<NotificationService> optionalNotificationService = mountPoint - .getService(NotificationService.class); - final NotificationService notificationService = optionalNotificationService.get(); - // notificationService.registerNotificationListener(microwaveEventListener); - ranListenerRegistrationResult = notificationService.registerNotificationListener(ranListener); - log.info("End registration listener for Mountpoint {} Listener: {} Result: {}", - mountPoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistrationResult); - } - - private class OnfListener implements IetfNetconfNotificationsListener { - - @Override - public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) { - log.info("onNetconfConfirmedCommit ", notification); - } - - @Override - public void onNetconfSessionStart(NetconfSessionStart notification) { - log.info("onNetconfSessionStart ", notification); - } - - @Override - public void onNetconfSessionEnd(NetconfSessionEnd notification) { - log.info("onNetconfSessionEnd ", notification); - } - - @Override - public void onNetconfCapabilityChange(NetconfCapabilityChange notification) { - log.info("onNetconfCapabilityChange ", notification); - } - - @Override - public void onNetconfConfigChange(NetconfConfigChange notification) { - log.info("onNetconfConfigChange (1) {}", notification); - StringBuffer sb = new StringBuffer(); - List<Edit> editList = notification.nonnullEdit(); - for (Edit edit : editList) { - if (sb.length() > 0) { - sb.append(", "); - } - sb.append(edit); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - - InstanceIdentifier<?> target = edit.getTarget(); - if (target != null) { - eventlogBuilder.setObjectId(target.toString()); - log.info("TARGET: {} {} {}", target.getClass(), target.getTargetType()); - for (PathArgument pa : target.getPathArguments()) { - log.info("PathArgument {}", pa); - } - } - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()); - eventlogBuilder.setNewValue(String.valueOf(edit.getOperation())); - databaseService.writeEventLog(eventlogBuilder.build()); - } - log.info("onNetconfConfigChange (2) {}", sb); - } - } - - @Override - public void register() { - } - - @Override - public void deregister() { - } - - - @Override - public NodeId getNodeId() { - return netconfAccessor.getNodeId(); - } - - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() { - } - - @Override - public Optional<NetconfAccessor> getAcessor() { - return Optional.of(netconfAccessor); - } - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java index 48f1ebba6..9fc0c9599 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java @@ -57,380 +57,378 @@ import org.slf4j.LoggerFactory; */ public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements NetworkElementCoreData { - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class); - - protected static final @NonNull List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>(); - // private static final List<Ltp> EMPTYLTPLIST = new ArrayList<>(); - - protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier - .builder(NetworkElement.class).build(); - - - /*----------------------------------------------------------------------------- - * Class members - */ - - // Non specific part. Used by all functions. - /** interfaceList is used by PM task and should be synchronized */ - @SuppressWarnings("null") - private final @NonNull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>()); - private Optional<NetworkElement> optionalNe; - - // Performance monitoring specific part - /** Lock for the PM access specific elements that could be null */ - private final @NonNull Object pmLock = new Object(); - protected @Nullable Iterator<Lp> interfaceListIterator = null; - /** Actual pmLp used during iteration over interfaces */ - protected @Nullable Lp pmLp = null; - - // Device monitoring specific part - /** Lock for the DM access specific elements that could be null */ - protected final @NonNull Object dmLock = new Object(); - - protected final boolean isNetworkElementCurrentProblemsSupporting12; - - protected final ONFCoreNetworkElement12Equipment equipment; - - protected final NodeId nodeId; - - /*--------------------------------------------------------------- - * Constructor - */ - - protected ONFCoreNetworkElement12Base(@NonNull NetconfAccessor acessor) { - super(acessor); - this.optionalNe = Optional.empty(); - this.nodeId = getAcessor().get().getNodeId(); - this.isNetworkElementCurrentProblemsSupporting12 = acessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); - this.equipment = new ONFCoreNetworkElement12Equipment(acessor, this, acessor.getCapabilites()); - WrapperPTPModelRev170208.initSynchronizationExtension(acessor); - LOG.debug("support necurrent-problem-list={}", this.isNetworkElementCurrentProblemsSupporting12); - } - - /*--------------------------------------------------------------- - * Getter/ Setter - */ - - @Override - public Optional<NetworkElement> getOptionalNetworkElement() { - return optionalNe; - } - - List<Lp> getInterfaceList() { - return interfaceList; - } - - public Object getPmLock() { - return pmLock; - } - - /*--------------------------------------------------------------- - * Core model related function - */ - - /** - * Get uuid of Optional NE. - * - * @return Uuid or EMPTY String if optionNE is not available - */ - protected String getUuId() { - String uuid = optionalNe.isPresent() ? Helper.nnGetUniversalId(optionalNe.get().getUuid()).getValue() : EMPTY; - return uuid; - } - - /** - * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new - * structure. From initial state it changes also. - */ - protected synchronized boolean readNetworkElementAndInterfaces() { - - LOG.debug("Update mountpoint if changed {}", getMountPointNodeName()); - - optionalNe = Optional.ofNullable(getGenericTransactionUtils().readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, - NETWORKELEMENT_IID)); - synchronized (pmLock) { - boolean change = false; - - if (!optionalNe.isPresent()) { - LOG.debug("Unable to read NE data for mountpoint {}", getMountPointNodeName()); - if (!interfaceList.isEmpty()) { - interfaceList.clear(); - interfaceListIterator = null; - change = true; - } - - } else { - NetworkElement ne = optionalNe.get(); - LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), ne.getName()); - List<Lp> actualInterfaceList = getLtpList(ne); - if (!interfaceList.equals(actualInterfaceList)) { - LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(), - actualInterfaceList.size()); - interfaceList.clear(); - interfaceList.addAll(actualInterfaceList); - interfaceListIterator = null; - change = true; - } - } - return change; - } - } - - /** - * Get List of UUIDs for conditional packages from Networkelement<br> - * Possible interfaces are:<br> - * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br> - * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br> - * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, - * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br> - * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br> - * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br> - * - * @param ne NetworkElement - * @return Id List, never null. - */ - - private static List<Lp> getLtpList(@Nullable NetworkElement ne) { - - List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>()); - - if (ne != null) { - List<Ltp> ltpRefList = ne.getLtp(); - if (ltpRefList == null) { - LOG.debug("DBRead NE-Interfaces: null"); - } else { - for (Ltp ltRefListE : ltpRefList) { - List<Lp> lpList = ltRefListE.getLp(); - if (lpList == null) { - LOG.debug("DBRead NE-Interfaces Reference List: null"); - } else { - for (Lp ltp : lpList) { - res.add(ltp); - } - } - } - } - } else { - LOG.debug("DBRead NE: null"); - } - - // ---- Debug - if (LOG.isDebugEnabled()) { - StringBuffer strBuf = new StringBuffer(); - for (Lp ltp : res) { - if (strBuf.length() > 0) { - strBuf.append(", "); - } - strBuf.append(Helper.nnGetLayerProtocolName(ltp.getLayerProtocolName()).getValue()); - strBuf.append(':'); - strBuf.append(Helper.nnGetUniversalId(ltp.getUuid()).getValue()); - } - LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString()); - } - // ---- Debug end - - return res; - } - - /** - * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB - * - * @return List with all problems - */ - protected FaultData readAllCurrentProblemsOfNode() { - - // Step 2.3: read the existing faults and add to DB - FaultData resultList = new FaultData(); - int idxStart; // Start index for debug messages - UniversalId uuid; - - synchronized (pmLock) { - for (Lp lp : interfaceList) { - - idxStart = resultList.size(); - uuid = lp.getUuid(); - FaultData.debugResultList(LOG, uuid.getValue(), resultList, idxStart); - - } - } - - // Step 2.4: Read other problems from mountpoint - if (isNetworkElementCurrentProblemsSupporting12) { - idxStart = resultList.size(); - readNetworkElementCurrentProblems12(resultList); - FaultData.debugResultList(LOG, "CurrentProblems12", resultList, idxStart); - } - - return resultList; - - } - - /** - * Reading problems for the networkElement V1.2 - * @param resultList to collect the problems - * @return resultList with additonal problems - */ - protected FaultData readNetworkElementCurrentProblems12(FaultData resultList) { - - LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName()); - - InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = - InstanceIdentifier.builder( - org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) - .build(); - - // Step 2.3: read to the config data store - NetworkElementPac problemPac; - NetworkElementCurrentProblems problems = null; - try { - problemPac = getGenericTransactionUtils().readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL, - networkElementCurrentProblemsIID); - if (problemPac != null) { - problems = problemPac.getNetworkElementCurrentProblems(); - } - if (problems == null) { - LOG.debug("DBRead no NetworkElementCurrentProblems12"); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems - .nonnullCurrentProblemList()) { - resultList.add(nodeId, problem.getSequenceNumber(), problem.getTimeStamp(), - problem.getObjectReference(), problem.getProblemName(), - WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity())); - } - } - } catch (Exception e) { - LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(), - e.getMessage()); - } - return resultList; - } - - /*--------------------------------------------------------------- - * Device Monitor - */ - - @Override - public boolean checkIfConnectionToMediatorIsOk() { - synchronized (dmLock) { - return optionalNe != null; - } - } - - /* - * New implementation to interpret status with empty LTP List as notConnected => return false - * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types - * it needs to be activated by extension or configuration. Change to be disabled at the moment - */ - @Override - public boolean checkIfConnectionToNeIsOk() { - return true; - } - - /*--------------------------------------------------------------- - * Synchronization - */ - - - /*--------------------------------------------------------------- - * Equipment related functions - */ - - @Override - public @NonNull InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { - LOG.debug("request inventory information. filter:" + layerProtocolFilter); - return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter)); - } - - @Override - public InventoryInformationDcae getInventoryInformation() { - return getInventoryInformation(null); - } - - protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) { - List<String> uuids = new ArrayList<>(); - - LOG.debug("request inventory information. filter:" + layerProtocolFilter); - if (optionalNe != null) { - // uuids - for (Lp lp : this.interfaceList) { - if (layerProtocolFilter == null || layerProtocolFilter.isEmpty()) { - uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue()); - } else if (layerProtocolFilter.equals(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue())) { - uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue()); - } - } - } - LOG.debug("uuids found: {}", uuids); - return uuids; - } - - - /*--------------------------------------------------------------- - * Performancemanagement specific interface - */ - - @Override - public void resetPMIterator() { - synchronized (pmLock) { - interfaceListIterator = interfaceList.iterator(); - } - LOG.debug("PM reset iterator"); - } - - @SuppressWarnings("null") - @Override - public boolean hasNext() { - boolean res; - synchronized (pmLock) { - res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false; - } - LOG.debug("PM hasNext LTP {}", res); - return res; - } - - @SuppressWarnings("null") - @Override - public void next() { - synchronized (pmLock) { - if (interfaceListIterator == null) { - pmLp = null; - LOG.debug("PM next LTP null"); - } else { - pmLp = interfaceListIterator.next(); - LOG.debug("PM next LTP {}", Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); - } - } - } - - @SuppressWarnings("null") - @Override - public String pmStatusToString() { - StringBuffer res = new StringBuffer(); - synchronized (pmLock) { - res.append(pmLp == null ? "no interface" : Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); - for (Lp lp : getInterfaceList()) { - res.append("IF:"); - res.append(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); - res.append(" "); - } - } - return res.toString(); - } - - @Override - public void doRegisterEventListener(MountPoint mountPoint) { - //Do nothing - } - - @SuppressWarnings("unchecked") - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return clazz.isInstance(this) ? Optional.of((L)this) : Optional.empty(); - } - - @Override - public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { - return Optional.empty(); - } + private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class); + + protected static final @NonNull List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>(); + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + + /*----------------------------------------------------------------------------- + * Class members + */ + + // Non specific part. Used by all functions. + /** interfaceList is used by PM task and should be synchronized */ + @SuppressWarnings("null") + private final @NonNull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>()); + private Optional<NetworkElement> optionalNe; + + // Performance monitoring specific part + /** Lock for the PM access specific elements that could be null */ + private final @NonNull Object pmLock = new Object(); + protected @Nullable Iterator<Lp> interfaceListIterator = null; + /** Actual pmLp used during iteration over interfaces */ + protected @Nullable Lp pmLp = null; + + // Device monitoring specific part + /** Lock for the DM access specific elements that could be null */ + protected final @NonNull Object dmLock = new Object(); + + protected final boolean isNetworkElementCurrentProblemsSupporting12; + + protected final ONFCoreNetworkElement12Equipment equipment; + + protected final NodeId nodeId; + + /*--------------------------------------------------------------- + * Constructor + */ + + protected ONFCoreNetworkElement12Base(@NonNull NetconfAccessor acessor) { + super(acessor); + this.optionalNe = Optional.empty(); + this.nodeId = getAcessor().get().getNodeId(); + this.isNetworkElementCurrentProblemsSupporting12 = acessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME); + this.equipment = new ONFCoreNetworkElement12Equipment(acessor, this, acessor.getCapabilites()); + WrapperPTPModelRev170208.initSynchronizationExtension(acessor); + LOG.debug("support necurrent-problem-list={}", this.isNetworkElementCurrentProblemsSupporting12); + } + + /*--------------------------------------------------------------- + * Getter/ Setter + */ + + @Override + public Optional<NetworkElement> getOptionalNetworkElement() { + return optionalNe; + } + + List<Lp> getInterfaceList() { + return interfaceList; + } + + public Object getPmLock() { + return pmLock; + } + + /*--------------------------------------------------------------- + * Core model related function + */ + + /** + * Get uuid of Optional NE. + * + * @return Uuid or EMPTY String if optionNE is not available + */ + protected String getUuId() { + return optionalNe.isPresent() ? Helper.nnGetUniversalId(optionalNe.get().getUuid()).getValue() : EMPTY; + } + + /** + * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new + * structure. From initial state it changes also. + */ + protected synchronized boolean readNetworkElementAndInterfaces() { + + LOG.debug("Update mountpoint if changed {}", getMountpoint()); + + optionalNe = Optional.ofNullable(getGenericTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)); + synchronized (pmLock) { + boolean change = false; + + if (!optionalNe.isPresent()) { + LOG.debug("Unable to read NE data for mountpoint {}", getMountpoint()); + if (!interfaceList.isEmpty()) { + interfaceList.clear(); + interfaceListIterator = null; + change = true; + } + + } else { + NetworkElement ne = optionalNe.get(); + LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountpoint(), ne.getName()); + List<Lp> actualInterfaceList = getLtpList(ne); + if (!interfaceList.equals(actualInterfaceList)) { + LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountpoint(), + actualInterfaceList.size()); + interfaceList.clear(); + interfaceList.addAll(actualInterfaceList); + interfaceListIterator = null; + change = true; + } + } + return change; + } + } + + /** + * Get List of UUIDs for conditional packages from Networkelement<br> + * Possible interfaces are:<br> + * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br> + * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br> + * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, + * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br> + * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br> + * + * @param ne NetworkElement + * @return Id List, never null. + */ + + private static List<Lp> getLtpList(@Nullable NetworkElement ne) { + + List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>()); + + if (ne != null) { + List<Ltp> ltpRefList = ne.getLtp(); + if (ltpRefList == null) { + LOG.debug("DBRead NE-Interfaces: null"); + } else { + for (Ltp ltRefListE : ltpRefList) { + List<Lp> lpList = ltRefListE.getLp(); + if (lpList == null) { + LOG.debug("DBRead NE-Interfaces Reference List: null"); + } else { + for (Lp ltp : lpList) { + res.add(ltp); + } + } + } + } + } else { + LOG.debug("DBRead NE: null"); + } + + // ---- Debug + if (LOG.isDebugEnabled()) { + StringBuilder strBuild = new StringBuilder(); + for (Lp ltp : res) { + if (strBuild.length() > 0) { + strBuild.append(", "); + } + strBuild.append(Helper.nnGetLayerProtocolName(ltp.getLayerProtocolName()).getValue()); + strBuild.append(':'); + strBuild.append(Helper.nnGetUniversalId(ltp.getUuid()).getValue()); + } + LOG.debug("DBRead NE-Interfaces: {}", strBuild.toString()); + } + // ---- Debug end + + return res; + } + + /** + * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB + * + * @return List with all problems + */ + protected FaultData readAllCurrentProblemsOfNode() { + + // Step 2.3: read the existing faults and add to DB + FaultData resultList = new FaultData(); + int idxStart; // Start index for debug messages + UniversalId uuid; + + synchronized (pmLock) { + for (Lp lp : interfaceList) { + + idxStart = resultList.size(); + uuid = lp.getUuid(); + FaultData.debugResultList(LOG, uuid.getValue(), resultList, idxStart); + + } + } + + // Step 2.4: Read other problems from mountpoint + if (isNetworkElementCurrentProblemsSupporting12) { + idxStart = resultList.size(); + readNetworkElementCurrentProblems12(resultList); + FaultData.debugResultList(LOG, "CurrentProblems12", resultList, idxStart); + } + + return resultList; + + } + + /** + * Reading problems for the networkElement V1.2 + * @param resultList to collect the problems + * @return resultList with additonal problems + */ + protected FaultData readNetworkElementCurrentProblems12(FaultData resultList) { + + LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountpoint()); + + InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID = + InstanceIdentifier.builder( + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class) + .build(); + + // Step 2.3: read to the config data store + NetworkElementPac problemPac; + NetworkElementCurrentProblems problems = null; + try { + problemPac = getGenericTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL, + networkElementCurrentProblemsIID); + if (problemPac != null) { + problems = problemPac.getNetworkElementCurrentProblems(); + } + if (problems == null) { + LOG.debug("DBRead no NetworkElementCurrentProblems12"); + } else { + for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems + .nonnullCurrentProblemList()) { + resultList.add(nodeId, problem.getSequenceNumber(), problem.getTimeStamp(), + problem.getObjectReference(), problem.getProblemName(), + WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity())); + } + } + } catch (Exception e) { + LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountpoint(), + e.getMessage()); + } + return resultList; + } + + /*--------------------------------------------------------------- + * Device Monitor + */ + + @Override + public boolean checkIfConnectionToMediatorIsOk() { + synchronized (dmLock) { + return optionalNe != null; + } + } + + /* + * New implementation to interpret status with empty LTP List as notConnected => return false + * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types + * it needs to be activated by extension or configuration. Change to be disabled at the moment + */ + @Override + public boolean checkIfConnectionToNeIsOk() { + return true; + } + + /*--------------------------------------------------------------- + * Synchronization + */ + + + /*--------------------------------------------------------------- + * Equipment related functions + */ + + @Override + public @NonNull InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { + LOG.debug("request inventory information. filter: {}" + layerProtocolFilter); + return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter)); + } + + @Override + public InventoryInformationDcae getInventoryInformation() { + return getInventoryInformation(null); + } + + protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) { + List<String> uuids = new ArrayList<>(); + + LOG.debug("request inventory information. filter: {}" + layerProtocolFilter); + if (optionalNe != null) { + // uuids + for (Lp lp : this.interfaceList) { + if (layerProtocolFilter == null || + layerProtocolFilter.isEmpty() || + layerProtocolFilter.equals(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue())) { + uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue()); + } + } + } + LOG.debug("uuids found: {}", uuids); + return uuids; + } + + + /*--------------------------------------------------------------- + * Performancemanagement specific interface + */ + + @Override + public void resetPMIterator() { + synchronized (pmLock) { + interfaceListIterator = interfaceList.iterator(); + } + LOG.debug("PM reset iterator"); + } + + @SuppressWarnings("null") + @Override + public boolean hasNext() { + boolean res; + synchronized (pmLock) { + res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false; + } + LOG.debug("PM hasNext LTP {}", res); + return res; + } + + @SuppressWarnings("null") + @Override + public void next() { + synchronized (pmLock) { + if (interfaceListIterator == null) { + pmLp = null; + LOG.debug("PM next LTP null"); + } else { + pmLp = interfaceListIterator.next(); + LOG.debug("PM next LTP {}", Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); + } + } + } + + @SuppressWarnings("null") + @Override + public String pmStatusToString() { + StringBuilder res = new StringBuilder(); + synchronized (pmLock) { + res.append(pmLp == null ? "no interface" : Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue()); + for (Lp lp : getInterfaceList()) { + res.append("IF:"); + res.append(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue()); + res.append(" "); + } + } + return res.toString(); + } + + @Override + public void doRegisterEventListener(MountPoint mountPoint) { + //Do nothing + } + + @SuppressWarnings("unchecked") + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return clazz.isInstance(this) ? Optional.of((L)this) : Optional.empty(); + } + + @Override + public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { + return Optional.empty(); + } } diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java index fb73b823e..b152824ee 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java @@ -104,7 +104,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { int problems = faultService.removeAllCurrentProblemsOfNode(nodeId); FaultData resultList = readAllCurrentProblemsOfNode(); faultService.initCurrentProblemStatus(nodeId, resultList); - LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), + LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(), getUuId(), problems, resultList.size()); } } @@ -130,8 +130,8 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { */ @Override public synchronized void initialReadFromNetworkElement() { - // optionalNe.getLtp().get(0).getLp(); - LOG.debug("Get info about {}", getMountPointNodeName()); + + LOG.debug("Get info about {}", getMountpoint()); int problems = faultService.removeAllCurrentProblemsOfNode(nodeId); LOG.debug("Removed all {} problems from database at registration", problems); @@ -150,7 +150,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { faultService.initCurrentProblemStatus(nodeId, resultList); equipmentService.writeEquipment(equipment.getEquipmentData()); - LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), + LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(), resultList.size()); } @@ -166,9 +166,6 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { public void register() { // Setup microwaveEventListener for notification service - // MicrowaveEventListener microwaveEventListener = new - // MicrowaveEventListener(mountPointNodeName, websocketmanagerService, - // xmlMapper, databaseClientEvents); doRegisterEventListener(acessor.getMountpoint()); // Register netconf stream @@ -201,6 +198,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base { @Override public void close() throws Exception { + // Close to be implemented } diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java index c90e76efc..505e0ca12 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java @@ -110,7 +110,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(nodeId); FaultData resultList = readAllCurrentProblemsOfNode(); microwaveEventListener.initCurrentProblemStatus(nodeId, resultList); - LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(), + LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(), getUuId(), problems, resultList.size()); } } @@ -187,8 +187,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas */ @Override public synchronized void initialReadFromNetworkElement() { - // optionalNe.getLtp().get(0).getLp(); - LOG.debug("Get info about {}", getMountPointNodeName()); + LOG.debug("Get info about {}", getMountpoint()); int problems = microwaveEventListener.removeAllCurrentProblemsOfNode(nodeId); LOG.debug("Removed all {} problems from database at registration", problems); @@ -207,7 +206,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas microwaveEventListener.initCurrentProblemStatus(nodeId, resultList); equipmentService.writeEquipment(equipment.getEquipmentData()); - LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(), + LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(), resultList.size()); } @@ -220,7 +219,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas */ private void debugResultList(String uuid, FaultData resultList, int idxStart) { if (LOG.isDebugEnabled()) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int idx = 0; for (int t = idxStart; t < resultList.size(); t++) { sb.append(idx++); @@ -228,7 +227,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas sb.append(resultList.get(t)); sb.append('}'); } - LOG.debug("Found problems {} {}", uuid, sb.toString()); + LOG.debug("Found problems {} {}", uuid, sb); } } @@ -290,7 +289,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas if (valueName.contentEquals("capability")) { capability = e.getValue(); if (capability != null) { - int idx = capability.indexOf("?"); + int idx = capability.indexOf('?'); if (idx != -1) { capability = capability.substring(0, idx); } @@ -310,7 +309,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas // "2017-03-24", "mw-air-interface-pac").intern(); LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision, conditionalPackage); - if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) { + if (capability != null && !capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) { try { QName qName = QName.create(capability, revision, conditionalPackage); res = this.microwaveModel.getClassForLtpExtension(qName); diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java index 0eb1982b2..5bbeb74ef 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java @@ -57,7 +57,6 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor private final String mountPointNodeName; private final NodeId nodeId; private final DataBroker netconfNodeDataBroker; - private final Capabilities capabilities; private final NetconfAccessor acessor; protected ONFCoreNetworkElementBase(NetconfAccessor acessor) { @@ -65,7 +64,6 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor this.mountPointNodeName = acessor.getNodeId().getValue(); this.nodeId = acessor.getNodeId(); this.netconfNodeDataBroker = acessor.getDataBroker(); - this.capabilities = acessor.getCapabilites(); this.acessor = acessor; } @@ -79,73 +77,14 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor public String getMountPointNodeName() { return mountPointNodeName; } - + /** * @return the netconfNodeDataBroker */ public DataBroker getNetconfNodeDataBroker() { return netconfNodeDataBroker; } - - /** - * @return the capabilities - */ - public Capabilities getCapabilities() { - return capabilities; - } - - /** - * Update devicetype and let all other field empty - * @param deviceType that should be updated - * @return NetworkElementConnectionEntity with related parameter - */ - public static NetworkElementConnectionEntity getNetworkConnectionDeviceTpe(NetworkElementDeviceType deviceType) { - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - eb.setDeviceType(deviceType); - return eb.build(); - } - - /** - * Provide device specific data - * @param nodeId mountpoint id - * @param nNode data - * @return NetworkElementConnectionEntity specific information - */ - public static NetworkElementConnectionEntity getNetworkConnection(String nodeId, @Nonnull NetconfNode nNode) { - - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - // -- basics - eb.setId(nodeId).setNodeId(nodeId).setDeviceType(NetworkElementDeviceType.Unknown).setIsRequired(false); - - // -- connection status - ConnectionLogStatus status = InternalConnectionStatus.statusFromNodeStatus(nNode.getConnectionStatus()); - eb.setStatus(status); - - // -- capabilites - Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode); - Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); - eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace(NetworkElement.QNAME)); - - NodeDetailsBuilder nodeDetails = new NodeDetailsBuilder() - .setAvailableCapabilities(availableCapabilities.getCapabilities()) - .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); - eb.setNodeDetails(nodeDetails.build()); - // -- host information - Host host = nNode.getHost(); - PortNumber portNumber = nNode.getPort(); - if (host != null && portNumber != null) { - eb.setHost(host.stringValue()).setPort(portNumber.getValue().longValue()); - } - - Credentials credentials = nNode.getCredentials(); - if (credentials instanceof LoginPassword) { - LoginPassword loginPassword = (LoginPassword) credentials; - eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword()); - } - return eb.build(); - } - - + @Override public void warmstart() { int problems = removeAllCurrentProblemsOfNode(); diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java deleted file mode 100644 index ef2636ca8..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -/** - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne; - -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ONFCoreNetworkElementRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author herbert - * - */ -public class ONFCoreNetworkElementEmpty implements ONFCoreNetworkElementRepresentation { - - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementEmpty.class); - - private final NetconfAccessor acessor; - private final String mountPointNodeName; - private final NodeId nodeId; - - public ONFCoreNetworkElementEmpty(NetconfAccessor acessor, String mountPointNodeName) { - LOG.info("Create {}",ONFCoreNetworkElementEmpty.class.getSimpleName()); - this.mountPointNodeName = mountPointNodeName; - this.nodeId = new NodeId(mountPointNodeName); - this.acessor = acessor; - } - - @Override - public void initialReadFromNetworkElement() { - } - - @Override - public String getMountPointNodeName() { - return mountPointNodeName; - } - - @Override - public String getMountpoint() { - return mountPointNodeName; - } - - @Override - public void resetPMIterator() { - } - - @Override - public boolean hasNext() { - return false; - } - - @Override - public void next() { - } - - @Override - public String pmStatusToString() { - return this.getClass().getSimpleName(); - } - - @Override - public int removeAllCurrentProblemsOfNode() { - return 0; - } - - @Override - public void doRegisterEventListener(MountPoint mointPoint) { - //Do nothing - } - - @Override - public void prepareCheck() { - //Do nothing here - } - - @Override - public boolean checkIfConnectionToMediatorIsOk() { - return true; - } - - @Override - public boolean checkIfConnectionToNeIsOk() { - return true; - } - - @Override - public InventoryInformationDcae getInventoryInformation() { - return InventoryInformationDcae.getDefault(); - } - - @Override - public InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { - return InventoryInformationDcae.getDefault(); - } - - @Override - public DataBroker getDataBroker() { - return null; - } - - @Override - public Optional<NetworkElement> getOptionalNetworkElement() { - return Optional.empty(); - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.Unknown; - } - - @Override - public void register() { - } - - @Override - public void deregister() { - } - - @Override - public NodeId getNodeId() { - return nodeId; - } - - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() { - } - - @Override - public Optional<NetconfAccessor> getAcessor() { - return Optional.of(acessor); - } - - @Override - public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { - return Optional.empty(); - } - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java index 44fad1b3a..5de65642b 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java @@ -54,7 +54,7 @@ public class NotificationWorker<T> implements AutoCloseable { @Override public void close() throws Exception { - // TODO Auto-generated method stub + // Auto-generated method stub } private static class Worker<T> implements Runnable { diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java deleted file mode 100644 index 4326fec32..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -/** - * @author herbert - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util; - - -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType; - -public enum InternalSeverity { - - NonAlarmed, - Warning, - Minor, - Major, - Critical; - - public boolean isNoAlarmIndication() { - return this == NonAlarmed; - } - - public String getValueAsString() { - return this.name(); - } - - @Override - public String toString() { - return this.name(); - } - - public String toNetconfString() { - switch (this) { - case NonAlarmed: - return "non-alarmed"; - case Warning: - return "warning"; - case Minor: - return "minor"; - case Major: - return "major"; - case Critical: - return "critical"; - } - return "not-specified"; - } - - public SeverityType toDataProviderSeverityType() { - switch (this) { - case NonAlarmed: - return SeverityType.NonAlarmed; - case Warning: - return SeverityType.Warning; - case Minor: - return SeverityType.Minor; - case Major: - return SeverityType.Major; - case Critical: - return SeverityType.Critical; - } - return null; //Should never happen - } - - /** - * convert ONF 1.2 Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - /** - * convert ONF 1.2.1.1 Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - /** - * convert ONF 1.2.1.1p Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - - - /** - * convert a text string into Severity - * @param severityString with textes: warning minor major critical non[-]alarmed. (Capital or lowercase) - * @return related enum. Unknown oe illegal are converted to NonAlarm - */ - public static @Nullable InternalSeverity valueOfString(String severityString) { - - switch( severityString.toLowerCase().trim() ) { - case "warning": - return InternalSeverity.Warning; - case "minor": - return InternalSeverity.Minor; - case "major": - return InternalSeverity.Major; - case "critical": - return InternalSeverity.Critical; - } - return InternalSeverity.NonAlarmed; - - } - - /** - * Convert to InternalSeverity - * @param severity to be converted - * @return InternalSeverity, null converted to NonAlarmed - */ - public static InternalSeverity valueOf(@org.eclipse.jdt.annotation.Nullable SeverityType severity) { - if (severity != null) { - switch (severity) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - } - return InternalSeverity.NonAlarmed; - } - - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java index 3fa52e110..f9e5ea688 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java @@ -23,14 +23,14 @@ import org.slf4j.LoggerFactory; public enum ONFLayerProtocolName { - MWAirInterface("MWPS"), //V1.0 + V1.2 - EthernetContainer10("ETH-CTP"), //V1.0 - EthernetContainer12("ETC"), //V1.2 + V1.2.1.1 - EthernetPhysical("ETY"), //V1.2 - TDMContainer("TDM"), //V1.2 - Structure("MWS"), //V1.0 + V1.2 - Ethernet("ETH"), //V1.2 - Unknown(""); + MWAIRINTERFACE("MWPS"), //V1.0 + V1.2 + ETHERNETCONTAINER10("ETH-CTP"), //V1.0 + ETHERNETCONTAINER12("ETC"), //V1.2 + V1.2.1.1 + ETHERNETPHYSICAL("ETY"), //V1.2 + TDMCONTAINER("TDM"), //V1.2 + STRUCTURE("MWS"), //V1.0 + V1.2 + ETHERNET("ETH"), //V1.2 + UNKNOWN(""); private static final Logger LOG = LoggerFactory.getLogger(ONFLayerProtocolName.class); @@ -51,7 +51,7 @@ public enum ONFLayerProtocolName { } } LOG.info("Can not map {}. Use Unknown",onfName.getValue() ); - return Unknown; + return UNKNOWN; } public String getValue() { diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java new file mode 100644 index 000000000..f55ef4afc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.test; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ExtendedEquipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolderBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThingBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstance; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstanceBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentTypeBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerPropertiesBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestExtendedEquipment { + + UniversalId id = new UniversalId("1234567"); + private static final String NODEID = "NODE1"; + private static final Logger LOG = LoggerFactory.getLogger(TestExtendedEquipment.class); + + @Test + public void test() { + final @NonNull List<ContainedHolder> holder = Arrays.asList(new ContainedHolderBuilder().setUuid(id).build()); + final @NonNull ManufacturerProperties manufacturerProps = new ManufacturerPropertiesBuilder() + .setManufacturerIdentifier("NOK") + .setManufacturerName("Nokia").build(); + + final @NonNull EquipmentType eqptType = new EquipmentTypeBuilder() + .setDescription("5G RAN Equipment") + .setModelIdentifier("NOK-987-1T") + .setPartTypeIdentifier("ABCDEF") + .setTypeName("12345") + .setVersion("5T9V4567") + .build(); + + final @NonNull EquipmentInstance eqptInstance = new EquipmentInstanceBuilder() + .setAssetInstanceIdentifier("NOK1234-ABCD") + .setManufactureDate("2020-02-11") + .setSerialNumber("123456ABCD").build(); + + final @NonNull ManufacturedThing manufacturedThing = new ManufacturedThingBuilder() + .setManufacturerProperties(manufacturerProps) + .setEquipmentType(eqptType) + .setEquipmentInstance(eqptInstance).build(); + + Equipment equipment = new EquipmentBuilder().setUuid(id).setContainedHolder(holder).setManufacturedThing(manufacturedThing).build(); + + ExtendedEquipment extEqpt = new ExtendedEquipment(NODEID, "1234567890", equipment, "/var/opt", 3); + assertEquals(extEqpt.getNodeId(), NODEID); + assertEquals(extEqpt.getParentUuid(), "1234567890"); + assertEquals(extEqpt.getEquipment(), equipment); + LOG.info(extEqpt.toString()); + extEqpt.getCreateInventoryInput(); + + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java new file mode 100644 index 000000000..c5107364f --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ONFCoreNetworkElement12Equipment; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.WrapperEquipmentPacRev170402; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.equipment.pac.EquipmentCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Equipment { + + NetconfAccessor netconfAccessor; + Capabilities capabilities; + NetworkElementCoreData coreData; + FaultData faultData; + TransactionUtils transactionUtils; + EquipmentCurrentProblems eqptCurrProblems; + DataBroker dataBroker; + UniversalId uid = new UniversalId("ID"); + + + @Before + public void init() throws Exception { + netconfAccessor = mock(NetconfAccessor.class); + capabilities = mock(Capabilities.class); + coreData = mock(NetworkElementCoreData.class); + faultData = mock(FaultData.class); + eqptCurrProblems = mock(EquipmentCurrentProblems.class); + dataBroker = mock(DataBroker.class); + transactionUtils = mock(TransactionUtils.class); + + final Class<EquipmentPac> clazzPac = EquipmentPac.class; + final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class; + final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class; + Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); + InstanceIdentifier<EquipmentCurrentProblems> interfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + when(netconfAccessor.getCapabilites()).thenReturn(capabilities); + when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils); + when(netconfAccessor.getDataBroker()).thenReturn(dataBroker); + when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems); + } + + @Test + public void test() { + when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true); + ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities); + onfCoreEqpt.addProblemsofNode(faultData); + onfCoreEqpt.addProblemsofNodeObject("ABCD"); + onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV")); + onfCoreEqpt.getEquipmentAll(); + onfCoreEqpt.getEquipmentData(); + onfCoreEqpt.getEquipmentPac(); + onfCoreEqpt.readNetworkElementEquipment(); + + } + + @Test + public void test1() { + when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false); + ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java new file mode 100644 index 000000000..5d14e7d26 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; + +public class TestHelper { + + @Test + public void test() { + + assertEquals(GranularityPeriodType.Period24Hours, Helper.nnGetGranularityPeriodType(GranularityPeriodType.Period24Hours)); + assertEquals(GranularityPeriodType.Unknown, Helper.nnGetGranularityPeriodType(null)); + + assertEquals(new LayerProtocolName("TDM"), Helper.nnGetLayerProtocolName(LayerProtocolName.getDefaultInstance("TDM"))); + assertEquals(new LayerProtocolName("default"), Helper.nnGetLayerProtocolName(null)); + + assertEquals("TEST", Helper.nnGetString("TEST")); + assertEquals("", Helper.nnGetString(null)); + + assertEquals(new UniversalId("ABC"), Helper.nnGetUniversalId(new UniversalId("ABC"))); + assertEquals(new UniversalId("Default"), Helper.nnGetUniversalId(null)); + + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java new file mode 100644 index 000000000..99e426adc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java @@ -0,0 +1,293 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestWrapperMicrowaveModelRev170324 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + dataBroker = mock(DataBroker.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getDataBroker()).thenReturn(dataBroker); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build(); + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + + wrapperMicrowaveModelRev170324.getLtpHistoricalPerformanceData(ONFLayerProtocolName.ETHERNET, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java new file mode 100644 index 000000000..64c857173 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java @@ -0,0 +1,290 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestWrapperMicrowaveModelRev180907 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build();; + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + + wrapperMicrowaveModelRev180907.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java new file mode 100644 index 000000000..32d9849d8 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java @@ -0,0 +1,295 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +@SuppressWarnings("deprecation") +public class TestWrapperMicrowaveModelRev181010 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + dataBroker = mock(DataBroker.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getDataBroker()).thenReturn(dataBroker); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().build(); + when(accessor.getTransactionUtils().readData(dataBroker, + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build(); + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + + wrapperMicrowaveModelRev181010.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java new file mode 100644 index 000000000..55db66a1a --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.test; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentityBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; + +import static org.mockito.Mockito.*; + +public class TestWrapperPTPModelRev170208 { + + private static final String NODEID = "node1"; + NetconfAccessor netconfAccessor; + Capabilities capabilities; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + @Before + public void init() { + netconfAccessor = mock(NetconfAccessor.class); + capabilities = mock(Capabilities.class); + dataBroker = mock(DataBroker.class); + transactionUtils = mock(TransactionUtils.class); + + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + when(netconfAccessor.getCapabilites()).thenReturn(capabilities); + when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils); + when(netconfAccessor.getDataBroker()).thenReturn(dataBroker); + + PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(10).build(); + List<PortDsList> portDsList = Arrays.asList(new PortDsListBuilder().setPortIdentity(portIdentity).build()); + InstanceList instanceList = new InstanceListBuilder().setPortDsList(portDsList).build(); + InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier + .builder(InstanceList.class, new InstanceListKey(1)).build(); + when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + PTPINSTANCES_IID)).thenReturn(instanceList); + } + + @Test + public void test() { + + when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false); + + WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor); + } + + @Test + public void test1() { + + when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true); + + WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java new file mode 100644 index 000000000..6713a7821 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.test; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.ONFCoreNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; + +public class TestONFCoreNetworkElementFactory { + + static NetconfAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + static DataBroker dataBroker; + static NodeId nNodeId; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + dataBroker = mock(DataBroker.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + //when(serviceProvider.getDataProvider()).thenReturn(dataProvider); + nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + + + } + + @Test + public void testCreateMWModelRev170324() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } + + @Test + public void testCreateMWModelRev180907() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @Test + public void testCreateMWModelRev181010() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(true); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @After + public void cleanUp() throws Exception { + + } +} + diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java new file mode 100644 index 000000000..a09d6fcfc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java @@ -0,0 +1,295 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; + +import org.eclipse.jdt.annotation.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Basic { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + Capabilities capabilities; + TransactionUtils transactionUtils; + NetworkElement optionalNe; + OnfMicrowaveModel onfMicrowaveModel; + FaultService faultService; + EquipmentService equipmentService; + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + capabilities = mock(Capabilities.class); + transactionUtils = mock(TransactionUtils.class); + onfMicrowaveModel = mock(OnfMicrowaveModel.class); + faultService = mock(FaultService.class); + equipmentService = mock(EquipmentService.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getEquipmentService()).thenReturn(equipmentService); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void test() { + optionalNe = new NetworkElement() { + + @Override + public @Nullable List<Label> getLabel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Extension> getExtension() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable OperationalState getOperationalState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable LifecycleState getLifecycleState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeState getAdministrativeState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeControl getAdministrativeControl() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Name> getName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable UniversalId getUuid() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<LocalId> getLocalId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Ltp> getLtp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Fd> getFd() { + // TODO Auto-generated method stub + return null; + } + }; + + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)).thenReturn(optionalNe); + + ONFCoreNetworkElement12Basic onfCoreNetworkElement12Basic = new ONFCoreNetworkElement12Basic(accessor, + serviceProvider); + onfCoreNetworkElement12Basic.prepareCheck(); + + /* + * EventlogEntity eventlogEntity = new EventlogEntity() { + * + * @Override public @Nullable String getId() { // TODO Auto-generated method + * stub return null; } + * + * @Override public @Nullable DateAndTime getTimestamp() { // TODO + * Auto-generated method stub return null; } + * + * @Override public @Nullable String getObjectId() { // TODO Auto-generated + * method stub return "ABCD"; } + * + * @Override public @Nullable String getNodeId() { // TODO Auto-generated method + * stub return null; } + * + * @Override public @Nullable Integer getCounter() { // TODO Auto-generated + * method stub return null; } + * + * @Override public @Nullable SourceType getSourceType() { // TODO + * Auto-generated method stub return null; } + * + * @Override public @Nullable String getNewValue() { // TODO Auto-generated + * method stub return null; } + * + * @Override public @Nullable String getAttributeName() { // TODO Auto-generated + * method stub return + * "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // + * "/equipment-pac/equipment-current-problems"; } + * + * @Override public Class<? extends DataContainer> getImplementedInterface() { + * // TODO Auto-generated method stub return null; } }; + * + * onfCoreNetworkElement12Basic.notificationActor(eventlogEntity); + */ + + } + + + @Test + public void test1() + { + when (accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = + new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, + onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + } + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java new file mode 100644 index 000000000..63b31b717 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java @@ -0,0 +1,319 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; + +import org.eclipse.jdt.annotation.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Microwave { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + Capabilities capabilities; + TransactionUtils transactionUtils; + NetworkElement optionalNe; + OnfMicrowaveModel onfMicrowaveModel; + FaultService faultService; + EquipmentService equipmentService; + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + capabilities = mock(Capabilities.class); + transactionUtils = mock(TransactionUtils.class); + onfMicrowaveModel = mock(OnfMicrowaveModel.class); + faultService = mock(FaultService.class); + equipmentService = mock(EquipmentService.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getEquipmentService()).thenReturn(equipmentService); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void test() { + optionalNe = new NetworkElement() { + + @Override + public @Nullable List<Label> getLabel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Extension> getExtension() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable OperationalState getOperationalState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable LifecycleState getLifecycleState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeState getAdministrativeState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeControl getAdministrativeControl() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Name> getName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable UniversalId getUuid() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<LocalId> getLocalId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Ltp> getLtp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Fd> getFd() { + // TODO Auto-generated method stub + return null; + } + }; + + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)).thenReturn(optionalNe); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = new ONFCoreNetworkElement12Microwave(accessor, + serviceProvider, onfMicrowaveModel); + onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + + } + + + @Test + public void test1() + { + when (accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = + new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, + onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + } + + +} diff --git a/sdnr/wt/devicemanager-oran/model/src/main/yang/devicemanager-oran.yang b/sdnr/wt/devicemanager-oran/model/src/main/yang/devicemanager-oran.yang index 231321459..6ea5836da 100644 --- a/sdnr/wt/devicemanager-oran/model/src/main/yang/devicemanager-oran.yang +++ b/sdnr/wt/devicemanager-oran/model/src/main/yang/devicemanager-oran.yang @@ -1,15 +1,37 @@ module devicemanager-oran { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-oran"; - prefix "devicemanager-oran"; - description - "DeviceManager Open RAN Api Module"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-oran"; + prefix devicemanager-oran; + + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + O-RAN: <https://wiki.o-ran-sc.org/display/OAM/Operations+and+Maintenance"; + + description + "DeviceManager Open RAN Api Module - revision "2019-11-15" { - description - "Initial revision"; - } + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. - } + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2019-11-15 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/pom.xml b/sdnr/wt/devicemanager-oran/provider/pom.xml index 7c4e628f0..cf26cc382 100644 --- a/sdnr/wt/devicemanager-oran/provider/pom.xml +++ b/sdnr/wt/devicemanager-oran/provider/pom.xml @@ -112,28 +112,6 @@ </excludes> </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generateDTOs</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>bash</executable> - <arguments> - <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument> - <argument>initfile</argument> - <argument>-f</argument> - <argument>${project.build.directory}/EsInit.script</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java index ed5fa9505..47d4c4e51 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java @@ -43,7 +43,7 @@ public class ORanChangeNotificationListener implements IetfNetconfNotifications private final NetconfAccessor netconfAccessor; private final DataProvider databaseService; - ORanChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService) { + public ORanChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService) { this.netconfAccessor = netconfAccessor; this.databaseService = databaseService; } diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java new file mode 100644 index 000000000..7e8327a09 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java @@ -0,0 +1,23 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; +import java.lang.String; +import java.lang.UnsupportedOperationException; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class OperatorStateBuilder { + private OperatorStateBuilder() { + //Exists only to defeat instantiation. + } + + public static OperatorState getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java new file mode 100644 index 000000000..7c4a63d2b --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java @@ -0,0 +1,23 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; +import java.lang.String; +import java.lang.UnsupportedOperationException; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class ResourceBuilder { + private ResourceBuilder() { + //Exists only to defeat instantiation. + } + + public static Resource getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java new file mode 100644 index 000000000..282a6a26d --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java @@ -0,0 +1,23 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; +import java.lang.String; +import java.lang.UnsupportedOperationException; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class ResourceMatchBuilder { + private ResourceMatchBuilder() { + //Exists only to defeat instantiation. + } + + public static ResourceMatch getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java new file mode 100644 index 000000000..81391922d --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java @@ -0,0 +1,23 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; +import java.lang.String; +import java.lang.UnsupportedOperationException; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class SeverityWithClearBuilder { + private SeverityWithClearBuilder() { + //Exists only to defeat instantiation. + } + + public static SeverityWithClear getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java new file mode 100644 index 000000000..9f10ae87f --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java @@ -0,0 +1,23 @@ +package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911.alarms; +import java.lang.String; +import java.lang.UnsupportedOperationException; + +/** + * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation. + * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32). + * + * The reason behind putting it under src/main/java is: + * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent + * loss of user code. + * + */ +public class ControlMaxAlarmStatusChangesBuilder { + private ControlMaxAlarmStatusChangesBuilder() { + //Exists only to defeat instantiation. + } + + public static Control.MaxAlarmStatusChanges getDefaultInstance(String defaultValue) { + throw new UnsupportedOperationException("Not yet implemented"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/ietf-alarms@2019-09-11.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/ietf-alarms@2019-09-11.yang new file mode 100644 index 000000000..a6f51bb81 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/ietf-alarms@2019-09-11.yang @@ -0,0 +1,1530 @@ +module ietf-alarms { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:ietf-alarms"; + prefix al; + + import ietf-yang-types { + prefix yang; + reference + "RFC 6991: Common YANG Data Types."; + } + + organization + "IETF CCAMP Working Group"; + contact + "WG Web: <https://trac.ietf.org/trac/ccamp> + WG List: <mailto:ccamp@ietf.org> + + Editor: Stefan Vallin + <mailto:stefan@wallan.se> + + Editor: Martin Bjorklund + <mailto:mbj@tail-f.com>"; + description + "This module defines an interface for managing alarms. Main + inputs to the module design are the 3GPP Alarm Integration + Reference Point (IRP), ITU-T X.733, and ANSI/ISA-18.2 alarm + standards. + + Main features of this module include: + + * Alarm list: + A list of all alarms. Cleared alarms stay in + the list until explicitly purged. + + * Operator actions on alarms: + Acknowledging and closing alarms. + + * Administrative actions on alarms: + Purging alarms from the list according to specific + criteria. + + * Alarm inventory: + A management application can read all + alarm types implemented by the system. + + * Alarm shelving: + Shelving (blocking) alarms according + to specific criteria. + + * Alarm profiles: + A management system can attach further + information to alarm types, for example, + overriding system-default severity + levels. + + This module uses a stateful view on alarms. An alarm is a state + for a specific resource (note that an alarm is not a + notification). An alarm type is a possible alarm state for a + resource. For example, the tuple: + + ('link-alarm', 'GigabitEthernet0/25') + + is an alarm of type 'link-alarm' on the resource + 'GigabitEthernet0/25'. + + Alarm types are identified using YANG identities and an optional + string-based qualifier. The string-based qualifier allows for + dynamic extension of the statically defined alarm types. Alarm + types identify a possible alarm state and not the individual + notifications. For example, the traditional 'link-down' and + 'link-up' notifications are two notifications referring to the + same alarm type 'link-alarm'. + + With this design, there is no ambiguity about how alarm and + alarm clear correlation should be performed; notifications that + report the same resource and alarm type are considered updates + + of the same alarm, e.g., clearing an active alarm or changing + the severity of an alarm. The instrumentation can update the + severity and alarm text on an existing alarm. The above alarm + example can therefore look like the following: + + (('link-alarm', 'GigabitEthernet0/25'), + warning, + 'interface down while interface admin state is up') + + There is a clear separation between updates on the alarm from + the underlying resource, like clear, and updates from an + operator, like acknowledging or closing an alarm: + + (('link-alarm', 'GigabitEthernet0/25'), + warning, + 'interface down while interface admin state is up', + cleared, + closed) + + Administrative actions like removing closed alarms older than a + given time is supported. + + This YANG module does not define how the underlying + instrumentation detects and clears the specific alarms. That + belongs to the Standards Development Organization (SDO) or + enterprise that owns that specific technology. + + The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL + NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED', + 'MAY', and 'OPTIONAL' in this document are to be interpreted as + described in BCP 14 (RFC 2119) (RFC 8174) when, and only when, + they appear in all capitals, as shown here. + + Copyright (c) 2019 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject to + the license terms contained in, the Simplified BSD License set + forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (https://trustee.ietf.org/license-info). + + This version of this YANG module is part of RFC 8632; see + the RFC itself for full legal notices."; + + revision 2019-09-11 { + description + "Initial revision."; + reference + "RFC 8632: A YANG Data Model for Alarm Management"; + } + + /* + * Features + */ + + feature operator-actions { + description + "This feature indicates that the system supports operator + states on alarms."; + } + + feature alarm-shelving { + description + "This feature indicates that the system supports shelving + (blocking) alarms. + + Alarm shelving may have an impact on server processing + resources in order to match alarms against shelf + criteria."; + } + + feature alarm-history { + description + "This feature indicates that the server maintains a history + of state changes for each alarm. For example, if an alarm + toggles between cleared and active 10 times, these state + changes are present in a separate list in the alarm. + + Keeping the alarm history may have an impact on server + memory resources."; + } + + feature alarm-summary { + description + "This feature indicates that the server summarizes the number + of alarms per severity and operator state."; + } + + feature alarm-profile { + description + "The system enables clients to configure further information + to each alarm type."; + } + + feature severity-assignment { + description + "The system supports configurable alarm severity levels."; + reference + "ITU-T Recommendation M.3100: + Generic network information model + ITU-T Recommendation M.3160: + Generic, protocol-neutral management information model"; + } + + feature root-cause-analysis { + description + "The system supports identifying candidate root-cause + resources for an alarm, for example, a disk partition + root cause for a logger failure alarm."; + } + + feature service-impact-analysis { + description + "The system supports identifying candidate-impacted + resources for an alarm, for example, an interface state change + resulting in a link alarm, which can refer to a link as being + impacted."; + } + + feature alarm-correlation { + description + "The system supports correlating/grouping alarms + that belong together."; + } + + /* + * Identities + */ + + identity alarm-type-id { + description + "Base identity for alarm types. A unique identification of + the alarm, not including the resource. Different resources + can share alarm types. If the resource reports the same + alarm type, it is considered to be the same alarm. The alarm + type is a simplification of the different X.733 and 3GPP Alarm + IRP correlation mechanisms, and it allows for + hierarchical extensions. + + A string-based qualifier can be used in addition to the + identity in order to have different alarm types based on + information not known at design time, such as values in + + textual SNMP Notification varbinds. + + Standards and vendors can define sub-identities to clearly + identify specific alarm types. + + This identity is abstract and MUST NOT be used for alarms."; + } + + /* + * Common types + */ + + typedef resource { + type union { + type instance-identifier { + require-instance false; + } + type yang:object-identifier; + type string; + type yang:uuid; + } + description + "This is an identification of the alarming resource, such as an + interface. It should be as fine-grained as possible to both + guide the operator and guarantee uniqueness of the alarms. + + If the alarming resource is modeled in YANG, this type will + be an instance-identifier. + + If the resource is an SNMP object, the type will be an + 'object-identifier'. + + If the resource is anything else, for example, a distinguished + name or a Common Information Model (CIM) path, this type will + be a string. + + If the alarming object is identified by a Universally Unique + Identifier (UUID), use the uuid type. Be cautious when using + this type, since a UUID is hard to use for an operator. + + If the server supports several models, the precedence should + be in the order as given in the union definition."; + } + + typedef resource-match { + type union { + type yang:xpath1.0; + type yang:object-identifier; + type string; + } + description + "This type is used to match resources of type 'resource'. + Since the type 'resource' is a union of different types, the + 'resource-match' type is also a union of corresponding types. + + If the type is given as an XPath 1.0 expression, a resource + of type 'instance-identifier' matches if the instance is part + of the node set that is the result of evaluating the XPath 1.0 + expression. For example, the XPath 1.0 expression: + + /ietf-interfaces:interfaces/ietf-interfaces:interface + [ietf-interfaces:type='ianaift:ethernetCsmacd'] + + would match the resource instance-identifier: + + /if:interfaces/if:interface[if:name='eth1'], + + assuming that the interface 'eth1' is of type + 'ianaift:ethernetCsmacd'. + + If the type is given as an object identifier, a resource of + type 'object-identifier' matches if the match object + identifier is a prefix of the resource's object identifier. + For example, the value: + + 1.3.6.1.2.1.2.2 + + would match the resource object identifier: + + 1.3.6.1.2.1.2.2.1.1.5 + + If the type is given as an UUID or a string, it is interpreted + as an XML Schema regular expression, which matches a resource + of type 'yang:uuid' or 'string' if the given regular + expression matches the resource string. + + If the type is given as an XPath expression, it is evaluated + in the following XPath context: + + o The set of namespace declarations is the set of prefix + and namespace pairs for all YANG modules implemented by + the server, where the prefix is the YANG module name and + the namespace is as defined by the 'namespace' statement + in the YANG module. + + If a leaf of this type is encoded in XML, all namespace + + declarations in scope on the leaf element are added to + the set of namespace declarations. If a prefix found in + the XML is already present in the set of namespace + declarations, the namespace in the XML is used. + + o The set of variable bindings is empty. + + o The function library is the core function library, and + the functions are defined in Section 10 of RFC 7950. + + o The context node is the root node in the data tree."; + reference + "XML Schema Part 2: Datatypes Second Edition, + World Wide Web Consortium Recommendation + REC-xmlschema-2-20041028"; + } + + typedef alarm-text { + type string; + description + "The string used to inform operators about the alarm. This + MUST contain enough information for an operator to be able to + understand the problem and how to resolve it. If this string + contains structure, this format should be clearly documented + for programs to be able to parse that information."; + } + + typedef severity { + type enumeration { + enum indeterminate { + value 2; + description + "Indicates that the severity level could not be + determined. This level SHOULD be avoided."; + } + enum warning { + value 3; + description + "The 'warning' severity level indicates the detection of a + potential or impending service-affecting fault, before any + significant effects have been felt. Action should be + taken to further diagnose (if necessary) and correct the + problem in order to prevent it from becoming a more + serious service-affecting fault."; + } + enum minor { + value 4; + description + "The 'minor' severity level indicates the existence of a + non-service-affecting fault condition and that corrective + action should be taken in order to prevent a more serious + (for example, service-affecting) fault. Such a severity + can be reported, for example, when the detected alarm + condition is not currently degrading the capacity of the + resource."; + } + enum major { + value 5; + description + "The 'major' severity level indicates that a service- + affecting condition has developed and an urgent corrective + action is required. Such a severity can be reported, for + example, when there is a severe degradation in the + capability of the resource and its full capability must be + restored."; + } + enum critical { + value 6; + description + "The 'critical' severity level indicates that a service- + affecting condition has occurred and an immediate + corrective action is required. Such a severity can be + reported, for example, when a resource becomes totally out + of service and its capability must be restored."; + } + } + description + "The severity level of the alarm. Note well that the value + 'clear' is not included. Whether or not an alarm is cleared + is a separate boolean flag."; + reference + "ITU-T Recommendation X.733: Information Technology + - Open Systems Interconnection + - System Management: Alarm Reporting Function"; + } + + typedef severity-with-clear { + type union { + type enumeration { + enum cleared { + value 1; + description + "The alarm is cleared by the instrumentation."; + } + } + type severity; + } + description + "The severity level of the alarm including clear. This is used + only in notifications reporting state changes for an alarm."; + } + + typedef writable-operator-state { + type enumeration { + enum none { + value 1; + description + "The alarm is not being taken care of."; + } + enum ack { + value 2; + description + "The alarm is being taken care of. Corrective action not + taken yet or has failed"; + } + enum closed { + value 3; + description + "Corrective action taken successfully."; + } + } + description + "Operator states on an alarm. The 'closed' state indicates + that an operator considers the alarm being resolved. This is + separate from the alarm's 'is-cleared' leaf."; + } + + typedef operator-state { + type union { + type writable-operator-state; + type enumeration { + enum shelved { + value 4; + description + "The alarm is shelved. Alarms in /alarms/shelved-alarms/ + MUST be assigned this operator state by the server as + the last entry in the 'operator-state-change' list. The + text for that entry SHOULD include the shelf name."; + } + enum un-shelved { + value 5; + description + "The alarm is moved back to 'alarm-list' from a shelf. + Alarms that are moved from /alarms/shelved-alarms/ to + /alarms/alarm-list MUST be assigned this state by the + server as the last entry in the 'operator-state-change' + list. The text for that entry SHOULD include the shelf + name."; + } + } + } + description + "Operator states on an alarm. The 'closed' state indicates + that an operator considers the alarm being resolved. This is + separate from the alarm's 'is-cleared' leaf."; + } + + /* Alarm type */ + + typedef alarm-type-id { + type identityref { + base alarm-type-id; + } + description + "Identifies an alarm type. The description of the alarm type + id MUST indicate whether or not the alarm type is abstract. + An abstract alarm type is used as a base for other alarm type + ids and will not be used as a value for an alarm or be present + in the alarm inventory."; + } + + typedef alarm-type-qualifier { + type string; + description + "If an alarm type cannot be fully specified at design time by + 'alarm-type-id', this string qualifier is used in addition to + fully define a unique alarm type. + + The definition of alarm qualifiers is considered to be part of + the instrumentation and is out of scope for this module. An + empty string is used when this is part of a key."; + } + + /* + * Groupings + */ + + grouping common-alarm-parameters { + description + "Common parameters for an alarm. + + This grouping is used both in the alarm list and in the + notification representing an alarm-state change."; + leaf resource { + type resource; + mandatory true; + description + "The alarming resource. See also 'alt-resource'. This could + be, for example, a reference to the alarming interface"; + } + leaf alarm-type-id { + type alarm-type-id; + mandatory true; + description + "This leaf and the leaf 'alarm-type-qualifier' together + provide a unique identification of the alarm type."; + } + leaf alarm-type-qualifier { + type alarm-type-qualifier; + description + "This leaf is used when the 'alarm-type-id' leaf cannot + uniquely identify the alarm type. Normally, this is not the + case, and this leaf is the empty string."; + } + leaf-list alt-resource { + type resource; + description + "Used if the alarming resource is available over other + interfaces. This field can contain SNMP OIDs, CIM paths, or + 3GPP distinguished names, for example."; + } + list related-alarm { + if-feature "alarm-correlation"; + key "resource alarm-type-id alarm-type-qualifier"; + description + "References to related alarms. Note that the related alarm + might have been purged from the alarm list."; + leaf resource { + type leafref { + path "/alarms/alarm-list/alarm/resource"; + require-instance false; + } + description + "The alarming resource for the related alarm."; + } + leaf alarm-type-id { + type leafref { + path "/alarms/alarm-list/alarm" + + "[resource=current()/../resource]" + + "/alarm-type-id"; + require-instance false; + } + description + "The alarm type identifier for the related alarm."; + } + leaf alarm-type-qualifier { + type leafref { + path "/alarms/alarm-list/alarm" + + "[resource=current()/../resource]" + + "[alarm-type-id=current()/../alarm-type-id]" + + "/alarm-type-qualifier"; + require-instance false; + } + description + "The alarm qualifier for the related alarm."; + } + } + leaf-list impacted-resource { + if-feature "service-impact-analysis"; + type resource; + description + "Resources that might be affected by this alarm. If the + system creates an alarm on a resource and also has a mapping + to other resources that might be impacted, these resources + can be listed in this leaf-list. In this way, the system + can create one alarm instead of several. For example, if an + interface has an alarm, the 'impacted-resource' can + reference the aggregated port channels."; + } + leaf-list root-cause-resource { + if-feature "root-cause-analysis"; + type resource; + description + "Resources that are candidates for causing the alarm. If the + system has a mechanism to understand the candidate root + causes of an alarm, this leaf-list can be used to list the + root-cause candidate resources. In this way, the system can + create one alarm instead of several. An example might be a + logging system (alarm resource) that fails; the alarm can + reference the file system in the 'root-cause-resource' + leaf-list. Note that the intended use is not to also send + an alarm with the 'root-cause-resource' as an alarming + resource. The 'root-cause-resource' leaf-list is a hint and + should not also generate an alarm for the same problem."; + } + } + + grouping alarm-state-change-parameters { + description + "Parameters for an alarm-state change. + + This grouping is used both in the alarm list's status-change + list and in the notification representing an alarm-state + change."; + leaf time { + type yang:date-and-time; + mandatory true; + description + "The time the status of the alarm changed. The value + represents the time the real alarm-state change appeared in + the resource and not when it was added to the alarm + list. The /alarm-list/alarm/last-changed MUST be set to the + same value."; + } + leaf perceived-severity { + type severity-with-clear; + mandatory true; + description + "The severity of the alarm as defined by X.733. Note that + this may not be the original severity since the alarm may + have changed severity."; + reference + "ITU-T Recommendation X.733: Information Technology + - Open Systems Interconnection + - System Management: Alarm Reporting Function"; + } + leaf alarm-text { + type alarm-text; + mandatory true; + description + "A user-friendly text describing the alarm-state change."; + reference + "ITU-T Recommendation X.733: Information Technology + - Open Systems Interconnection + - System Management: Alarm Reporting Function"; + } + } + + grouping operator-parameters { + description + "This grouping defines parameters that can be changed by an + operator."; + leaf time { + type yang:date-and-time; + mandatory true; + description + "Timestamp for operator action on the alarm."; + } + leaf operator { + type string; + mandatory true; + description + "The name of the operator that has acted on this alarm."; + } + leaf state { + type operator-state; + mandatory true; + description + "The operator's view of the alarm state."; + } + leaf text { + type string; + description + "Additional optional textual information provided by the + operator."; + } + } + + grouping resource-alarm-parameters { + description + "Alarm parameters that originate from the resource view."; + leaf is-cleared { + type boolean; + mandatory true; + description + "Indicates the current clearance state of the alarm. An + alarm might toggle from active alarm to cleared alarm and + back to active again."; + } + leaf last-raised { + type yang:date-and-time; + mandatory true; + description + "An alarm may change severity level and toggle between + active and cleared during its lifetime. This leaf indicates + the last time it was raised ('is-cleared' = 'false')."; + } + leaf last-changed { + type yang:date-and-time; + mandatory true; + description + "A timestamp when the 'status-change' or + 'operator-state-change' list was last changed."; + } + leaf perceived-severity { + type severity; + mandatory true; + description + "The last severity of the alarm. + + If an alarm was raised with severity 'warning' but later + changed to 'major', this leaf will show 'major'."; + } + leaf alarm-text { + type alarm-text; + mandatory true; + description + "The last reported alarm text. This text should contain + information for an operator to be able to understand the + problem and how to resolve it."; + } + list status-change { + if-feature "alarm-history"; + key "time"; + min-elements 1; + description + "A list of status-change events for this alarm. + + The entry with latest timestamp in this list MUST + correspond to the leafs 'is-cleared', 'perceived-severity', + and 'alarm-text' for the alarm. + + This list is ordered according to the timestamps of alarm + state changes. The first item corresponds to the latest + state change. + + The following state changes create an entry in this + list: + - changed severity (warning, minor, major, critical) + - clearance status; this also updates the 'is-cleared' + leaf + - alarm-text update"; + uses alarm-state-change-parameters; + } + } + + grouping filter-input { + description + "Grouping to specify a filter construct on alarm information."; + leaf alarm-clearance-status { + type enumeration { + enum any { + description + "Ignore alarm-clearance status."; + } + enum cleared { + description + "Filter cleared alarms."; + } + enum not-cleared { + description + "Filter not-cleared alarms."; + } + } + mandatory true; + description + "The clearance status of the alarm."; + } + container older-than { + presence "Age specification"; + description + "Matches the 'last-status-change' leaf in the alarm."; + choice age-spec { + description + "Filter using date and time age."; + case seconds { + leaf seconds { + type uint16; + description + "Age expressed in seconds."; + } + } + case minutes { + leaf minutes { + type uint16; + description + "Age expressed in minutes."; + } + } + case hours { + leaf hours { + type uint16; + description + "Age expressed in hours."; + } + } + case days { + leaf days { + type uint16; + description + "Age expressed in days."; + } + } + case weeks { + leaf weeks { + type uint16; + description + "Age expressed in weeks."; + } + } + } + } + container severity { + presence "Severity filter"; + choice sev-spec { + description + "Filter based on severity level."; + leaf below { + type severity; + description + "Severity less than this leaf."; + } + leaf is { + type severity; + description + "Severity level equal to this leaf."; + } + leaf above { + type severity; + description + "Severity level higher than this leaf."; + } + } + description + "Filter based on severity."; + } + container operator-state-filter { + if-feature "operator-actions"; + presence "Operator state filter"; + leaf state { + type operator-state; + description + "Filter on operator state."; + } + leaf user { + type string; + description + "Filter based on which operator."; + } + description + "Filter based on operator state."; + } + } + + /* + * The /alarms data tree + */ + + container alarms { + description + "The top container for this module."; + container control { + description + "Configuration to control the alarm behavior."; + leaf max-alarm-status-changes { + type union { + type uint16; + type enumeration { + enum infinite { + description + "The status-change entries are accumulated + infinitely."; + } + } + } + default "32"; + description + "The 'status-change' entries are kept in a circular list + per alarm. When this number is exceeded, the oldest + status change entry is automatically removed. If the + value is 'infinite', the status-change entries are + accumulated infinitely."; + } + leaf notify-status-changes { + type enumeration { + enum all-state-changes { + description + "Send notifications for all status changes."; + } + enum raise-and-clear { + description + "Send notifications only for raise, clear, and + re-raise. Notifications for severity-level changes or + alarm-text changes are not sent."; + } + enum severity-level { + description + "Only send notifications for alarm-state changes + crossing the level specified in + 'notify-severity-level'. Always send clear + notifications."; + } + } + must '. != "severity-level" or ../notify-severity-level' { + description + "When notify-status-changes is 'severity-level', a value + must be given for 'notify-severity-level'."; + } + default "all-state-changes"; + description + "This leaf controls the notifications sent for alarm status + updates. There are three options: + + 1. Notifications are sent for all updates, severity-level + changes, and alarm-text changes. + + 2. Notifications are only sent for alarm raise and clear. + + 3. Notifications are sent for status changes equal to or + above the specified severity level. Clear + notifications shall always be sent. Notifications + shall also be sent for state changes that make an + alarm less severe than the specified level. + + For example, in option 3, assume that the severity level + is set to major and that the alarm has the following state + changes: + + [(Time, severity, clear)]: + [(T1, major, -), (T2, minor, -), (T3, warning, -), + (T4, minor, -), (T5, major, -), (T6, critical, -), + (T7, major. -), (T8, major, clear)] + + In that case, notifications will be sent at times + T1, T2, T5, T6, T7, and T8."; + } + leaf notify-severity-level { + when '../notify-status-changes = "severity-level"'; + type severity; + description + "Only send notifications for alarm-state changes crossing + the specified level. Always send clear notifications."; + } + container alarm-shelving { + if-feature "alarm-shelving"; + description + "The 'alarm-shelving/shelf' list is used to shelve + (block/filter) alarms. The conditions in the shelf + criteria are logically ANDed. The first matching shelf is + used, and an alarm is shelved only for this first match. + Matching alarms MUST appear in the + /alarms/shelved-alarms/shelved-alarm list, and + non-matching /alarms MUST appear in the + /alarms/alarm-list/alarm list. The server does not send + any notifications for shelved alarms. + + The server MUST maintain states (e.g., severity + changes) for the shelved alarms. + + Alarms that match the criteria shall have an + operator state 'shelved'. When the shelf + configuration removes an alarm from the shelf, the server + shall add the operator state 'un-shelved'."; + list shelf { + key "name"; + ordered-by user; + leaf name { + type string; + description + "An arbitrary name for the alarm shelf."; + } + description + "Each entry defines the criteria for shelving alarms. + Criteria are ANDed. If no criteria are specified, + all alarms will be shelved."; + leaf-list resource { + type resource-match; + description + "Shelve alarms for matching resources."; + } + list alarm-type { + key "alarm-type-id alarm-type-qualifier-match"; + description + "Any alarm matching the combined criteria of + 'alarm-type-id' and 'alarm-type-qualifier-match' + MUST be matched."; + leaf alarm-type-id { + type alarm-type-id; + description + "Shelve all alarms that have an 'alarm-type-id' that + is equal to or derived from the given + 'alarm-type-id'."; + } + leaf alarm-type-qualifier-match { + type string; + description + "An XML Schema regular expression that is used to + match an alarm type qualifier. Shelve all alarms + that match this regular expression for the alarm + type qualifier."; + reference + "XML Schema Part 2: Datatypes Second Edition, + World Wide Web Consortium Recommendation + REC-xmlschema-2-20041028"; + } + } + leaf description { + type string; + description + "An optional textual description of the shelf. This + description should include the reason for shelving + these alarms."; + } + } + } + } + container alarm-inventory { + config false; + description + "The 'alarm-inventory/alarm-type' list contains all possible + alarm types for the system. + + If the system knows for which resources a specific alarm + type can appear, it is also identified in the inventory. + The list also tells if each alarm type has a corresponding + clear state. The inventory shall only contain concrete + alarm types. + + The alarm inventory MUST be updated by the system when new + alarms can appear. This can be the case when installing new + software modules or inserting new card types. A + notification 'alarm-inventory-changed' is sent when the + inventory is changed."; + list alarm-type { + key "alarm-type-id alarm-type-qualifier"; + description + "An entry in this list defines a possible alarm."; + leaf alarm-type-id { + type alarm-type-id; + description + "The statically defined alarm type identifier for this + possible alarm."; + } + leaf alarm-type-qualifier { + type alarm-type-qualifier; + description + "The optionally dynamically defined alarm type identifier + for this possible alarm."; + } + leaf-list resource { + type resource-match; + description + "Optionally, specifies for which resources the alarm type + is valid."; + } + leaf will-clear { + type boolean; + mandatory true; + description + "This leaf tells the operator if the alarm will be + cleared when the correct corrective action has been + taken. Implementations SHOULD strive for detecting the + cleared state for all alarm types. + + If this leaf is 'true', the operator can monitor the + alarm until it becomes cleared after the corrective + action has been taken. + + If this leaf is 'false', the operator needs to validate + that the alarm is no longer active using other + mechanisms. Alarms can lack a corresponding clear due + to missing instrumentation or no logical + corresponding clear state."; + } + leaf-list severity-level { + type severity; + description + "This leaf-list indicates the possible severity levels of + this alarm type. Note well that 'clear' is not part of + the severity type. In general, the severity level + should be defined by the instrumentation based on the + dynamic state, rather than being defined statically by + the alarm type, in order to provide a relevant severity + level based on dynamic state and context. However, most + alarm types have a defined set of possible severity + levels, and this should be provided here."; + } + leaf description { + type string; + mandatory true; + description + "A description of the possible alarm. It SHOULD include + information on possible underlying root causes and + corrective actions."; + } + } + } + container summary { + if-feature "alarm-summary"; + config false; + description + "This container gives a summary of the number of alarms."; + list alarm-summary { + key "severity"; + description + "A global summary of all alarms in the system. The summary + does not include shelved alarms."; + leaf severity { + type severity; + description + "Alarm summary for this severity level."; + } + leaf total { + type yang:gauge32; + description + "Total number of alarms of this severity level."; + } + leaf not-cleared { + type yang:gauge32; + description + "Total number of alarms of this severity level + that are not cleared."; + } + leaf cleared { + type yang:gauge32; + description + "For this severity level, the number of alarms that are + cleared."; + } + leaf cleared-not-closed { + if-feature "operator-actions"; + type yang:gauge32; + description + "For this severity level, the number of alarms that are + cleared but not closed."; + } + leaf cleared-closed { + if-feature "operator-actions"; + type yang:gauge32; + description + "For this severity level, the number of alarms that are + cleared and closed."; + } + leaf not-cleared-closed { + if-feature "operator-actions"; + type yang:gauge32; + description + "For this severity level, the number of alarms that are + not cleared but closed."; + } + leaf not-cleared-not-closed { + if-feature "operator-actions"; + type yang:gauge32; + description + "For this severity level, the number of alarms that are + not cleared and not closed."; + } + } + leaf shelves-active { + if-feature "alarm-shelving"; + type empty; + description + "This is a hint to the operator that there are active + alarm shelves. This leaf MUST exist if the + /alarms/shelved-alarms/number-of-shelved-alarms is > 0."; + } + } + container alarm-list { + config false; + description + "The alarms in the system."; + leaf number-of-alarms { + type yang:gauge32; + description + "This object shows the total number of + alarms in the system, i.e., the total number + of entries in the alarm list."; + } + leaf last-changed { + type yang:date-and-time; + description + "A timestamp when the alarm list was last + changed. The value can be used by a manager to + initiate an alarm resynchronization procedure."; + } + list alarm { + key "resource alarm-type-id alarm-type-qualifier"; + description + "The list of alarms. Each entry in the list holds one + alarm for a given alarm type and resource. An alarm can + be updated from the underlying resource or by the user. + The following leafs are maintained by the resource: + 'is-cleared', 'last-change', 'perceived-severity', and + 'alarm-text'. An operator can change 'operator-state' and + 'operator-text'. + + Entries appear in the alarm list the first time an alarm + becomes active for a given alarm type and resource. + Entries do not get deleted when the alarm is cleared. + Clear status is represented as a boolean flag. + + Alarm entries are removed, i.e., purged, from the list by + an explicit purge action. For example, purge all alarms + that are cleared and in closed operator state that are + older than 24 hours. Purged alarms are removed from the + alarm list. If the alarm resource state changes after a + purge, the alarm will reappear in the alarm list. + + Systems may also remove alarms based on locally configured + policies; this is out of scope for this module."; + uses common-alarm-parameters; + leaf time-created { + type yang:date-and-time; + mandatory true; + description + "The timestamp when this alarm entry was created. This + represents the first time the alarm appeared; it can + also represent that the alarm reappeared after a purge. + Further state changes of the same alarm do not change + this leaf; these changes will update the 'last-changed' + leaf."; + } + uses resource-alarm-parameters; + list operator-state-change { + if-feature "operator-actions"; + key "time"; + description + "This list is used by operators to indicate the state of + human intervention on an alarm. For example, if an + operator has seen an alarm, the operator can add a new + item to this list indicating that the alarm is + acknowledged."; + uses operator-parameters; + } + action set-operator-state { + if-feature "operator-actions"; + description + "This is a means for the operator to indicate the level + of human intervention on an alarm."; + input { + leaf state { + type writable-operator-state; + mandatory true; + description + "Set this operator state."; + } + leaf text { + type string; + description + "Additional optional textual information."; + } + } + } + notification operator-action { + if-feature "operator-actions"; + description + "This notification is used to report that an operator + acted upon an alarm."; + uses operator-parameters; + } + } + action purge-alarms { + description + "This operation requests that the server delete entries + from the alarm list according to the supplied criteria. + + Typically, this operation is used to delete alarms that + are in closed operator state and older than a specified + time. + + The number of purged alarms is returned as an output + parameter."; + input { + uses filter-input; + } + output { + leaf purged-alarms { + type uint32; + description + "Number of purged alarms."; + } + } + } + action compress-alarms { + if-feature "alarm-history"; + description + "This operation requests that the server compress + entries in the alarm list by removing all but the + latest 'status-change' entry for all matching alarms. + Conditions in the input are logically ANDed. If no + input condition is given, all alarms are compressed."; + input { + leaf resource { + type resource-match; + description + "Compress the alarms matching this resource."; + } + leaf alarm-type-id { + type leafref { + path "/alarms/alarm-list/alarm/alarm-type-id"; + require-instance false; + } + description + "Compress alarms with this 'alarm-type-id'."; + } + leaf alarm-type-qualifier { + type leafref { + path "/alarms/alarm-list/alarm/alarm-type-qualifier"; + require-instance false; + } + description + "Compress the alarms with this + 'alarm-type-qualifier'."; + } + } + output { + leaf compressed-alarms { + type uint32; + description + "Number of compressed alarm entries."; + } + } + } + } + container shelved-alarms { + if-feature "alarm-shelving"; + config false; + description + "The shelved alarms. Alarms appear here if they match the + criteria in /alarms/control/alarm-shelving. This list does + not generate any notifications. The list represents alarms + that are considered not relevant by the operator. Alarms in + this list have an 'operator-state' of 'shelved'. This + cannot be changed."; + leaf number-of-shelved-alarms { + type yang:gauge32; + description + "This object shows the total number of current + alarms, i.e., the total number of entries + in the alarm list."; + } + leaf shelved-alarms-last-changed { + type yang:date-and-time; + description + "A timestamp when the shelved-alarm list was last changed. + The value can be used by a manager to initiate an alarm + resynchronization procedure."; + } + list shelved-alarm { + key "resource alarm-type-id alarm-type-qualifier"; + description + "The list of shelved alarms. Shelved alarms can only be + updated from the underlying resource; no operator actions + are supported."; + uses common-alarm-parameters; + leaf shelf-name { + type leafref { + path "/alarms/control/alarm-shelving/shelf/name"; + require-instance false; + } + description + "The name of the shelf."; + } + uses resource-alarm-parameters; + list operator-state-change { + if-feature "operator-actions"; + key "time"; + description + "This list is used by operators to indicate the state of + human intervention on an alarm. For shelved alarms, the + system has set the list item in the list to 'shelved'."; + uses operator-parameters; + } + } + action purge-shelved-alarms { + description + "This operation requests that the server delete entries from + the shelved-alarm list according to the supplied criteria. + In the shelved-alarm list, it makes sense to delete alarms + that are not relevant anymore. + + The number of purged alarms is returned as an output + parameter."; + input { + uses filter-input; + } + output { + leaf purged-alarms { + type uint32; + description + "Number of purged alarms."; + } + } + } + action compress-shelved-alarms { + if-feature "alarm-history"; + description + "This operation requests that the server compress entries + in the shelved-alarm list by removing all but the latest + 'status-change' entry for all matching shelved alarms. + Conditions in the input are logically ANDed. If no input + condition is given, all alarms are compressed."; + input { + leaf resource { + type leafref { + path "/alarms/shelved-alarms/shelved-alarm/resource"; + require-instance false; + } + description + "Compress the alarms with this resource."; + } + leaf alarm-type-id { + type leafref { + path "/alarms/shelved-alarms/shelved-alarm" + + "/alarm-type-id"; + require-instance false; + } + description + "Compress alarms with this 'alarm-type-id'."; + } + leaf alarm-type-qualifier { + type leafref { + path "/alarms/shelved-alarms/shelved-alarm" + + "/alarm-type-qualifier"; + require-instance false; + } + description + "Compress the alarms with this + 'alarm-type-qualifier'."; + } + } + output { + leaf compressed-alarms { + type uint32; + description + "Number of compressed alarm entries."; + } + } + } + } + list alarm-profile { + if-feature "alarm-profile"; + key "alarm-type-id alarm-type-qualifier-match resource"; + ordered-by user; + description + "This list is used to assign further information or + configuration for each alarm type. This module supports a + mechanism where the client can override the system-default + alarm severity levels. The 'alarm-profile' is also a useful + augmentation point for specific additions to alarm types."; + leaf alarm-type-id { + type alarm-type-id; + description + "The alarm type identifier to match."; + } + leaf alarm-type-qualifier-match { + type string; + description + "An XML Schema regular expression that is used to match the + alarm type qualifier."; + reference + "XML Schema Part 2: Datatypes Second Edition, + World Wide Web Consortium Recommendation + REC-xmlschema-2-20041028"; + } + leaf resource { + type resource-match; + description + "Specifies which resources to match."; + } + leaf description { + type string; + mandatory true; + description + "A description of the alarm profile."; + } + container alarm-severity-assignment-profile { + if-feature "severity-assignment"; + description + "The client can override the system-default severity + level."; + reference + "ITU-T Recommendation M.3100: + Generic network information model + ITU-T Recommendation M.3160: + Generic, protocol-neutral management information model"; + leaf-list severity-level { + type severity; + ordered-by user; + description + "Specifies the configured severity level(s) for the + matching alarm. If the alarm has several severity + levels, the leaf-list shall be given in rising severity + order. The original M3100/M3160 ASAP function only + allows for a one-to-one mapping between alarm type and + severity, but since YANG module supports stateful + alarms, the mapping must allow for several severity + levels. + + Assume a high-utilization alarm type with two thresholds + with the system-default severity levels of threshold1 = + warning and threshold2 = minor. Setting this leaf-list + to (minor, major) will assign the severity levels as + threshold1 = minor and threshold2 = major"; + } + } + } + } + + /* + * Notifications + */ + + notification alarm-notification { + description + "This notification is used to report a state change for an + alarm. The same notification is used for reporting a newly + raised alarm, a cleared alarm, or changing the text and/or + severity of an existing alarm."; + uses common-alarm-parameters; + uses alarm-state-change-parameters; + } + + notification alarm-inventory-changed { + description + "This notification is used to report that the list of possible + alarms has changed. This can happen when, for example, a new + software module is installed or a new physical card is + inserted."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-common-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-common-alarms-v1.yang new file mode 100644 index 000000000..930bba32f --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-common-alarms-v1.yang @@ -0,0 +1,56 @@ +module o-ran-sc-common-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran-sc:alarms:1.0"; + prefix osc-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran-sc.org"; + description + "This module defines the alarm identities for the O-RAN-SC Components. + + Copyright 2020 the O-RAN Software Community. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type use for all O-RAN-SC alarm types which are + common across the O-RAN managed functions."; + } + + identity smo-o1-ves-collector-not-reachable { + base alarm-type-id; + description + "The configured VES end-point for asynchron messages is not reachable. + Instructions: + 1) Verify the VES configuration on the O-RAN component. + 2) Verify the connectivity between the O-RAN component and the + SMO in terms of routing and firewall settings along the path. + 3) Check the credentials of the O-RAN component (user, password, + certificate). Did changes happen on SMO level recently?"; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-cp-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-cp-alarms-v1.yang new file mode 100644 index 000000000..e29ff2d21 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-cp-alarms-v1.yang @@ -0,0 +1,57 @@ +module o-ran-sc-cu-cp-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran-sc:cu:cp:alarms:1.0"; + prefix osc-cu-cp-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran-sc.org"; + description + "This module defines the alarm identities for the O-RAN-SC Central Unit + Control Plane. + + Copyright 2020 the O-RAN Software Community. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type used for all O-RAN-SC specific alarm types for + Managed Function O-CU-CP."; + } + + identity huston-we-have-a-problem { + base alarm-type-id; + description + "A generic alarm which is under development and analysis, + must not happen in production environment. + Instructions: + Create an JIRA issue and provide the following intormation: + - SMO version, build number or git hash + - O-CU-CP version, build number or git hash + - A procedure to reproduce the alarm."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-up-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-up-alarms-v1.yang new file mode 100644 index 000000000..020103f4f --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-cu-up-alarms-v1.yang @@ -0,0 +1,57 @@ +module o-ran-sc-cu-up-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran-sc:cu:up:alarms:1.0"; + prefix osc-cu-up-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran-sc.org"; + description + "This module defines the alarm identities for the O-RAN-SC Central Unit + User Plane. + + Copyright 2020 the O-RAN Software Community. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type used for all O-RAN-SC specific alarm types for + Managed Function O-CU-UP."; + } + + identity huston-we-have-a-problem { + base alarm-type-id; + description + "A generic alarm which is under development and analysis, + must not happen in production environment. + Instructions: + Create an JIRA issue and provide the following intormation: + - SMO version, build number or git hash + - O-CU-UP version, build number or git hash + - A procedure to reproduce the alarm."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-du-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-du-alarms-v1.yang new file mode 100644 index 000000000..e7d3b45f0 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-du-alarms-v1.yang @@ -0,0 +1,56 @@ +module o-ran-sc-du-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran-sc:du:alarms:1.0"; + prefix osc-du-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran-sc.org"; + description + "This module defines the alarm identities for the O-RAN-SC Distributed Unit. + + Copyright 2020 the O-RAN Software Community. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type used for all O-RAN-SC specific alarm types for + Managed Function O-DU."; + } + + identity huston-we-have-a-problem { + base alarm-type-id; + description + "A generic alarm which is under development and analysis, + must not happen in production environment. + Instructions: + Create an JIRA issue and provide the following intormation: + - SMO version, build number or git hash + - O-DU version, build number or git hash + - A procedure to reproduce the alarm."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ric-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ric-alarms-v1.yang new file mode 100644 index 000000000..ace2a78b0 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ric-alarms-v1.yang @@ -0,0 +1,56 @@ +module o-ran-sc-ric-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran:ric:alarms:1.0"; + prefix osc-ric-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran.org"; + description + "This module defines the alarm identities for the O-RAN-SC Near realtime RAN Intelligent Controller. + + Copyright 2019 the O-RAN Alliance. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type used for all O-RAN-SC specific alarm types for + Managed Function Non-RT-RIC."; + } + + identity huston-we-have-a-problem { + base alarm-type-id; + description + "A generic alarm which is under development and analysis, + must not happen in production environment. + Instructions: + Create an JIRA issue and provide the following intormation: + - SMO version, build number or git hash + - O-DU-low version, build number or git hash + - A procedure to reproduce the alarm."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ru-alarms-v1.yang b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ru-alarms-v1.yang new file mode 100644 index 000000000..c52414d75 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/yang/o-ran-sc-ru-alarms-v1.yang @@ -0,0 +1,56 @@ +module o-ran-sc-ru-alarms-v1 { + yang-version 1.1; + namespace "urn:o-ran-sc:ru:alarms:1.0"; + prefix osc-ru-al; + + import ietf-alarms { + prefix al; + } + + organization + "O-RAN Software Community"; + contact + "www.o-ran-sc.org"; + description + "This module defines the alarm identities for the O-RAN-SC Components. + + Copyright 2020 the O-RAN Software Community. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2020-01-18 { + description + "initial revision"; + reference + "O-RAN-OAM-Interface-Specification (O1)"; + } + + identity alarm-type-id { + base al:alarm-type-id; + description + "An abstract alarm type used for all O-RAN-SC specific alarm types for + Managed Function O-RU."; + } + + identity huston-we-have-a-problem { + base alarm-type-id; + description + "A generic alarm which is under development and analysis, + must not happen in production environment. + Instructions: + Create an JIRA issue and provide the following intormation: + - SMO version, build number or git hash + - O-RU version, build number or git hash + - A procedure to reproduce the alarm."; + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java new file mode 100644 index 000000000..1b5ed9b86 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java @@ -0,0 +1,84 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.DeviceManagerORanImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestDeviceManagerORanImpl { + private static Path KARAF_ETC = Paths.get("etc"); + private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerORanImpl.class); + DeviceManagerORanImpl devMgrOran; + + @Before + public void init() throws InterruptedException, IOException { + /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName()); + Path etc = KARAF_ETC; + delete(etc); + + System.out.println("Create empty:" + etc.toString()); + Files.createDirectories(etc);*/ + } + + @Test + public void test() throws Exception { + devMgrOran = new DeviceManagerORanImpl(); + /*DeviceManagerImpl devMgr = new DeviceManagerImpl(); + + try { + devMgr.init(); + devMgrOran.setNetconfNetworkElementService(devMgr); + devMgrOran.init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + /* + * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init(); + * NetconfNetworkElementService netConfNetworkElementService = + * mock(NetconfNetworkElementService.class); devMgrOran = + * mock(DeviceManagerORanImpl.class); + * when(netConfNetworkElementService.registerNetworkElementFactory(new + * ORanNetworkElementFactory())).thenReturn(null); + */ + + + } + + @After + public void cleanUp() throws Exception { + devMgrOran.close(); + } + + private static void delete(Path etc) throws IOException { + if (Files.exists(etc)) { + System.out.println("Found, removing:" + etc.toString()); + delete(etc.toFile()); + } + } + + private static void delete(File f) throws IOException { + if (f.isDirectory()) { + for (File c : f.listFiles()) { + delete(c); + } + } + if (!f.delete()) { + throw new FileNotFoundException("Failed to delete file: " + f); + } + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java new file mode 100644 index 000000000..caa4e6463 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java @@ -0,0 +1,7 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; + +public interface TestHardwareClass extends HardwareClass { + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java new file mode 100644 index 000000000..c309d86c1 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ + +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import static org.mockito.Mockito.*; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; + +public class TestORanChangeNotificationListener { + + private static final String NODEID = "node1"; + + @Test + public void test() { + + NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); + DataProvider databaseService = mock(DataProvider.class); + ORanChangeNotificationListener notifListener = new ORanChangeNotificationListener(netconfAccessor, + databaseService); + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { + + @Override + public int compareTo(PathArgument arg0) { + return 0; + } + + @Override + public Class<? extends DataObject> getType() { + return DataObject.class; + } + }); + InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); + + notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create,target)); + EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) + .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build(); + verify(databaseService).writeEventLog(event); + + } + + /** + * @param type + * @return + */ + private static NetconfConfigChange createNotification(EditOperationType type,InstanceIdentifier<?> target) { + NetconfConfigChange change = mock(NetconfConfigChange.class); + + @SuppressWarnings("null") + final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); + when(change.nonnullEdit()).thenReturn(edits); + return change; + } +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java index a215e1883..9cdb83c1d 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,23 +15,16 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotificationListener; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; - -public class ClusterSingletonServiceProviderMock implements ClusterSingletonServiceProvider { - - @Override - public void close() throws Exception { +public class TestORanFaultNotificationListener { + @Test + public void test() { + ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(); + faultListener.onAlarmNotif(null); } - - @Override - public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service) { - return null; - } - } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java new file mode 100644 index 000000000..4752b6802 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; + +import java.util.List; +import java.util.Optional; +import java.io.IOException; +import java.util.Date; + +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.TransactionUtilsMock; +import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; + +public class TestORanNetworkElement { + + static NetconfAccessorMock accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + QName qCapability; + + @SuppressWarnings("unchecked") + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + //accessor = mock(NetconfAccessorMock.class); + accessor = spy(new NetconfAccessorMock(null, null, null, null)); + serviceProvider = mock(DeviceManagerServiceProvider.class); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getCapabilites()).thenReturn(capabilities); + when (accessor.getNodeId()).thenReturn(nNodeId); + when (accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock()); + + when(serviceProvider.getDataProvider()).thenReturn(new DataProvider() { + + @Override + public void writeConnectionLog(ConnectionlogEntity event) { + // TODO Auto-generated method stub + + } + + @Override + public void writeEventLog(EventlogEntity event) { + // TODO Auto-generated method stub + + } + + @Override + public void writeFaultLog(FaultlogEntity fault) { + // TODO Auto-generated method stub + + } + + @Override + public void updateFaultCurrent(FaultcurrentEntity fault) { + // TODO Auto-generated method stub + + } + + @Override + public int clearFaultsCurrentOfNode(String nodeName) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public List<String> getAllNodesWithCurrentAlarms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void writeInventory(Inventory internalEquipment) { + // TODO Auto-generated method stub + + } + + @Override + public void updateNetworkConnectionDeviceType( + NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) { + // TODO Auto-generated method stub + + } + + @Override + public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, + String nodeId) { + // TODO Auto-generated method stub + + } + + @Override + public void removeNetworkConnection(String nodeId) { + // TODO Auto-generated method stub + + } + + @Override + public int doIndexClean(Date olderAreOutdated) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getNumberOfOldObjects(Date olderAreOutdated) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public List<NetworkElementConnectionEntity> getNetworkElementConnections() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void doWritePerformanceData(List<PmdataEntity> list) { + // TODO Auto-generated method stub + + } + + }); + + + } + + @Test + public void test() { + Optional<NetworkElement> oRanNe; + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + oRanNe = factory.create(accessor, serviceProvider); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + oRanNe.get().register(); + oRanNe.get().deregister(); + oRanNe.get().getAcessor(); + oRanNe.get().getDeviceType(); + assertEquals(oRanNe.get().getNodeId().getValue(), "nSky"); + } + + @After + public void cleanUp() throws Exception { + + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java new file mode 100644 index 000000000..3583bef2b --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yangtools.yang.common.QName; + +public class TestORanNetworkElementFactory { + + static NetconfAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + accessor = mock(NetconfAccessorMock.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getDataProvider()).thenReturn(null); + + + } + + @Test + public void testCreateORANHWComponent() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } + + @Test + public void testCreateSimulator() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @Test + public void testCreateNone() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); + } + + @After + public void cleanUp() throws Exception { + + } +} + diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java new file mode 100644 index 000000000..c20b7e653 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; +import java.io.IOException; +import java.util.ArrayList; + +import org.eclipse.jdt.annotation.Nullable; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanToInternalDataModel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.TestHardwareClass; + +public class TestORanToInternalDataModel { + + NodeId nodeId; + Component component; + + @SuppressWarnings("unchecked") + @Before + public void init() throws InterruptedException, IOException { + nodeId = mock(NodeId.class); + component = mock(Component.class); + + when(nodeId.getValue()).thenReturn("ORan-1000"); + when(component.getParent()).thenReturn("Shelf"); + when(component.getParentRelPos()).thenReturn(0); + when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB")); + + List<String> list = new ArrayList<String>(); + list.add("Card-01A"); + list.add("Card-01B"); + + when (component.getContainsChild()).thenReturn(list); + when (component.getName()).thenReturn("Nokia"); + when (component.getDescription()).thenReturn("ORAN Network Element NO-456"); + Class<? extends HardwareClass> hwClass = TestHardwareClass.class; + Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass); + + DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z"); + when (component.getMfgDate()).thenReturn(dt); + + } + + @Test + public void test() throws Exception { + ORanToInternalDataModel model = new ORanToInternalDataModel(); + model.getInternalEquipment(nodeId, component); + assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB"); + assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z"); + + } + + @After + public void cleanUp() throws Exception { + + } +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java new file mode 100644 index 000000000..bf204d4c6 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock; + +import com.google.common.util.concurrent.ListenableFuture; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.RpcResult; + +/** + */ +public class NetconfAccessorMock implements NetconfAccessor { + + private final NodeId nNodeId; + private final NetconfNode netconfNode; + private final MountPoint mountpoint; + private final DataBroker netconfNodeDataBroker; + + public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint, + DataBroker netconfNodeDataBroker) { + this.nNodeId = nNodeId; + this.netconfNode = netconfNode; + this.mountpoint = mountpoint; + this.netconfNodeDataBroker = netconfNodeDataBroker; + } + + @Override + public NodeId getNodeId() { + return nNodeId; + } + + @Override + public NetconfNode getNetconfNode() { + return netconfNode; + } + + @Override + public Capabilities getCapabilites() { + return null; + } + + @Override + public DataBroker getDataBroker() { + return netconfNodeDataBroker; + } + + @Override + public MountPoint getMountpoint() { + return mountpoint; + } + + @Override + public TransactionUtils getTransactionUtils() { + return null; + } + + @Override + public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener( + @NonNull T listener) { + return null; + } + + @Override + public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) { + return null; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java new file mode 100644 index 000000000..288bcc1d8 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedBy; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +public class NetconfConfigChangeMock implements NetconfConfigChange { + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + + @Override + public <E$$ extends Augmentation<NetconfConfigChange>> @Nullable E$$ augmentation(Class<E$$> augmentationType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable ChangedBy getChangedBy() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Datastore getDatastore() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Edit> getEdit() { + List<Edit> list = new ArrayList<Edit>(); + return list; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java new file mode 100644 index 000000000..1e6a4800b --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TransactionUtilsMock implements TransactionUtils { + + @Override + public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, + InstanceIdentifier<T> iid) { + // TODO Auto-generated method stub + return null; + } + + @Override + public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, + LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, + AtomicReference<String> statusIndicator) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang b/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang index b1dea1357..e8d29641a 100644 --- a/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang +++ b/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang @@ -1,157 +1,191 @@ module devicemanager { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager"; - prefix "devicemanager"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager"; + prefix devicemanager; - import data-provider { prefix "data-provider"; } + import data-provider { + prefix data-provider; + } + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + ONAP: <https://wiki.onap.org/display/DW/ODLUX+DB+API>"; + + description + "DeviceManager Api Module + + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. + + Licensed under the Apache License, Version 2.0 (the 'License'); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an 'AS IS' BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License."; + + revision 2019-01-09 { description - "DeviceManager Api Module"; + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } - revision "2019-01-09" { - description - "Initial revision"; + rpc set-maintenance-mode { + description + "Set maintenance mode for network element"; + input { + uses data-provider:maintenance-entity; + } + output { + uses data-provider:maintenance-entity; } + } - rpc set-maintenance-mode{ + rpc get-maintenance-mode { + description + "Get maintenance mode Configuration"; + input { + leaf mountpoint-name { + type string; description - "Set maintenance mode for network element"; - input{ - uses data-provider:maintenance-entity; - } - output { - uses data-provider:maintenance-entity; - } + "Mountpoint-name as key of node"; + } + } + output { + uses data-provider:maintenance-entity; } - rpc get-maintenance-mode{ + } + + rpc test-maintenance-mode { + description + "Send test pattern similar to notification that are test from algorithm"; + input { + leaf mountpoint-name { + type string; + mandatory true; description - "Get maintenance mode Configuration"; - input{ - leaf mountpoint-name{ - mandatory true; - type string; - description - "Mountpoint-name as key of node"; - } - } - output { - uses data-provider:maintenance-entity; - } + "mountpoint for test"; + } + leaf object-id-ref { + type string; + mandatory true; + description + "object id for test"; + } + leaf problem-name { + type string; + mandatory true; + description + "problem for test"; + } + leaf test-date { + type string; + mandatory true; + description + "point in time used for the test"; + } } - rpc test-maintenance-mode{ + output { + leaf result-string { + type string; + mandatory true; description - "Send test pattern similar to notification that are test from algorithm"; - input{ - leaf mountpoint-name { - mandatory true; - type string; - description "mountpoint for test"; - } - leaf object-id-ref { - mandatory true; - type string; - description "object id for test"; - } - leaf problem-name { - mandatory true; - type string; - description "problem for test"; - } - leaf test-date { - mandatory true; - type string; - description "point in time used for the test"; - } - - } - output { - leaf result-string { - mandatory true; - type string; - description "Describin if mountpoint was found and result of maintenance mode testing"; - } - uses data-provider:maintenance-entity; - } + "Describin if mountpoint was found and result of maintenance mode testing"; + } + uses data-provider:maintenance-entity; } - rpc show-required-network-element { + } + + rpc show-required-network-element { + description + "Get information for required network element"; + input { + leaf mountpoint-name { + type string; + mandatory true; description - "Get information for required network element"; - - input { - leaf mountpoint-name { - mandatory true; - type string; - description - "Mountpoint-name as key of the node to be displayed."; - } + "Mountpoint-name as key of the node to be displayed."; + } + } + output { + container required-network-element { + leaf mountpoint-name { + type string; + description + "The name of the mountpoint"; + } + leaf status { + type string; + description + "Status: pre-provisoning, installed, end-of-life (Later enum)"; } - output { - container required-network-element { - leaf mountpoint-name { - type string; - description - "The name of the mountpoint"; - } - leaf status { - type string; - description - "Status: pre-provisoning, installed, end-of-life (Later enum)"; - } - leaf description { - type string; - description "Device description"; - } - } + leaf description { + type string; + description + "Device description"; } + description + "An output object presenting a network element (or device, NetConf + server, network function) which is expected to be connected."; + } } + } - rpc get-required-network-element-keys { + rpc get-required-network-element-keys { + description + "Returns a list of netconf nodes for each data store space"; + output { + leaf-list mountpoint-names { + type string; description - "Returns a list of netconf nodes for each data store space"; - - output { - leaf-list mountpoint-names { - type string; - description - "List of required-network-element keys that are the mountpoint-names"; - } - } + "List of required-network-element keys that are the mountpoint-names"; + } } + } - rpc clear-current-fault-by-nodename { + rpc clear-current-fault-by-nodename { + description + "try to clear alarms and sync the alarm with the devices currently connected"; + input { + leaf-list nodenames { + type string; description - "try to clear alarms and sync the alarm with the devices currently connected"; - input { - leaf-list nodenames { - type string; - description - "list of network-elements to clear alarms for nodenames, if list empty then all"; - } - } - output { - leaf-list nodenames { - type string; - description - "list of network-elements alarms cleared"; - } - } + "list of network-elements to clear alarms for nodenames, if list empty then all"; + } } - rpc push-fault-notification { + output { + leaf-list nodenames { + type string; description - "Forward fault problem notification of a network-element"; - input { - uses data-provider:object-change-reference; - uses data-provider:fault; - } + "list of network-elements alarms cleared"; + } } - rpc push-attribute-change-notification { - description - "Forward attribute change notification of a network-element"; - input { - uses data-provider:object-change-reference; - uses data-provider:attribute-change; - } + } + + rpc push-fault-notification { + description + "Forward fault problem notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:fault; } -} + } + rpc push-attribute-change-notification { + description + "Forward attribute change notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:attribute-change; + } + } +} diff --git a/sdnr/wt/devicemanager/provider/pom.xml b/sdnr/wt/devicemanager/provider/pom.xml index 28ca6c18b..5a76795af 100644 --- a/sdnr/wt/devicemanager/provider/pom.xml +++ b/sdnr/wt/devicemanager/provider/pom.xml @@ -176,40 +176,6 @@ </excludes> </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generateDTOs</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>bash</executable> - <arguments> - <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument> - <argument>initfile</argument> - <argument>-f</argument> - <argument>${project.build.directory}/EsInit.script</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <systemProperties> - <property> - <name>databaseport</name> - <value>${databaseport}</value> - </property> - </systemProperties> - </configuration> - </plugin> </plugins> </build> </project> diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java index d30ee9d67..68e5dd940 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java @@ -20,6 +20,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Base64; import java.util.HashMap; import java.util.Map; @@ -35,233 +36,242 @@ import org.slf4j.LoggerFactory; public class AaiConfig implements Configuration { - private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class); - - private static final String SECTION_MARKER_AAI = "aai"; - - private enum Config { - AAIPROP_FILE("aaiPropertiesFile", "null"), - BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"), - USERCREDENTIALS("aaiUserCredentials",""), - HEADERS("aaiHeaders","[\"X-TransactionId: 9999\"]"), - DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove",false), - TRUSTALLCERTS("aaiTrustAllCerts",false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"), - APIVERSION("aaiApiVersion", "aai/v13"), - PCKS12CERTFILENAME("aaiPcks12ClientCertFile","", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"), - PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase","", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"), - CONNECTIONTIMEOUT("aaiClientConnectionTimeout",String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT), "connection.timeout"), //in ms; - APPLICATIONID("aaiApplicationId","SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"), - HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout"); - - private String propertyKey; - private String propertyValue; - private Optional<String> propertyKeySecondFile; - - Config(String propertyKey, Object propertyValue) { - this.propertyKey = propertyKey; - this.propertyValue = propertyValue.toString(); - this.propertyKeySecondFile = Optional.empty(); - } - - Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) { - this(propertyKey, propertyValue); - this.propertyKeySecondFile = Optional.of(propertyKeySecondFile); - } - } - - private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms - private static final String HEADER_KEY_APPLICATION = "X-FromAppId"; - - private final ConfigurationFileRepresentation configuration; - - public AaiConfig(ConfigurationFileRepresentation configuration) { - HtAssert.nonnull(configuration); - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_AAI); - defaults(); - } - - /* - * Getter - */ - - public boolean doDeleteOnMountPointRemoved() { - return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey); - } - - public boolean getTrustAll() { - return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey); - } - - public String getPcks12CertificateFilename() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey); - } - - public String getPcks12CertificatePassphrase() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey); - } - - public int getConnectionTimeout() { - long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey).orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT); - return (int)res; - } - - public boolean isOff() { - return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off"); - } - - public String getBaseUri() { - String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); - if (!res.startsWith("/")) { - res = "/" + res; - } - return res; - } - - public String getBaseUrl() { - if (isOff()) { - return ""; - } else { - String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey); - if (!url.endsWith("/")) { - url += "/"; - } - String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); - if (apiVersion.startsWith("/")) { - apiVersion = apiVersion.substring(1); - } - return url + apiVersion; - } - } - - public Map<String, String> getHeaders() { - - Map<String,String> headers = _parseHeadersMap(configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey)); - headers.put(HEADER_KEY_APPLICATION, configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey)); - - String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey); - if (!nullorempty(credentials)) { - String credentialParts[] = credentials.split(":"); - if (credentialParts.length == 2) { - // 0:username 1:password - String s = headers.getOrDefault("Authorization", null); - if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) { - headers.put("Authorization", - "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()))); - } - } - } - return headers; - } - - @Override - public String getSectionName() { - return SECTION_MARKER_AAI; - } - - @Override - public void defaults() { - for (Config conf : Config.values()) { - configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue); - } - // If file is available, the content is assigned to related parameters. - getAaiPropertiesFile(); - } - - @Override - public String toString() { - return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()=" - + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename() - + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()=" - + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()=" - + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]"; - } - - /* - * Private - */ - - private boolean nullorempty(String s) { - return s == null || s.isEmpty(); - } - - /** - * Convert headers to configuration string. - * @param headers - * @return - */ - @SuppressWarnings("unused") - private static String _printHeadersMap(Map<String, String> headers) { - String r = "["; - if (headers != null) { - int i = 0; - for (Entry<String, String> entry : headers.entrySet()) { - if (i > 0) { - r += ","; - } - r += "\"" + entry.getKey() + ":" + entry.getValue() + "\""; - i++; - } - } - r += "]"; - return r; - } - - private static Map<String, String> _parseHeadersMap(String s) { - - LOG.info("Parse: '{}'",s); - Map<String, String> r = new HashMap<>(); - if (s != null) { - s = s.trim(); - if (!s.isEmpty()) { - JSONArray a; - try { - a = new JSONArray(s); - if (a.length() > 0) { - for (int i = 0; i < a.length(); i++) { - String item = a.getString(i); - String[] hlp = item.split(":"); - if (hlp.length > 1) { - r.put(hlp[0], hlp[1]); - } - } - } - } catch (Exception e) { - LOG.debug("Unparsable '{}'", s); - } - } - } - return r; - } - - /** - * Read file if available and assign to configuration - */ - private void getAaiPropertiesFile() { - String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey); - File f = new File(aaiPropertiesFileName); - if (f.exists()) { - try { - FileInputStream in = new FileInputStream(f); - Properties defaultProps = new Properties(); - defaultProps.load(in); - - for (Config conf : Config.values()) { - if (conf.propertyKeySecondFile.isPresent()) { - String config = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", conf.propertyValue); - LOG.debug("Property file assign {} = {} ",conf.propertyKey, config ); - configuration.setPropertyIfNotAvailable( - SECTION_MARKER_AAI, - conf.propertyKey, - config); - } - } - - in.close(); - } catch (IOException e) { - LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e); - } - } - } + private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class); + + private static final String SECTION_MARKER_AAI = "aai"; + + private enum Config { + AAIPROP_FILE("aaiPropertiesFile", "null"), BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"), + USERCREDENTIALS("aaiUserCredentials", ""), HEADERS("aaiHeaders", "[\"X-TransactionId: 9999\"]"), + DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove", false), + TRUSTALLCERTS("aaiTrustAllCerts", false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"), + APIVERSION("aaiApiVersion", "aai/v13"), + PCKS12CERTFILENAME("aaiPcks12ClientCertFile", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"), + PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"), + CONNECTIONTIMEOUT("aaiClientConnectionTimeout", String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT), + "connection.timeout"), //in ms; + APPLICATIONID("aaiApplicationId", "SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"), + HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout"); + + private String propertyKey; + private String propertyValue; + private Optional<String> propertyKeySecondFile; + + Config(String propertyKey, Object propertyValue) { + this.propertyKey = propertyKey; + this.propertyValue = propertyValue.toString(); + this.propertyKeySecondFile = Optional.empty(); + } + + Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) { + this(propertyKey, propertyValue); + this.propertyKeySecondFile = Optional.of(propertyKeySecondFile); + } + } + + private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms + private static final String HEADER_KEY_APPLICATION = "X-FromAppId"; + + private final ConfigurationFileRepresentation configuration; + + public AaiConfig(ConfigurationFileRepresentation configuration) { + HtAssert.nonnull(configuration); + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_AAI); + defaults(); + } + + /* + * Getter + */ + + public boolean doDeleteOnMountPointRemoved() { + return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey); + } + + public boolean getTrustAll() { + return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey); + } + + public String getPcks12CertificateFilename() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey); + } + + public String getPcks12CertificatePassphrase() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey); + } + + public int getConnectionTimeout() { + long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.CONNECTIONTIMEOUT.propertyKey) + .orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT); + return (int) res; + } + + public boolean isOff() { + return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off"); + } + + public String getBaseUri() { + String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); + if (!res.startsWith("/")) { + res = "/" + res; + } + return res; + } + + public String getBaseUrl() { + if (isOff()) { + return ""; + } + + String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey); + if (!url.endsWith("/")) { + url += "/"; + } + String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey); + if (apiVersion.startsWith("/")) { + apiVersion = apiVersion.substring(1); + } + return url + apiVersion; + + } + + public Map<String, String> getHeaders() { + + Map<String, String> headers = _parseHeadersMap( + configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey)); + headers.put(HEADER_KEY_APPLICATION, + configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey)); + + String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey); + if (!nullorempty(credentials)) { + String credentialParts[] = credentials.split(":"); + if (credentialParts.length == 2) { + // 0:username 1:password + String s = headers.getOrDefault("Authorization", null); + if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) { + headers.put("Authorization", + "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()))); + } + } + } + return headers; + } + + @Override + public String getSectionName() { + return SECTION_MARKER_AAI; + } + + @Override + public void defaults() { + for (Config conf : Config.values()) { + configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue); + } + // If file is available, the content is assigned to related parameters. + getAaiPropertiesFile(); + } + + @Override + public String toString() { + return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()=" + + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename() + + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()=" + + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()=" + + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]"; + } + + /* + * Private + */ + + private boolean nullorempty(String s) { + return s == null || s.isEmpty(); + } + + /** + * Convert headers to configuration string. + * @param headers + * @return + */ + @SuppressWarnings("unused") + private static String _printHeadersMap(Map<String, String> headers) { + String r = "["; + if (headers != null) { + int i = 0; + for (Entry<String, String> entry : headers.entrySet()) { + if (i > 0) { + r += ","; + } + r += "\"" + entry.getKey() + ":" + entry.getValue() + "\""; + i++; + } + } + r += "]"; + return r; + } + + private static Map<String, String> _parseHeadersMap(String s) { + + LOG.info("Parse: '{}'", s); + Map<String, String> r = new HashMap<>(); + if (s != null) { + s = s.trim(); + if (!s.isEmpty()) { + JSONArray a; + try { + a = new JSONArray(s); + if (a.length() > 0) { + for (int i = 0; i < a.length(); i++) { + String item = a.getString(i); + String[] hlp = item.split(":"); + if (hlp.length > 1) { + r.put(hlp[0], hlp[1]); + } + } + } + } catch (Exception e) { + LOG.debug("Unparsable '{}'", s); + } + } + } + return r; + } + + /** + * Read file if available and assign to configuration + */ + private void getAaiPropertiesFile() { + String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey); + File f = new File(aaiPropertiesFileName); + if (f.exists()) { + InputStream in = null; + try { + in = new FileInputStream(f); + Properties defaultProps = new Properties(); + defaultProps.load(in); + + for (Config conf : Config.values()) { + if (conf.propertyKeySecondFile.isPresent()) { + String config = defaultProps.getProperty(conf.propertyKeySecondFile.get(), + conf.propertyValue); + LOG.debug("Property file assign {} = {} ", conf.propertyKey, config); + configuration.setProperty(SECTION_MARKER_AAI, conf.propertyKey, config); + } + } + + } catch (IOException e) { + LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + LOG.warn("problem closing file string for {}: {}",f.getAbsoluteFile(),e); + } + } + } + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java index 11e86e896..66caf0df7 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java @@ -29,7 +29,7 @@ import java.util.concurrent.ScheduledExecutorService; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.config.DmConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.DeviceMonitoredNe; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; @@ -215,6 +215,17 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener } } + /** + * For test run the tasks + */ + public void taskTestRun() { + synchronized(queue) { + for (DeviceMonitorTask task : queue.values()) { + task.run(); + } + } + } + /*------------------------------------------------------------- * Private functions */ diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java index fc7af5a92..b25f3fd8b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java @@ -31,7 +31,7 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.DeviceMonitoredNe; import org.slf4j.Logger; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/datamanager/DeviceManagerDatabaseNotificationService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java index e65a42720..1db1e2ca5 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/datamanager/DeviceManagerDatabaseNotificationService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java @@ -15,21 +15,27 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.datamanager; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler; import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.common.HtAssert; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.DevicemanagerNotificationDelayService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationDelayFilter; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationDelayedListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.EquipmentData; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.EventlogNotificationBuilder; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; @@ -43,28 +49,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -/** - * @author herbert - * - */ -public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService { +public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService,NotificationDelayedListener<ProblemNotificationXml> { + + private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerDatabaseNotificationService.class); - private final DataProvider databaseService; - private final WebSocketServiceClientInternal webSocketService; + private final @NonNull DataProvider databaseService; + private final @NonNull WebSocketServiceClientInternal webSocketService; + private @NonNull + final DevicemanagerNotificationDelayService notificationDelayService; + private @NonNull + final DcaeForwarderInternal aotsDcaeForwarder; + + private final @NonNull MaintenanceServiceImpl maintenanceService; /** * @param databaseService to access database + * @param maintenanceService * @param webSocketService to send notifications + * @param notificationDelayService filter to prevent toggle alarms + * @param aotsDcaeForwarder */ - public DeviceManagerDatabaseNotificationService(DataProvider databaseService, - WebSocketServiceClientInternal webSocketService) { + public DeviceManagerDatabaseNotificationService(@NonNull DataProvider databaseService, + @NonNull MaintenanceServiceImpl maintenanceService, @NonNull WebSocketServiceClientInternal webSocketService, + @NonNull DevicemanagerNotificationDelayService notificationDelayService, + @NonNull DcaeForwarderInternal aotsDcaeForwarder) { super(); - HtAssert.nonnull(databaseService); - HtAssert.nonnull(webSocketService); + HtAssert.nonnull(databaseService, maintenanceService,webSocketService, notificationDelayService); this.databaseService = databaseService; + this.maintenanceService = maintenanceService; this.webSocketService = webSocketService; + this.notificationDelayService = notificationDelayService; + this.aotsDcaeForwarder = aotsDcaeForwarder; } @Override @@ -120,16 +139,40 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer ProblemNotificationXml notificationXml = new ProblemNotificationXml(faultNotification); String nodeName = faultNotification.getNodeId(); + if(NotificationDelayFilter.isEnabled()) + { + if(notificationXml.getSeverity() == InternalSeverity.NonAlarmed) { + this.notificationDelayService.getInstance(nodeName, this).clearAlarmNotification(notificationXml); + } else { + this.notificationDelayService.getInstance(nodeName, this).pushAlarmNotification(notificationXml); + } + } + else + { + this.pushAlarmIfNotInMaintenance(nodeName,notificationXml); + } // ToggleAlarmFilter functionality -// if (delayFilter.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed, notificationXml.getProblem(), notificationXml)) -// { -// dcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml); +// if (notificationDelayService.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed, +// notificationXml.getProblem(), notificationXml)) { +// if (notificationDelayService.processNotification(notificationXml)) { +// aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml); +// } // } // end of ToggleAlarmFilter this.webSocketService.sendViaWebsockets(nodeName, notificationXml); } - + private void pushAlarmIfNotInMaintenance(String nodeName,ProblemNotificationXml notificationXml) + { + if(!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(), notificationXml.getProblem())) + { + this.aotsDcaeForwarder.sendProblemNotification(nodeName, notificationXml); + } + else + { + LOG.debug("Notification will not be sent to external services. Device "+nodeName+" is in maintenance mode"); + } + } @Override public void faultNotification(@NonNull NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp, @Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity) { @@ -165,4 +208,10 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer return bFaultcurrent.build(); } + + @Override + public void onNotificationDelay(String nodeName,ProblemNotificationXml notification) { + LOG.debug("Got delayed event of type :: {}", ProblemNotificationXml.class.getSimpleName()); + this.pushAlarmIfNotInMaintenance(nodeName,notification); + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/ODLEventListenerHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java index 1b31a4e98..003a30c72 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/ODLEventListenerHandler.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java @@ -15,7 +15,7 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/RpcPushNotificationsHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java index 6378db7b0..7c04ffc54 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/RpcPushNotificationsHandler.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java @@ -2,7 +2,10 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,25 +21,7 @@ * ============LICENSE_END======================================================= * */ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler; -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java index 1628fba1b..3335a88de 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java @@ -36,6 +36,7 @@ import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus; import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; @@ -142,8 +143,8 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ @SuppressWarnings("null") @NonNull InstanceIdentifier<Node> instanceIdentifier = NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(nodeId))); - FluentFuture<Optional<Node>> optionalNode = this.dataBroker.newReadOnlyTransaction() - .read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); + ReadTransaction trans = this.dataBroker.newReadOnlyTransaction(); + FluentFuture<Optional<Node>> optionalNode =trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); try { Node node = optionalNode.get(5, TimeUnit.SECONDS).get(); LOG.debug("node is {}", node); @@ -157,6 +158,9 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ } catch (ExecutionException | InterruptedException | TimeoutException e) { LOG.warn("unable to get node info: {}", e); } + finally { + trans.close(); + } return null; } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java index 73a3e7c24..ef666966f 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java @@ -27,8 +27,8 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.opendaylight.mdsal.binding.api.MountPoint; import org.opendaylight.mdsal.binding.api.MountPointService; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java index 9a2b81cbb..11fba81f4 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java @@ -67,7 +67,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl private @Nullable final ResyncNetworkElementsListener resyncCallbackListener; - DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry, + public DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry, MaintenanceServiceImpl maintenanceService, ResyncNetworkElementsListener listener, PushNotifications pushNotificationsListener) { this.maintenanceService = maintenanceService; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java index bf467cf9c..d202def5e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java @@ -28,18 +28,16 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.datamanager.DeviceManagerDatabaseNotificationService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.DeviceManagerDatabaseNotificationService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.RpcPushNotificationsHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ConnectionStatusHousekeepingService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementHouskeepingService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.RpcPushNotificationsHandler; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfChangeListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientDummyImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl2; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl; @@ -100,7 +98,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa // Devicemanager common services for network element handler private @Nullable WebSocketServiceClientInternal webSocketService; private ODLEventListenerHandler odlEventListenerHandler; //EventHandlingService - private NetconfChangeListener netconfChangeListener; + //private NetconfChangeListener netconfChangeListener; private DeviceManagerApiServiceImpl rpcApiService; private PerformanceManagerImpl performanceManager; private DcaeProviderClient dcaeProviderClient; @@ -200,14 +198,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.maintenanceService = new MaintenanceServiceImpl(iEntityDataProvider.getHtDatabaseMaintenance()); // Websockets - try { - this.webSocketService = new WebSocketServiceClientImpl2(websocketmanagerService); - } catch (Exception e) { - LOG.error("Can not start websocket service. Loading mock class.", e); - this.webSocketService = new WebSocketServiceClientDummyImpl(); - } - - this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, webSocketService); + this.webSocketService = new WebSocketServiceClientImpl2(websocketmanagerService); IEsConfig esConfig = iEntityDataProvider.getEsConfig(); // DCAE @@ -218,6 +209,9 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + esConfig.getCluster(); this.aotsDcaeForwarder = new DcaeForwarderImpl(null, dcaeProviderClient, maintenanceService); + + this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, maintenanceService,webSocketService, notificationDelayService, aotsDcaeForwarder); + this.rpcPushNotificationsHandler = new RpcPushNotificationsHandler(webSocketService, dataProvider, aotsDcaeForwarder); this.odlEventListenerHandler = new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, @@ -279,7 +273,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa close(aaiProviderClient); close(deviceMonitor); //close(htDatabaseClient); - close(netconfChangeListener); + //close(netconfChangeListener); close(maintenanceService); close(rpcApiService); close(notificationDelayService); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java index 2d949e59a..9065ffd4b 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java @@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.HtAssert; import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; @@ -149,8 +149,12 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis @Override public void close() { - registerNetconfNodeConnectListener.close(); - registerNetconfNodeStateListener.close(); + if (registerNetconfNodeConnectListener != null) { + registerNetconfNodeConnectListener.close(); + } + if (registerNetconfNodeStateListener != null) { + registerNetconfNodeStateListener.close(); + } } /*-------------------------------------------- diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java deleted file mode 100644 index 7e54881ed..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka; - -import java.io.File; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; - -public class AkkaConfig { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(AkkaConfig.class); - - private static final String DEFAULT_FILENAME = "configuration/initial/akka.conf"; - private final String filename; - private ClusterConfig cluserConfig; - - public ClusterConfig getClusterConfig() { - return this.cluserConfig; - } - - private AkkaConfig(String filename) { - this.filename = filename; - } - - public AkkaConfig() { - this(null); - } - - @Override - public String toString() { - return "AkkaConfig [filename=" + filename + ", cluserConfig=" + cluserConfig + "]"; - } - - private void loadFromFile() throws Exception { - Config cfg = ConfigFactory.parseFile(new File(this.filename)); - this.cluserConfig = new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster")); - } - - public boolean isCluster() { - return this.cluserConfig != null ? this.cluserConfig.isCluster() : false; - } - - public boolean isClusterAndFirstNode() { - return isSingleNode() || isCluster() && getClusterConfig().getRoleMemberIndex() == 1; - } - - public static AkkaConfig load() throws Exception { - return load(DEFAULT_FILENAME); - } - - public static AkkaConfig load(String filename) throws Exception { - AkkaConfig cfg = new AkkaConfig(filename); - cfg.loadFromFile(); - return cfg; - } - - public boolean isSingleNode() { - return !this.isCluster(); - } - public static AkkaConfig parse(String content) throws Exception { - Config cfg = ConfigFactory.parseString(content); - AkkaConfig c = new AkkaConfig(); - c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster")); - return c; - } -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java deleted file mode 100644 index c6c8c1533..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka; - -import java.util.ArrayList; -import java.util.List; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.ClusterRoleInfo; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.ClusterRoleInfoCollection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.typesafe.config.Config; - -public class ClusterConfig { - - private static final Logger LOG = LoggerFactory.getLogger(ClusterConfig.class); - - private final List<ClusterNodeInfo> seedNodes; - private final ClusterRoleInfoCollection roles; - private ClusterNodeInfo ismeInfo; - - public static ClusterConfig defaultSingleNodeConfig() - { - ClusterConfig cfg=new ClusterConfig(); - cfg.ismeInfo=ClusterNodeInfo.defaultSingleNodeInfo(); - cfg.seedNodes.add(cfg.ismeInfo); - cfg.roles.add(ClusterRoleInfo.defaultSingleNodeRole()); - return cfg; - } - public ClusterConfig() - { - this.seedNodes = new ArrayList<>(); - this.roles = new ClusterRoleInfoCollection(); - - } - public ClusterConfig(Config o) throws Exception { - { - this.seedNodes = new ArrayList<>(); - this.roles = new ClusterRoleInfoCollection(); - List<String> a = o.getStringList("seed-nodes"); - for (int i = 0; i < a.size(); i++) { - ClusterNodeInfo info = new ClusterNodeInfo(a.get(i)); - this.seedNodes.add(info); - } - a = o.getStringList("roles"); - for (int i = 0; i < a.size(); i++) { - ClusterRoleInfo s = new ClusterRoleInfo(a.get(i)); - this.roles.add(s); - } - int idx = this.roles.get(0).getIndex() - 1; - if (idx >= 0 && idx < this.seedNodes.size()) { - this.ismeInfo = this.seedNodes.get(idx); - } else { - this.ismeInfo = null; - } - } - - } - - public boolean isCluster() { - return this.seedNodes != null ? this.seedNodes.size() > 1 : false; - } - - public boolean isMe(ClusterNodeInfo i) { - return this.ismeInfo != null ? this.ismeInfo.equals(i) : false; - } - - public List<ClusterNodeInfo> getSeedNodes() { - return this.seedNodes; - } - - public String getHostName(String defaultValue) { - if (getRoleMemberIndex() > 0 && getRoleMemberIndex() <= seedNodes.size()) { - return this.seedNodes.get(getRoleMemberIndex()-1).getRemoteAddress(); - } else { - LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}",getRoleMember(), defaultValue); - return defaultValue; - } - } - - public String getDBClusterName(String defaultValue) { - String r = null; - if (this.seedNodes != null && this.seedNodes.size() > 0) { - r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), this.seedNodes.get(0).getPort()); - } - if (r == null || r.isEmpty()) { - r = defaultValue; - } - return r; - } - public String getClusterSeedNodeName() { - return this.getClusterSeedNodeName(""); - } - public String getClusterSeedNodeName(String defaultValue) { - int idx=this.getRoleMemberIndex()-1; - String r=null; - if(this.seedNodes!=null && idx>=0 && this.seedNodes.size()>0 && this.seedNodes.size()>idx) - { - r=this.seedNodes.get(idx).getSeedNodeName(); - } - if (r == null || r.isEmpty()) { - r = defaultValue; - } - return r; - } - public int getRoleMemberIndex() { - - ClusterRoleInfo role=this.roles.get("member"); - return role!=null?role.getIndex():0; - } - public ClusterRoleInfo getRoleMember() { - return this.roles.get("member"); - } - - @Override - public String toString() { - return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + ", ismeInfo=" + ismeInfo + "]"; - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java deleted file mode 100644 index 7bc015fed..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ClusterNodeInfo { - private final String protocol; - private final String clusterName; - private final String remoteAdr; - private final int port; - private final String seedNodeName; - - public static ClusterNodeInfo defaultSingleNodeInfo() { - return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550); - } - - public ClusterNodeInfo(String s) throws Exception { - final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)"; - final Pattern pattern = Pattern.compile(regex); - final Matcher matcher = pattern.matcher(s); - if (!matcher.find()) { - throw new Exception("invalid seedNode format"); - } - this.seedNodeName = matcher.group(); - this.protocol = matcher.group(1); - this.clusterName = matcher.group(2); - this.remoteAdr = matcher.group(3); - this.port = Integer.parseInt(matcher.group(4)); - } - - public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) { - this.protocol=protocol; - this.clusterName=clustername; - this.remoteAdr=remoteadr; - this.port=port; - this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port; - } - - public String getProtocol() { - return protocol; - } - - public String getClusterName() { - return clusterName; - } - - public String getRemoteAddress() { - return remoteAdr; - } - public String getSeedNodeName() { - return seedNodeName; - } - - public int getPort() { - return port; - } - - @Override - public String toString() { - return "ClusterNodeInfo [protocol=" + protocol + ", clusterName=" + clusterName + ", remoteAdr=" + remoteAdr - + ", port=" + port + ", seedNodeName=" + seedNodeName + "]"; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java deleted file mode 100644 index 9a9793b89..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ClusterRoleInfo { - private final String Role; - private final int Index; - - public ClusterRoleInfo(String s) throws Exception { - final String regex = "([a-zA-Z]*)-([0-9]*)"; - final Pattern pattern = Pattern.compile(regex); - final Matcher matcher = pattern.matcher(s); - if (!matcher.find()) { - throw new Exception("unexpected role format:"+s); - } - this.Role = matcher.group(1); - this.Index = Integer.parseInt(matcher.group(2)); - } - - private ClusterRoleInfo(String role, int idx) { - this.Role=role; - this.Index=idx; - } - - public static ClusterRoleInfo defaultSingleNodeRole() { - return new ClusterRoleInfo("member",1); - } - - public String getRole() { - return Role; - } - public int getIndex() { - return Index; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Index; - result = prime * result + (Role == null ? 0 : Role.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ClusterRoleInfo other = (ClusterRoleInfo) obj; - if (Index != other.Index) { - return false; - } - if (Role == null) { - if (other.Role != null) { - return false; - } - } else if (!Role.equals(other.Role)) { - return false; - } - return true; - } - @Override - public String toString() { - return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]"; - } -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java deleted file mode 100644 index 089bf33f2..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo; - -import java.util.ArrayList; - -public class ClusterRoleInfoCollection extends ArrayList<ClusterRoleInfo> { - private static final long serialVersionUID = 1L; - - public ClusterRoleInfo get(String role) { - for (ClusterRoleInfo info : this) { - if (info.getRole().equals(role)) { - return info; - } - } - return null; - } - - public boolean contains(ClusterRoleInfo info) { - if (info == null) { - return false; - } - for (ClusterRoleInfo i : this) { - if (i.equals(info)) { - return true; - } - } - return false; - } -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java deleted file mode 100644 index 25e7fe265..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import com.typesafe.config.Config; -import com.typesafe.config.ConfigFactory; - -public class GeoConfig { - - private static final String DEFAULT_FILENAME = "configuration/initial/geo.conf"; - private static final String LUMINA_ROOTNODENAME = "lumina-geo-cluster"; - private final String filename; - private final String rootNodename; - private ClusterRoleInfoCollection primaryRoles; - private ClusterRoleInfoCollection secondayRoles; - private RolesTable rolesTable; - - private GeoConfig() { - this(null); - } - - private GeoConfig(String filename) { - this(filename, LUMINA_ROOTNODENAME); - } - - private GeoConfig(String filename, String rootNodeName) { - this.filename = filename; - this.rootNodename = rootNodeName; - } - - public static boolean fileExists() { - File f = new File(DEFAULT_FILENAME); - return f.exists(); - } - - public static GeoConfig load() throws Exception { - return load(DEFAULT_FILENAME); - } - - public static GeoConfig load(String filename) throws Exception { - GeoConfig cfg = new GeoConfig(filename); - cfg._load(); - return cfg; - } - - private void _load() throws Exception { - this._load(ConfigFactory.parseFile(new File(this.filename))); - } - - private void _load(Config cfg) throws Exception { - this.primaryRoles = new ClusterRoleInfoCollection(); - List<String> a = cfg.getConfig(this.rootNodename).getStringList("primary_roles"); - - for (int i = 0; i < a.size(); i++) { - ClusterRoleInfo s = new ClusterRoleInfo(a.get(i)); - this.primaryRoles.add(s); - } - this.secondayRoles = new ClusterRoleInfoCollection(); - a = cfg.getConfig(this.rootNodename).getStringList("secondary_roles"); - for (int i = 0; i < a.size(); i++) { - ClusterRoleInfo s = new ClusterRoleInfo(a.get(i)); - this.secondayRoles.add(s); - } - this.checkDuplicateRoleEntries(); - this.rolesTable = new RolesTable(cfg.getConfig(this.rootNodename).getConfigList("ip_roles_table")); - } - - private void checkDuplicateRoleEntries() throws Exception { - ClusterRoleInfoCollection duplicateEntries = new ClusterRoleInfoCollection(); - for (ClusterRoleInfo primaryRole : this.primaryRoles) { - if (this.secondayRoles.contains(primaryRole)) { - duplicateEntries.add(primaryRole); - } - } - if (duplicateEntries.size() > 0) { - throw new Exception("duplicate entries found: " + duplicateEntries.toString()); - } - - } - - public static GeoConfig parse(String content) throws Exception { - GeoConfig cfg = new GeoConfig(); - cfg._load(ConfigFactory.parseString(content)); - return cfg; - } - - public ClusterRoleInfoCollection getPrimaryRoles() { - return this.primaryRoles; - } - - public ClusterRoleInfoCollection getSecondaryRoles() { - return this.secondayRoles; - } - - public boolean isPrimary(ClusterRoleInfo roleMember) { - return !this.isSecondary(roleMember); - } - - private boolean isSecondary(ClusterRoleInfo roleMember) { - if (roleMember == null) { - return false; - } - for (ClusterRoleInfo info : this.secondayRoles) { - if (info.equals(roleMember)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return "GeoConfig [filename=" + filename + ", rootNodename=" + rootNodename + ", primaryRoles=" + primaryRoles - + ", secondayRoles=" + secondayRoles + ", rolesTable=" + rolesTable + "]"; - } - - public static class RolesTableEntry { - private final ClusterRoleInfo role; - private final String ip; - - public RolesTableEntry(Config c) throws Exception { - this.role = new ClusterRoleInfo(c.getString("role")); - this.ip = c.getString("ip"); - } - - @Override - public String toString() { - return "RolesTableEntry [role=" + role + ", ip=" + ip + "]"; - } - } - public static class RolesTable extends ArrayList<RolesTableEntry> { - private static final long serialVersionUID = -9146218864237487506L; - - public RolesTable(List<? extends Config> configList) throws Exception { - for (Config c : configList) { - this.add(new RolesTableEntry(c)); - } - } - - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java deleted file mode 100644 index 919156b20..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java +++ /dev/null @@ -1,258 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database; - -import java.util.Collection; -import java.util.List; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.common.database.IsEsObject; -import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; -import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; -import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Generic class to write lists of model classes to the database. - * - */ -public class HtDataBaseReaderAndWriter<T extends IsEsObject> { - - private static final Logger log = LoggerFactory.getLogger(HtDataBaseReaderAndWriter.class); - - - private final DatabaseClient db; - private final String dataTypeName; - private final HtMapper<T> mapper; - - /** - * Class specific access to database - * @param db ES database descriptor - * @param dataTypeName datatype name - * @param clazz class of datatype - */ - public HtDataBaseReaderAndWriter(DatabaseClient db, String dataTypeName, Class<? extends T> clazz) { - - this.db = db; - this.dataTypeName = dataTypeName; - this.mapper = new HtMapper<>( clazz ); - - } - public boolean isExistsIndex() { - return this.db.isExistsIndex(this.dataTypeName); - } - /** - * @return dataTypeName - */ - public String getDataTypeName() { - return this.dataTypeName; - } - /** - * Remove Object from database - * @param object Object with content - * @return true if remove is done - */ - public boolean doRemove( T object) { - - return db.doRemove(dataTypeName, object ); - - } - - /** - * Remove all data that match the filter - * @param query to specify data to be deleted - * @return number of removed objects - */ - public int doRemoveByQuery(QueryBuilder query) { - - int idx = 0; //Idx for getAll - int iterateLength = 100; //Step width for iterate - - List<SearchHit> hits; - do { - hits = db.doReadByQueryJsonData( dataTypeName, query).getHits(); - log.debug("Found: {} elements: {} Failures: {}",dataTypeName,hits.size(), mapper.getMappingFailures()); - - T object; - idx += hits.size(); - for (SearchHit hit : hits) { - - object = mapper.getObjectFromJson( hit.getSourceAsString() ); - - log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures()); - if (object != null) { - object.setEsId( hit.getId() ); - doRemove(object); - } else { - log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString()); - } - } - } while (hits.size() == iterateLength); //Do it until end indicated, because less hits than iterateLength allows. - - return idx; - } - - /** - * Do the mapping for test purpose - * @param object object for test purpose - * @return json String - */ - public String getJson( T object ) { - String json = mapper.objectToJson(object); - return json; - } - - /** - * Write one object into Database - * @param object Object with content - * @return This object for chained call pattern. - */ - public T doWrite( T object) { - - String json = mapper.objectToJson(object); - return doWrite(object, json); - - } - - /** - * Write one object into Database - * @param object Object with content - * @param json string - * @return This object for chained call pattern. - */ - public T doWrite( T object, String json) { - - log.debug("doWrite {} {}",object.getClass().getSimpleName(), object.getEsId()); - - if (json != null) { - String esId = db.doWriteJsonString(dataTypeName, object, json); - object.setEsId(esId); - log.debug("doWrite done for {} {}",object.getClass().getSimpleName(), object.getEsId()); - return esId == null ? null : object; - } else { - log.warn("Can not map object and write to database. {} {}",object.getClass().getSimpleName(), object); - return null; - } - - } - - - /** - * Write a list of Objects to the database. - * @param list Object list with content - * @return This object for chained call pattern. - */ - public HtDataBaseReaderAndWriter<T> doWrite( Collection<T> list) { - - int writeError = 0; - log.debug("Write to ES database {} Class: {} {} elements",dataTypeName, mapper.getClazz().getSimpleName(), list.size()); - - if (list != null && !list.isEmpty()) { - for( T s : list ) { - if ( doWrite(s) == null ) { - if ( ++writeError > 5 ) { - log.warn("Leave because of to >5 write errors"); - break; - } - } - } - } - - return this; - } - - /** - * Read one object via the object class specific ID - * @param object Object refrenced by idString - * @return The Object if found or null - */ - public @Nullable T doRead( IsEsObject object ) { - T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, object) ); - if (res != null) { - res.setEsId(object.getEsId()); - } - return res; - } - - /** - * Read one object via the object class specific ID - * @param objectEsId Object refrence - * @return The Object if found or null - */ - public @Nullable T doRead( String objectEsId ) { - T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, objectEsId ) ); - if (res != null) { - res.setEsId(objectEsId); - } - return res; - } - /** - * Get all elements of related type - * @return all Elements - */ - public SearchResult<T> doReadAll() { - return doReadAll(null); - } - - /** - * Read all existing objects of a type - * @param query for the elements - * @return the list of all objects - */ - - public SearchResult<T> doReadAll(QueryBuilder query) { - - SearchResult<T> res = new SearchResult<>(); - int idx = 0; //Idx for getAll - int iterateLength = 100; //Step width for iterate - - SearchResult<SearchHit> result; - List<SearchHit> hits; - do { - if(query!=null) { - log.debug("read data in {} with query {}",dataTypeName,query.toJSON()); - result=db.doReadByQueryJsonData( dataTypeName, query); - } - else { - result = db.doReadAllJsonData( dataTypeName); - } - hits=result.getHits(); - log.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), mapper.getMappingFailures()); - - T object; - idx += result.getHits().size(); - for (SearchHit hit : hits) { - -// object = mapper.getObjectFromJson( hit.getSourceRef() ); - object = mapper.getObjectFromJson( hit.getSourceAsString() ); - - log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures()); - if (object != null) { - object.setEsId( hit.getId() ); - res.add( object ); - } else { - log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString()); - } - } - } while (hits.size() == iterateLength); //Do it until end indicated, because less hits than iterateLength allows. - res.setTotal(idx); - return res; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java deleted file mode 100644 index dc2e4d768..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import java.io.IOException; -import org.eclipse.jdt.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Herbert - * - */ -public class HtMapper<T> { - - private static final Logger log = LoggerFactory.getLogger(HtMapper.class); - - private final Class<? extends T> clazz; - - private final JsonMapperBase objectMapperRead; - private final JsonMapperBase objectMapperWrite; - - private int mappingFailures; - - public HtMapper(Class<? extends T> clazz) { - - this.mappingFailures = 0; - this.clazz = clazz; - - this.objectMapperRead = new JsonMapperBase(); - this.objectMapperWrite = this.objectMapperRead; - } - - public Class<? extends T> getClazz() { - return clazz; - } - - public int getMappingFailures() { - return mappingFailures; - } - - public String objectToJson(T object) { - return objectMapperWrite.objectToJson(object); - } - - /** - * Do the mapping from Json to class Block further mapping if there is are to - * many failures - * - * @param json String with Objects JSON representation - * @return The Object - */ - public @Nullable T getObjectFromJson(byte[] json) { - - if (json == null) { - return null; - } else if (mappingFailures < 10) { - try { - T object = objectMapperRead.readValue(json, clazz); - return object; - } catch (JsonParseException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (JsonMappingException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (IOException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (Exception e) { - mappingFailures++; - log.warn(e.toString()); - } - } - log.warn("Problems parsing : {} {}", clazz, json); - return null; - } - - /** - * Do the mapping from Json to class Block further mapping if there is are to - * many failures - * - * @param json String with Objects JSON representation - * @return The Object - */ - public @Nullable T getObjectFromJson(String json) { - - if (json == null) { - return null; - } else if (mappingFailures < 10) { - try { - T object = objectMapperRead.readValue(json, clazz); - return object; - } catch (JsonParseException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (JsonMappingException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (IOException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (Exception e) { - mappingFailures++; - log.warn(e.toString()); - } - } - log.warn("Problems parsing : {} {}", clazz, json); - return null; - } - - public void setSerializationInclusion(Include incl) { - this.objectMapperRead.setSerializationInclusion(incl); - - } - public void resetSerializationInclusion() { - this.objectMapperRead.setSerializationInclusion(Include.USE_DEFAULTS); - - - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java deleted file mode 100644 index 848004b39..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database; - -import java.io.IOException; -import java.io.StringWriter; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; -import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator.Feature; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -/** - * This class is used to define default for JSON Serialization and Deserialization for the project at a single place - */ -public class JsonMapperBase extends ObjectMapper { - - private static final long serialVersionUID = 1L; - private static final Logger LOG = LoggerFactory.getLogger(JsonMapperBase.class); - - public JsonMapperBase() { - - setVisibility(PropertyAccessor.ALL, Visibility.NONE); - setVisibility(PropertyAccessor.FIELD, Visibility.ANY); - - // Deserialization - configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); - - // Serialization - configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - getFactory().configure(Feature.ESCAPE_NON_ASCII, true); - } - - public JsonMapperBase(int t) { - - switch(t) { - case 0: - break; - case 1: - setVisibility(PropertyAccessor.ALL, Visibility.NONE); - setVisibility(PropertyAccessor.FIELD, Visibility.DEFAULT); - break; - case 2: - setVisibility(PropertyAccessor.ALL, Visibility.NONE); - setVisibility(PropertyAccessor.FIELD, Visibility.PROTECTED_AND_PUBLIC); - break; - case 3: - setVisibility(PropertyAccessor.ALL, Visibility.NONE); - setVisibility(PropertyAccessor.GETTER, Visibility.ANY); - setVisibility(PropertyAccessor.IS_GETTER, Visibility.ANY); - break; - default: - setVisibility(PropertyAccessor.ALL, Visibility.NONE); - setVisibility(PropertyAccessor.FIELD, Visibility.ANY); - break; - - } - - // Deserialization - configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); - - // Serialization - configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - getFactory().configure(Feature.ESCAPE_NON_ASCII, true); - } - - - - public String objectToJson( Object object ) { - String res = null; - - try { - - res = writeValueAsString(object); - - } catch (JsonGenerationException e) { - LOG.debug(e.toString()); - } catch (JsonMappingException e) { - LOG.debug(e.toString()); - } catch (IOException e) { - LOG.debug(e.toString()); - } catch (Exception e) { - LOG.debug(e.toString()); - } - - return res; - } - - public String objectListToJson( List<? extends Object> objectList ) { - String res = null; - - try { - - StringWriter stringEmp = new StringWriter(); - writeValue(stringEmp, objectList); - res = stringEmp.toString(); - stringEmp.close(); - - } catch (JsonGenerationException e) { - LOG.debug(e.toString()); - } catch (JsonMappingException e) { - LOG.debug(e.toString()); - } catch (IOException e) { - LOG.debug(e.toString()); - } catch (Exception e) { - LOG.debug(e.toString()); - } - - return res; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java deleted file mode 100644 index 2334bd181..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener; - -import java.util.Collection; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.NetconfNodeService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.NetconfNodeService.Action; -import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.DataObjectModification; -import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; -import org.opendaylight.mdsal.binding.api.DataTreeModification; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -// 07.09.18 Switched to DataTreeChangeListener from ClusteredDataTreeChangeListener -> DM Service is -// running at all nodes -// This is not correct -public class NetconfChangeListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfChangeListener.class); - - private static final InstanceIdentifier<Node> NETCONF_NODE_TOPO_IID = - InstanceIdentifier.create(NetworkTopology.class) - .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))) - .child(Node.class); - // Name of ODL controller NETCONF instance - private static final NodeId CONTROLLER = new NodeId("controller-config"); - - private final NetconfNodeService deviceManagerService; - private final DataBroker dataBroker; - private ListenerRegistration<NetconfChangeListener> dlcReg; - - public NetconfChangeListener(NetconfNodeService deviceManagerService, DataBroker dataBroker) { - this.deviceManagerService = deviceManagerService; - this.dataBroker = dataBroker; - } - - public void register() { - DataTreeIdentifier<Node> treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, NETCONF_NODE_TOPO_IID); - - dlcReg = dataBroker.registerDataTreeChangeListener(treeId, this); - } - - @Override - public void close() { - if (dlcReg != null) { - dlcReg.close(); - } - } - /** - * Listener function to select the right node from DataObjectModification - */ - @Override - public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) { - LOG.debug("OnDataChange, TreeChange, changes:{}", changes.size()); - - for (final DataTreeModification<Node> change : changes) { - final DataObjectModification<Node> root = change.getRootNode(); - final ModificationType modificationType = root.getModificationType(); - if (LOG.isTraceEnabled()) { - LOG.trace("Handle this modificationType:{} path:{} root:{}", modificationType, change.getRootPath(), - root); - } - switch (modificationType) { - case SUBTREE_MODIFIED: - // Change of subtree information - // update(change); OLD - doProcessing(Action.UPDATE, root.getDataAfter()); - break; - case WRITE: - // Create or modify top level node - // Treat an overwrite as an update - boolean update = root.getDataBefore() != null; - if (update) { - // update(change); - doProcessing(Action.UPDATE, root.getDataAfter()); - } else { - // add(change); - doProcessing(Action.CREATE, root.getDataAfter()); - } - break; - case DELETE: - // Node removed - // remove(change); - doProcessing(Action.REMOVE, root.getDataBefore()); - break; - } - } - } - - /* - * ---------------------------------------------------------------- - */ - - /** - * Process event and forward to clients if Node is a NetconfNode - * @param action - * @param node Basis node - */ - private void doProcessing(Action action, Node node) { - - NodeId nodeId = null; - NetconfNode nnode = null; - - try { - if (node != null) { - nodeId = node.key().getNodeId(); //Never null - nnode = node.augmentation(NetconfNode.class); - } - - if (node == null || nnode == null) { - LOG.warn("Unexpected node {}, netconf node {} id {}", node, nnode, nodeId); - } else { - // Do not forward any controller related events to devicemanager - if (nodeId.equals(CONTROLLER)) { - LOG.debug("Stop processing for [{}]", nodeId); - } else { - // Action forwarded to devicehandler - deviceManagerService.netconfNodeChangeHandler(action, nodeId, nnode); - } - } - } catch (NullPointerException e) { - LOG.warn("Unexpected null .. stop processing.", e); - } - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java index b04a49bca..c52853280 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java @@ -15,36 +15,30 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ -/** - * - */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util; +import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; /** * Converts time stamps into internal format according to ONF1.2 and ISO 8601. - * @author herbert - * + * To be replaced by NetconfTimeStampImpl */ +@Deprecated public class InternalDateAndTime { - private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter(); - - private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime("2017-01-01T00:00:00.0Z"); + private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z"; private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z"; - String internalDateAndTime = INITIALPATTERN; + private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime(TESTPATTERNSTRING); + private static final DateAndTime TESTPATTERN2 = new DateAndTime(TESTPATTERNSTRING); - /** - * Static builder ONF1.2 - * @param time in ONF1.2 yang format - * @return InternalDateAndTime - */ -// public static InternalDateAndTime valueOf(DateAndTime time) { -// return new InternalDateAndTime(time); -// } + private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter(); + + /** Internal variable to hold the value, that is converted **/ + private final String internalDateAndTime; /** * Static builder ONF1.0 @@ -63,17 +57,24 @@ public class InternalDateAndTime { return internalDateAndTime; } - /*---------------------------------------------------------------- - * Private constructors and functions + /** + * Get a testpattern + * @return testpattern */ + public static InternalDateAndTime getTestpattern() { + return TESTPATTERN; + } /** - * Convert ONF 1.2 DateAndTime to String - * @param time as input + * @return DateAndTime testpattern + */ + public static @Nullable DateAndTime getTestpatternDateAndTime() { + return TESTPATTERN2; + } + + /*---------------------------------------------------------------- + * Private constructors */ -// private InternalDateAndTime(DateAndTime time) { -// internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue()); -// } /** * Convert ONF 1.2 DateAndTime to String @@ -95,14 +96,4 @@ public class InternalDateAndTime { this.internalDateAndTime = internalDateAndTime; } - /** - * Get a testpattern - * @return testpattern - */ - public static InternalDateAndTime getTestpattern() { - return TESTPATTERN; - } - - - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java deleted file mode 100644 index 95d6b89c4..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util; - -import java.util.Optional; -import javax.annotation.Nonnull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NetconfNotification { - - private static final Logger log = LoggerFactory.getLogger(DeviceManagerImpl.class); - - /** - * Do the stream creation for the device. - * @param nodeId node-id of device - * @param mountpoint information - * @param streamName to register - */ - public static void registerNotificationStream(String nodeId, MountPoint mountpoint, String streamName) { - - final Optional<RpcConsumerRegistry> optionalRpcConsumerService = - mountpoint.getService(RpcConsumerRegistry.class); - if (optionalRpcConsumerService.isPresent()) { - final RpcConsumerRegistry rpcConsumerRegitry = optionalRpcConsumerService.get(); - @Nonnull - final NotificationsService rpcService = rpcConsumerRegitry.getRpcService(NotificationsService.class); - - final CreateSubscriptionInputBuilder createSubscriptionInputBuilder = new CreateSubscriptionInputBuilder(); - createSubscriptionInputBuilder.setStream(new StreamNameType(streamName)); - log.info("Event listener triggering notification stream {} for node {}", streamName, nodeId); - try { - CreateSubscriptionInput createSubscriptionInput = createSubscriptionInputBuilder.build(); - if (createSubscriptionInput == null) { - log.warn("createSubscriptionInput is null for mountpoint {}", nodeId); - } else { - rpcService.createSubscription(createSubscriptionInput); - } - } catch (NullPointerException e) { - log.warn("createSubscription failed"); - } - } else { - log.warn("No RpcConsumerRegistry avaialble."); - } - - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/FaultEntityManager.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java index 5b7057b81..ef30e4f28 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/FaultEntityManager.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java @@ -15,7 +15,7 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java index 156f9226e..fa67ff660 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java @@ -38,6 +38,7 @@ public class MwtNotificationBase { public MwtNotificationBase() { // For Jaxb + this.objectId = EMPTY; } public MwtNotificationBase(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectId) { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java index dcb299a8e..fbb7b6a28 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java @@ -21,9 +21,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.FaultEntityManager; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.ToggleAlarmFilterable; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder; @@ -34,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.slf4j.Logger; @XmlRootElement(name = "ProblemNotification") -public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType { +public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType, ToggleAlarmFilterable { private static String EVENTTYPE = "ProblemNotification"; @@ -87,6 +87,17 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv return severity.isNoAlarmIndication(); } + @Override + public String getUuidForMountpoint() { + return genSpecificEsId(); + } + + @Override + public boolean isCleared() { + return !isNotManagedAsCurrentProblem() && isNoAlarmIndication(); + } + + /** * Create a specific ES id for the current log. * @return a string with the generated ES Id @@ -118,6 +129,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv + super.toString() + "]"; } + @Override public String getEventType() { return EVENTTYPE; @@ -143,4 +155,5 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv log.debug("Found problems {} {}", uuid, sb.toString()); } } + } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java index fa6bb1887..bc77e2d1a 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java @@ -18,7 +18,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml; import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java index 8c01438ca..cdbbdf2df 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java @@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml; import java.util.concurrent.Future; import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventInputBuilder; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java index 8771b4c2f..40ef82a15 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java @@ -128,7 +128,7 @@ public class MaintenanceCalculator { * @param zoneTimeString with time * @return ZonedDateTime string */ - static ZonedDateTime valueOf(String zoneTimeString) { + public static ZonedDateTime valueOf(String zoneTimeString) { if (zoneTimeString == null || zoneTimeString.isEmpty()) { LOG.warn("Null or empty zoneTimeString"); return EMPTYDATETIME; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java index 6f68589f2..1368de081 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java @@ -44,7 +44,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP private final HtDatabaseMaintenance database; - public MaintenanceServiceImpl(HtDatabaseMaintenance client) throws ClassNotFoundException { + public MaintenanceServiceImpl(HtDatabaseMaintenance client) { LOG.info("Create {} start", MaintenanceServiceImpl.class); database = client; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java index 92af68bc0..0d3b8bcb8 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java @@ -22,19 +22,32 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationDelayFilter<T> implements AutoCloseable { +public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayFilter.class); + private static long delay; + private static boolean enabled; + private final ConcurrentHashMap <String, NotificationWithServerTimeStamp<T>> problemItems; // private final HashMap<String, NotificationWithServerTimeStamp<T>> nonProblemItems; private final NotificationDelayedListener<T> timeoutListener; - private static long delay; - private static boolean enabled; + private final ScheduledExecutorService scheduler; + private final Runnable timerRunner = () -> onTick(); + private final String nodeName; + + public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) { + this.nodeName = nodeName; + this.timeoutListener = timeoutListener; + this.problemItems = new ConcurrentHashMap <>(); + this.scheduler = Executors.newScheduledThreadPool(1); + this.startTimer(); + } public static void setDelay(long l) { NotificationDelayFilter.delay = l; @@ -52,30 +65,17 @@ public class NotificationDelayFilter<T> implements AutoCloseable { NotificationDelayFilter.enabled = enabled; } - private final ScheduledExecutorService scheduler; - private final Runnable timerRunner = () -> onTick(); - - private final String nodeName; - - public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) { - this.nodeName = nodeName; - this.timeoutListener = timeoutListener; - this.problemItems = new ConcurrentHashMap <>(); - this.scheduler = Executors.newScheduledThreadPool(1); - this.startTimer(); - } - /** * If process the notification * @return true if other processing is required, false if not */ - public boolean processNotification(boolean cleared, String problemName, T notificationXml) { + public boolean processNotification(@NonNull T notificationXml) { // ToggleAlarmFilter functionality if (NotificationDelayFilter.isEnabled()) { - if (cleared) { - clearAlarmNotification(problemName, notificationXml); + if (notificationXml.isCleared()) { + clearAlarmNotification(notificationXml); } else { - pushAlarmNotification(problemName, notificationXml); + pushAlarmNotification(notificationXml); } return false; } else { @@ -86,12 +86,11 @@ public class NotificationDelayFilter<T> implements AutoCloseable { /** * Push notification with a specific severity (everything except non-alarmed) - * @param problemName key * @param notification related notification */ - public void pushAlarmNotification(String problemName, T notification) { + public void pushAlarmNotification(@NonNull T notification) { synchronized (problemItems) { - + String problemName = notification.getUuidForMountpoint(); boolean cp = this.problemItems.containsKey(problemName); if (!cp) { // no alarm in entries => create entry and push the alarm currently @@ -101,7 +100,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable { + item.toString()); this.problemItems.put(problemName, item); if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(notification); + this.timeoutListener.onNotificationDelay(this.nodeName,notification); } } else { LOG.debug("clear contra event for node " + this.nodeName + " for alarm " + problemName); @@ -113,12 +112,11 @@ public class NotificationDelayFilter<T> implements AutoCloseable { /** * Push notification with severity non-alarmed - * @param problemName key * @param notification related notification */ - public void clearAlarmNotification(String problemName, T notification) { + public void clearAlarmNotification(@NonNull T notification) { synchronized (problemItems) { - + String problemName = notification.getUuidForMountpoint(); boolean cp = this.problemItems.containsKey(problemName); if (cp) { LOG.debug("set contra event for alarm " + problemName); @@ -126,7 +124,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable { } else { // not in list => push directly through if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(notification); + this.timeoutListener.onNotificationDelay(this.nodeName,notification); } } } @@ -156,7 +154,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable { // send contra Alarm if exists if (value.getContraAlarmNotification() != null) { if (this.timeoutListener != null) { - this.timeoutListener.onNotificationDelay(value.getContraAlarmNotification()); + this.timeoutListener.onNotificationDelay(this.nodeName,value.getContraAlarmNotification()); } } problemItems.remove(entry.getKey()); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java index 0768ffda8..2ad6a27bc 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java @@ -26,7 +26,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.Togg import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NotificationDelayService<T> implements DeviceManagerService, AutoCloseable, IConfigChangedListener { +public class NotificationDelayService<T extends ToggleAlarmFilterable> implements DeviceManagerService, AutoCloseable, IConfigChangedListener { private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayService.class); private final HashMap<String, NotificationDelayFilter<T>> filters; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java index eab541d13..61a913874 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java @@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter; public interface NotificationDelayedListener<T> { - public void onNotificationDelay(T notification); + public void onNotificationDelay(String nodeName,T notification); } diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java index 633912579..7a172f784 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java @@ -15,20 +15,18 @@ * the License. * ============LICENSE_END========================================================================== ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; - -import static org.junit.Assert.*; - -import org.junit.Test; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter; /** - * - Handling of inital values for Maintenance mode. + * @author herbert + * */ -public class TestInitalMaintenanceObjectInDatabase { +public interface ToggleAlarmFilterable { + - //@Test - public void test() { - fail("Not yet implemented"); - } + /** Provide id for toggle alarm filter that is unique for the mountpoint/nodeId**/ + String getUuidForMountpoint(); + /** Provide indication if cleared **/ + boolean isCleared(); } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java index c1d24b4d1..69ac9e893 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java @@ -20,6 +20,8 @@ ******************************************************************************/ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.common.io.Files; @@ -36,7 +38,9 @@ import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader; @@ -46,196 +50,228 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD public class TestAai { - private static final String CONFIGURATIONTESTFILE = "test.properties"; // for - private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties"; - private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME); - private static final int AAI_SERVER_PORT=45454; - private static final String TESTCONFIG_CONTENT="[dcae]\n" + - "dcaeUserCredentials=admin:admin\n" + - "dcaeUrl=off\n" + - "dcaeHeartbeatPeriodSeconds=120\n" + - "dcaeTestCollector=no\n" + - "\n" + - "[aots]\n" + - "userPassword=passwd\n" + - "soapurladd=off\n" + - "soapaddtimeout=10\n" + - "soapinqtimeout=20\n" + - "userName=user\n" + - "inqtemplate=inqreq.tmpl.xml\n" + - "assignedto=userid\n" + - "addtemplate=addreq.tmpl.xml\n" + - "severitypassthrough=critical,major,minor,warning\n" + - "systemuser=user\n" + - "prt-offset=1200\n" + - "soapurlinq=off\n" + - "#smtpHost=\n" + - "#smtpPort=\n" + - "#smtpUsername=\n" + - "#smtpPassword=\n" + - "#smtpSender=\n" + - "#smtpReceivers=\n" + - "\n" + - "[es]\n" + - "esCluster=sendateodl5\n" + - "\n" + - "[aai]\n" + - "#keep comment\n" + - "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + - "aaiUrl=http://localhost:"+AAI_SERVER_PORT+"\n" + - "aaiUserCredentials=AAI:AAI\n" + - "aaiDeleteOnMountpointRemove=true\n" + - "aaiTrustAllCerts=false\n" + - "aaiApiVersion=aai/v13\n" + - "aaiPropertiesFile=aaiclient.properties\n" + - "aaiApplicationId=SDNR\n" + - "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + - "aaiPcks12ClientCertPassphrase=adminadmin\n" + - "aaiClientConnectionTimeout=30000\n" + - "\n" + - "[pm]\n" + - "pmCluster=sendateodl5\n" + - "pmEnabled=true\n" + - "\n" + - ""; - private HttpServer server; - private ExecutorService httpThreadPool; - private ConfigurationFileRepresentation globalCfg; - - @Test - public void test() { - - String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath(); - ConfigurationFileRepresentation cfg=new ConfigurationFileRepresentation(testConfigurationFileName); - - AaiProviderClient provider = new AaiProviderClient(cfg, null); - - String mountPointName = "testDevice 01"; - String type="Unit"; - String model="Horizon Compact+"; - String vendor="DragonWave-X"; - String ipv4="127.0.0.1"; - String ipv6="::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName,ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - @Test - public void test2() { - try { - Thread.sleep(3000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - AaiProviderClient provider = new AaiProviderClient(globalCfg, null); - - String mountPointName = "testDevice 01"; - String type="Unit"; - String model="Horizon Compact+"; - String vendor="DragonWave-X"; - String ipv4="127.0.0.1"; - String ipv6="::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName); - provider.onDeviceRegistered(mountPointName,ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - @Before - public void initAaiTestWebserver() throws IOException { - try { - Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - } catch (IOException e1) { - fail(e1.getMessage()); - } - //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); - globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME); - this.server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); - this.httpThreadPool = Executors.newFixedThreadPool(5); - this.server.setExecutor(this.httpThreadPool); - AaiConfig config = new AaiConfig(globalCfg); - this.server.createContext(config.getBaseUri(), new MyHandler()); - //server.createContext("/", new MyRootHandler()); - this.server.setExecutor(null); // creates a default executor - this.server.start(); - System.out.println("http server started"); - } - - @After - public void stopTestWebserver() { - if (this.server != null) { - this.server.stop(0); - this.httpThreadPool.shutdownNow(); - System.out.println("http server stopped" ); - } - if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { - ENABLEDAAI_TESTCONFIG_FILE.delete(); - } - - } - static class MyHandler implements HttpHandler { - @Override - public void handle(HttpExchange t) throws IOException { - String method = t.getRequestMethod(); - System.out.println("req method: " + method); - OutputStream os = null; - try { - String res=""; - if (method.equals("GET")) { - t.sendResponseHeaders(404,res.length() ); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("DELETE")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("PUT")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else { - t.sendResponseHeaders(404, 0); - } - System.out.println("req handled successful"); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - finally { - if (os != null) - { - os.close(); - } - } - } - } + private static final String CONFIGURATIONTESTFILE = "test.properties"; // for + private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties"; + private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME); + private static final int AAI_SERVER_PORT = 45454; + private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n" + + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" + + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" + + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n" + + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n" + + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" + + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" + + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n" + + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" + + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" + + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" + + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; + + private static final String EXT_TEST_URL="https://testaai.onap.org:8443"; + private static final String EXT_TEST_KEY="test.key"; + private static final String EXT_TEST_PASSWD="test123"; + private static final String EXT_TEST_APPLICATIONID="SDNC"; + private static final long EXT_TEST_CONN_TIMEOUT=6000; + + + private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n" + + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" + + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + + // "aaiApplicationId=SDNR\n" + + // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + + // "aaiPcks12ClientCertPassphrase=adminadmin\n" + + // "aaiClientConnectionTimeout=30000\n" + + "\n"; + private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="+EXT_TEST_KEY+"\n" + + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd="+EXT_TEST_PASSWD+"\n" + + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n" + + "org.onap.ccsdk.sli.adaptors.aai.application="+EXT_TEST_APPLICATIONID+"\n" + + "org.onap.ccsdk.sli.adaptors.aai.uri="+EXT_TEST_URL+"\n" + + "connection.timeout="+EXT_TEST_CONN_TIMEOUT+"\n"; + private static HttpServer server; + private static ExecutorService httpThreadPool; + private static ConfigurationFileRepresentation globalCfg; + + @Test + public void test() { + + String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath(); + ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); + + AaiProviderClient provider = new AaiProviderClient(cfg, null); + + String mountPointName = "testDevice 01"; + String type = "Unit"; + String model = "Horizon Compact+"; + String vendor = "DragonWave-X"; + String ipv4 = "127.0.0.1"; + String ipv6 = "::1"; + List<String> ifInfos = new ArrayList<>(); + ifInfos.add("LP-MWPS-RADIO"); + InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); + System.out.println("registering device"); + provider.onDeviceRegistered(mountPointName, ii); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("unregistering device"); + provider.onDeviceUnregistered(mountPointName); + System.out.println("finished"); + try { + provider.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void test2() { + try { + Thread.sleep(3000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + AaiProviderClient provider = new AaiProviderClient(globalCfg, null); + + String mountPointName = "testDevice 01"; + String type = "Unit"; + String model = "Horizon Compact+"; + String vendor = "DragonWave-X"; + String ipv4 = "127.0.0.1"; + String ipv6 = "::1"; + List<String> ifInfos = new ArrayList<>(); + ifInfos.add("LP-MWPS-RADIO"); + InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); + System.out.println("registering device"); + provider.onDeviceRegistered(mountPointName); + provider.onDeviceRegistered(mountPointName, ii); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("unregistering device"); + provider.onDeviceUnregistered(mountPointName); + System.out.println("finished"); + try { + provider.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testExtendedProperties() { + File testConfigurationFileName = new File("abbsads.properties"); + File extfile = new File("aaiclient.properties"); + if (testConfigurationFileName.exists()) { + testConfigurationFileName.delete(); + } + if (extfile.exists()) { + extfile.delete(); + } + try { + Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT); + } catch (IOException e) { + e.printStackTrace(); + fail("problem writing a test config file: " + e.getMessage()); + } + try { + Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2); + } catch (IOException e) { + e.printStackTrace(); + fail("problem writing a second test config file: " + e.getMessage()); + } + + ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); + AaiConfig config = new AaiConfig(cfg); + System.out.println(config.toString()); + + assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL)); + assertEquals(EXT_TEST_KEY,config.getPcks12CertificateFilename()); + assertEquals(EXT_TEST_PASSWD,config.getPcks12CertificatePassphrase()); + assertEquals(EXT_TEST_APPLICATIONID,config.getHeaders().get("X-FromAppId")); + assertEquals(EXT_TEST_CONN_TIMEOUT,config.getConnectionTimeout()); + + if (testConfigurationFileName.exists()) { + testConfigurationFileName.delete(); + } + if (extfile.exists()) { + extfile.delete(); + } + + } + + @BeforeClass + public static void initAaiTestWebserver() throws IOException { + try { + Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + } catch (IOException e1) { + fail(e1.getMessage()); + } + //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); + globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME); + server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); + httpThreadPool = Executors.newFixedThreadPool(5); + server.setExecutor(httpThreadPool); + AaiConfig config = new AaiConfig(globalCfg); + server.createContext(config.getBaseUri(), new MyHandler()); + //server.createContext("/", new MyRootHandler()); + server.setExecutor(null); // creates a default executor + server.start(); + System.out.println("http server started"); + } + + @AfterClass + public static void stopTestWebserver() { + if (server != null) { + server.stop(0); + httpThreadPool.shutdownNow(); + System.out.println("http server stopped"); + } + if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { + ENABLEDAAI_TESTCONFIG_FILE.delete(); + } + + } + + static class MyHandler implements HttpHandler { + @Override + public void handle(HttpExchange t) throws IOException { + String method = t.getRequestMethod(); + System.out.println("req method: " + method); + OutputStream os = null; + try { + String res = ""; + if (method.equals("GET")) { + t.sendResponseHeaders(404, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else if (method.equals("DELETE")) { + t.sendResponseHeaders(200, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else if (method.equals("PUT")) { + t.sendResponseHeaders(200, res.length()); + os = t.getResponseBody(); + os.write(res.getBytes()); + } else { + t.sendResponseHeaders(404, 0); + } + System.out.println("req handled successful"); + + } catch (Exception e) { + System.out.println(e.getMessage()); + } finally { + if (os != null) { + os.close(); + } + } + } + } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java deleted file mode 100644 index 7bc30550f..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.fail; -import java.io.File; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka.AkkaConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka.ClusterNodeInfo; - -public class TestAkkaConfig { - - private static String getAkkaConfigSingleNodeText() { - return "\n" + "odl-cluster-data {\n" + " akka {\n" + " remote {\n" + " artery {\n" - + " enabled = off\n" + " canonical.hostname = \"127.0.0.1\"\n" - + " canonical.port = 2550\n" + " }\n" + " netty.tcp {\n" - + " hostname = \"127.0.0.1\"\n" + " port = 2550\n" + " }\n" - + " # when under load we might trip a false positive on the failure detector\n" - + " # transport-failure-detector {\n" + " # heartbeat-interval = 4 s\n" - + " # acceptable-heartbeat-pause = 16s\n" + " # }\n" + " }\n" + "\n" + " cluster {\n" - + " # Remove \".tcp\" when using artery.\n" - + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" + "\n" - + " roles = [\n" + " \"member-1\"\n" + " ]\n" + "\n" + " }\n" + "\n" - + " persistence {\n" - + " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n" - + " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n" - + " # The relative path is always relative to KARAF_HOME.\n" + "\n" - + " # snapshot-store.local.dir = \"target/snapshots\"\n" - + " # journal.leveldb.dir = \"target/journal\"\n" + "\n" + " journal {\n" - + " leveldb {\n" + " # Set native = off to use a Java-only implementation of leveldb.\n" - + " # Note that the Java-only version is not currently considered by Akka to be production quality.\n" - + "\n" + " # native = off\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}"; - } - - private static String getAkkaConfigClusterNodeText() { - return "\n" + "odl-cluster-data {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n" - + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" - + " port = 2550\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n" - + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n" - + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n" - + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2550\"]\n" - + " seed-node-timeout = 15s\n" + " roles = [\"member-1\"]\n" + "\n" + " }\n" - + " persistence {\n" + " journal-plugin-fallback {\n" + " circuit-breaker {\n" - + " max-failures = 10\n" + " call-timeout = 60s\n" - + " reset-timeout = 30s\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n" - + "odl-cluster-rpc {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n" - + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" - + " port = 2551\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n" - + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n" - + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n" - + " seed-nodes = [\"akka.tcp://odl-cluster-rpc@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2551\"]\n" - + " seed-node-timeout = 15s\n" + " }\n" + " persistence {\n" - + " journal-plugin-fallback {\n" + " circuit-breaker {\n" + " max-failures = 10\n" - + " call-timeout = 60s\n" + " reset-timeout = 30s\n" + " }\n" + " }\n" - + " }\n" + " }\n" + "}\n" + "\n" + ""; - } - - @Test - public void test1() { - AkkaConfig cfg; - try { - System.out.println("testing clusternode config1"); - System.out.println("==========================="); - cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText()); - System.out.println("succeeded: "); - System.out.println(cfg.toString()); - System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size())); - for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) { - System.out.println(n.toString()); - } - } catch (Exception e) { - String failMessage = "failed: " + e.getMessage(); - System.out.println(failMessage); - fail(failMessage); - } - } - - @Test - public void test2() { - AkkaConfig cfg; - try { - System.out.println("testing singlenode config1"); - System.out.println("==========================="); - cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText()); - System.out.println("succeeded: "); - System.out.println(cfg.toString()); - } catch (Exception e) { - String failMessage = "failed: " + e.getMessage(); - System.out.println(failMessage); - fail(failMessage); - } - } - - @Test - public void test3() { - AkkaConfig cfg; - - ClassLoader classLoader = getClass().getClassLoader(); - File file = new File(classLoader.getResource("captured-akka.conf").getFile()); - System.out.println(file.getAbsolutePath()); - - try { - System.out.println("testing clusternode config1"); - System.out.println("==========================="); - cfg = AkkaConfig.load(file.getAbsolutePath()); - System.out.println("succeeded: "+cfg.hashCode()); - System.out.println(cfg.toString()); - System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size())); - for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) { - System.out.println(n.toString()); - } - } catch (Exception e) { - String failMessage = "failed: " + e.getMessage(); - System.out.println(failMessage); - fail(failMessage); - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java index ff15f7991..0a458d805 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java @@ -46,16 +46,14 @@ public class TestDevMgrPropertiesFile { private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class); - private static final File FILENAME = new File("test.properties"); - private static final File AAIPROP_FILE=new File("aaiclient.properties"); + private static final File FILENAME = new File("testdevmgrpropertiesfile.properties"); + private static final File AAIPROP_FILE=new File("testdevmgrpropertiesfileaaiclient.properties"); private int hasChanged; @Before public void init() { - //if (! LOG.isDebugEnabled()) { - delete(FILENAME); - delete(AAIPROP_FILE); - //} + delete(FILENAME); + delete(AAIPROP_FILE); } @After public void deinit() { @@ -63,14 +61,13 @@ public class TestDevMgrPropertiesFile { } @Test - public void test1() { + public void testBasicConfiguration() { writeFile(FILENAME, this.getContent1()); writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); - System.out.println("Read and verify"); - ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(FILENAME.getPath()); - ConfigurationFileRepresentation cfg2 = cfg; + LOG.info("Read and verify"); + ConfigurationFileRepresentation cfg2 = new ConfigurationFileRepresentation(FILENAME.getPath()); AaiConfig aaiConfig = new AaiConfig(cfg2); assertNotNull(aaiConfig); @@ -81,34 +78,24 @@ public class TestDevMgrPropertiesFile { ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2); assertNotNull(toggleAlarmConfig); - System.out.println("Verify\n"+aaiConfig+"\n"); - @SuppressWarnings("unused") - boolean res; - /* - res = cfg.getAai().equals(AaiConfig.getDefaultConfiguration()); - res = cfg.getDcae().equals(DcaeConfig.getDefaultConfiguration()); - res = cfg.getPm().equals(PmConfig.getDefaultConfiguration()); - res = cfg.getEs().equals(EsConfig.getDefaultConfiguration()); - res = cfg.getToggleAlarm().equals(ToggleAlarmConfig.getDefaultConfiguration()); - - res = cfg.getAai().hashCode() == AaiConfig.getDefaultConfiguration().hashCode(); - res = cfg.getDcae().hashCode() == DcaeConfig.getDefaultConfiguration().hashCode(); - res = cfg.getPm().hashCode() == PmConfig.getDefaultConfiguration().hashCode(); - res = cfg.getEs().hashCode() == EsConfig.getDefaultConfiguration().hashCode(); - res = cfg.getToggleAlarm().hashCode() == ToggleAlarmConfig.getDefaultConfiguration().hashCode(); - */ + LOG.info("Verify {} ", aaiConfig); } //-- Observer not working with all testcases, because config does not support different file types. @Test - public void test2() { + public void testChangeConfiguration() { + + LOG.info("Read and verify"); - hasChanged=0; writeFile(FILENAME, this.getContent1()); writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); - System.out.println("Read and verify"); ConfigurationFileRepresentation cfg2 = new ConfigurationFileRepresentation(FILENAME.getPath()); + hasChanged = 0; + cfg2.registerConfigChangedListener(() -> { + hasChanged++; + LOG.info("file changed listener triggered: {}",hasChanged); + }); AaiConfig aaiConfig = new AaiConfig(cfg2); assertNotNull(aaiConfig); @@ -119,25 +106,18 @@ public class TestDevMgrPropertiesFile { ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2); assertNotNull(toggleAlarmConfig); - cfg2.registerConfigChangedListener(() -> { - hasChanged++; - System.out.println("file changed listener triggered: "+hasChanged); - }); - - sleep(1000); - System.out.println("Write new content. Changes "+hasChanged); + LOG.info("Write new content. Changes {}",hasChanged); writeFile(FILENAME, this.getContent2()); - sleep(1000); int i=10; while(hasChanged == 0 && i-- > 0) { - System.out.println("Wait for Change indication."); + LOG.info("Wait for Change indication."); sleep(1000); } - System.out.println("Changes "+hasChanged); + LOG.info("Changes {}",hasChanged); - assertTrue("fileChanged counter"+hasChanged, hasChanged > 0); - System.out.println("Test done"); + assertTrue("fileChanged counter "+hasChanged, hasChanged > 0); + LOG.info("Test done"); } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java new file mode 100644 index 000000000..7fb417838 --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * ONAP : ccsdk feature sdnr wt + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; +import org.opendaylight.mdsal.binding.api.DataBroker; + +public class TestDeviceMonitor extends Mockito { + + private static final String CONFIGURATIONTESTFILE = "test.properties"; // for + private static final String mountPointNodeName = "TestMountpoint"; + + private static DeviceMonitorImpl deviceMonitor; + + @BeforeClass + public static void before() { + + DataBroker dataBroker = mock(DataBroker.class); + ODLEventListenerHandler odlEventListenerHandler = mock(ODLEventListenerHandler.class); + ConfigurationFileRepresentation config = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE); + + deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config); + + } + + @Test + public void testDeviceMonitor() { + + deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName); + deviceMonitor.refreshAlarmsInDb(); + deviceMonitor.taskTestRun(); + deviceMonitor.deviceDisconnectIndication(mountPointNodeName); + deviceMonitor.removeMountpointIndication(mountPointNodeName); + } + + @Test + public void testDeviceMonitorTask() { + + + } + + @AfterClass + public static void after() throws Exception { + deviceMonitor.close(); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java new file mode 100644 index 000000000..a86bfc277 --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java @@ -0,0 +1,207 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * ONAP : ccsdk feature sdnr wt + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock.RpcProviderServiceMock; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPointService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings("deprecation") +public class TestDevicemanager extends Mockito { + + private static final Logger log = LoggerFactory.getLogger(TestDevicemanager.class); + + private static DeviceManagerImpl deviceManager = new DeviceManagerImpl(); + private static DevicemanagerService apiService; + private static HtDatabaseMaintenance htDataBaseMaintenance = mock(HtDatabaseMaintenance.class); + + @BeforeClass + public static void before() throws Exception { + + DataBroker dataBroker = mock(DataBroker.class); + RpcProviderServiceMock rpcProviderRegistry = new RpcProviderServiceMock(); + NotificationPublishService notificationPublishService = mock(NotificationPublishService.class); + MountPointService mountPointService = mock(MountPointService.class); + ClusterSingletonServiceProvider clusterSingletonService = mock(ClusterSingletonServiceProvider.class); + NetconfNodeStateService netconfNodeStateService = mock(NetconfNodeStateService.class); + + @SuppressWarnings("unchecked") + ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class); + //doNothing().when(lr1).close(); + when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))).thenReturn(lr1); + + @SuppressWarnings("unchecked") + ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class); + //doNothing().when(lr2).close(); + when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))).thenReturn(lr2); + + WebsocketmanagerService websocketmanagerService = mock(WebsocketmanagerService.class); + + IEntityDataProvider iEntityDataProvider = mock(IEntityDataProvider.class); + doNothing().when(iEntityDataProvider).setReadyStatus(isA(Boolean.class)); + + DataProvider dataProvider = mock(DataProvider.class); + when(iEntityDataProvider.getDataProvider()).thenReturn(dataProvider); + + when(iEntityDataProvider.getHtDatabaseMaintenance()).thenReturn(htDataBaseMaintenance); + + + IEsConfig esConfig = mock(IEsConfig.class); + when(iEntityDataProvider.getEsConfig()).thenReturn(esConfig); + + + deviceManager.setDataBroker(dataBroker); + deviceManager.setRpcProviderRegistry(rpcProviderRegistry); + deviceManager.setNotificationPublishService(notificationPublishService); + deviceManager.setMountPointService(mountPointService); + deviceManager.setClusterSingletonService(clusterSingletonService); + deviceManager.setNetconfNodeStateService(netconfNodeStateService); + deviceManager.setWebsocketmanagerService(websocketmanagerService); + deviceManager.setEntityDataProvider(iEntityDataProvider); + + deviceManager.init(); + + apiService = rpcProviderRegistry.getDeviceManagerApiService(); + + } + + + @Test + public void testInit() { + assertTrue(deviceManager.isDevicemanagerInitializationOk()); + } + + @Test + public void testChangeNotification() { + NotificationService n = deviceManager.getNotificationService(); + + n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); + + n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", "AtrributeTest1", "NewTest1"); + + n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); + + } + + @Test + public void testFaultNotification() { + log.info("testFaultNotification"); + + MaintenanceBuilder mb = new MaintenanceBuilder(); + when(htDataBaseMaintenance + .getMaintenance("")) + .thenReturn(mb.build()); + + FaultService n = deviceManager.getFaultService(); + FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder(); + n.faultNotification(faultLogEntityBuilder.build()); + + } + + @Test + public void testGet() { + log.info("testGet"); + GetRequiredNetworkElementKeysInputBuilder inputBuilder = new GetRequiredNetworkElementKeysInputBuilder(); + apiService.getRequiredNetworkElementKeys(inputBuilder.build()); + + } + + @Test + public void testShow() { + log.info("testShow"); + ShowRequiredNetworkElementInputBuilder inputBuilder = new ShowRequiredNetworkElementInputBuilder(); + inputBuilder.setMountpointName("test"); + apiService.showRequiredNetworkElement(inputBuilder.build()); + + } + + @Test + public void testResync() { + log.info("testResync"); + + ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder(); + inputBuilder.setNodenames(Arrays.asList("test1", "test2")); + apiService.clearCurrentFaultByNodename(inputBuilder.build()); + + } + + @Test + public void testPushFault() { + log.info("testPushFault"); + + PushFaultNotificationInputBuilder inputBuilder = new PushFaultNotificationInputBuilder(); + inputBuilder.setNodeId("NodeTest23"); + inputBuilder.setTimestamp(new DateAndTime("2020-01-01T01:02:03.4Z")); + apiService.pushFaultNotification(inputBuilder.build()); + + } + + @Test + public void testPushChange() { + log.info("testPushChange"); + + PushAttributeChangeNotificationInputBuilder inputBuilder = new PushAttributeChangeNotificationInputBuilder(); + inputBuilder.setNodeId("NodeTest24"); + apiService.pushAttributeChangeNotification(inputBuilder.build()); + + } + + + @AfterClass + public static void after() { + deviceManager.close(); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java deleted file mode 100644 index 6474a1eb6..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.*; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.GeoConfig; - -public class TestGeoConfig { - - @Test - public void test() { - GeoConfig config; - try { - System.out.println("testing clusternode geo config1"); - System.out.println("==========================="); - config = GeoConfig.parse(getClusterGeoConfigContent()); - System.out.println("succeeded: "); - System.out.println(config.toString()); - System.out.println("primary roles:"); - System.out.println(config.getPrimaryRoles().toString()); - System.out.println("secondary roles:"); - System.out.println(config.getSecondaryRoles().toString()); - - } catch (Exception e) { - fail("failed: " + e.getMessage()); - } - } - - - - private static String getClusterGeoConfigContent() { - return "\n" + "lumina-geo-cluster {\n" + " primary_roles = [\n" - + " \"member-1\",\"member-2\",\"member-3\"\n" + " ]\n" + " secondary_roles = [\n" - + " \"member-4\",\"member-5\",\"member-6\"\n" + " ]\n" + " ip_roles_table = [\n" + "\n" - + " {\n" + "role=\"member-1\"\n" + "ip=\"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" + "},\n" - + "{\n" + "role=\"member-2\"\n" + "ip=\"zltcmtn23arbc02.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n" - + "role=\"member-3\"\n" + "ip=\"zltcmtn23arbc03.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n" - + "role=\"member-4\"\n" + "ip=\"zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n" - + "role=\"member-5\"\n" + "ip=\"zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n" - + "role=\"member-6\"\n" + "ip=\"zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com\"\n" + "}\n" + " \n" - + " ]\n" + "}\n" + "\n" + "\n" + "\n" + "\n" + ""; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java index 932ad52d2..3d8571659 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java @@ -22,11 +22,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.time.ZonedDateTime; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceCalculator; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder; public class TestMaintenanceTimeFilter { @@ -34,7 +34,7 @@ public class TestMaintenanceTimeFilter { private static String DEFAULT2 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; @Test - public void test1() { + public void testBasic() { boolean res; @@ -59,4 +59,29 @@ public class TestMaintenanceTimeFilter { } + @Test + public void testBasic2() { + + MaintenanceBuilder mb = new MaintenanceBuilder(); + + mb.setActive(true); + mb.setStart(new DateAndTime("1999-01-01T00:00:00Z")); + mb.setEnd(new DateAndTime("2001-01-01T00:00:00Z")); + mb.setId("id1"); + mb.setObjectIdRef("Interface1"); + mb.setProblem("Problem1"); + + boolean res; + ZonedDateTime now; + + now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z"); + res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now); + assertTrue("within period",res); + + now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z"); + res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now); + assertFalse("outside period",res); + + } + } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java index 7e54f16b1..766b25e6d 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java @@ -23,10 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationWithServerTimeStamp; -public class TestNotification { +public class TestToggleAlarmFilter { @Test - public void test() { + public void testNotification() { NotificationWithServerTimeStamp<Integer> test = new NotificationWithServerTimeStamp<>(1000); @@ -37,5 +37,4 @@ public class TestNotification { } - } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java new file mode 100644 index 000000000..f1822768d --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * ONAP : ccsdk feature sdnr wt + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestXmlNotification { + + private static final Logger log = LoggerFactory.getLogger(TestXmlNotification.class); + + @Test + public void test() { + + ProblemNotificationXml notification = new ProblemNotificationXml("TestMointpoint", "network-element", + "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); + + notification.getFaultlog(SourceType.Unknown); + + notification.getFaultcurrent(); + + notification.isNotManagedAsCurrentProblem(); + + ProblemNotificationXml.debugResultList(log, "uuid", Arrays.asList(notification), 0); + + } + + @Test + public void testNoAlarm() { + + ProblemNotificationXml notification; + notification = new ProblemNotificationXml("TestMointpoint", "network-element", + "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); + + assertFalse("Critical", notification.isNoAlarmIndication()); + + notification = new ProblemNotificationXml("TestMointpoint", "network-element", + "problemName", InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern()); + + assertTrue("NonAlarm", notification.isNoAlarmIndication()); + + } + + @Test + public void testObjectCreationNotification() { + + ObjectCreationNotificationXml notification; + notification = new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1"); + + } + + @Test + public void testDeletionCreationNotification() { + + ObjectDeletionNotificationXml notification; + notification = new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2"); + + } + + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java deleted file mode 100644 index 2bd5a9272..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.mdsal.binding.api.BindingService; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; -import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; -import org.opendaylight.mdsal.binding.api.ReadTransaction; -import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; -import org.opendaylight.mdsal.binding.api.TransactionChain; -import org.opendaylight.mdsal.binding.api.TransactionChainListener; -import org.opendaylight.mdsal.binding.api.WriteTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class DataBrokerMountpointMock implements DataBroker, BindingService { - - ReadTransaction readOnlyTransaction; - - public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) { - this.readOnlyTransaction = readOnlyTransaction; - } - - @Override - public @NonNull ReadTransaction newReadOnlyTransaction() { - return readOnlyTransaction; - } - - @Override - public @NonNull ReadWriteTransaction newReadWriteTransaction() { - return null; - } - - @Override - public @NonNull WriteTransaction newWriteOnlyTransaction() { - return null; - } - - @Override - public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener( - @NonNull DataTreeIdentifier<T> treeId, @NonNull L listener) { - return null; - } - - @Override - public @NonNull TransactionChain createTransactionChain(@NonNull TransactionChainListener listener) { - return null; - } - - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java deleted file mode 100644 index 0b5052632..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; -import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; -import org.opendaylight.mdsal.binding.api.ReadTransaction; -import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; -import org.opendaylight.mdsal.binding.api.TransactionChain; -import org.opendaylight.mdsal.binding.api.TransactionChainListener; -import org.opendaylight.mdsal.binding.api.WriteTransaction; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class DataBrokerNetconfMock implements DataBroker { - - - ReadTransaction readOnlyTransaction; - - public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) { - this.readOnlyTransaction = readOnlyTransaction; - } - - @Override - public @NonNull ReadTransaction newReadOnlyTransaction() { - return readOnlyTransaction; - } - - @Override - public @NonNull ReadWriteTransaction newReadWriteTransaction() { - return null; - } - - @Override - public @NonNull WriteTransaction newWriteOnlyTransaction() { - return null; - } - - @Override - public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener( - @NonNull DataTreeIdentifier<T> treeId, @NonNull L listener) { - return null; - } - - @Override - public @NonNull TransactionChain createTransactionChain(@NonNull TransactionChainListener listener) { - return null; - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java deleted file mode 100644 index 00edbe2ed..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity; - -public class DataProviderMock implements DataProvider { - - @Override - public void writeConnectionLog(ConnectionlogEntity event) { - } - - @Override - public void writeEventLog(EventlogEntity event) { - } - - @Override - public void writeFaultLog(FaultlogEntity fault) { - } - - @Override - public void updateFaultCurrent(FaultcurrentEntity fault) { - } - - @Override - public int clearFaultsCurrentOfNode(String nodeName) { - return 0; - } - - @Override - public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) { - return 0; - } - - @Override - public List<String> getAllNodesWithCurrentAlarms() { - return new ArrayList<>(); - } - - @Override - public void writeInventory(Inventory internalEquipment) { - } - - @Override - public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy, - String nodeId) { - } - - @Override - public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, - String nodeId) { - } - - @Override - public void removeNetworkConnection(String nodeId) { - } - - @Override - public int doIndexClean(Date olderAreOutdated) { - return 0; - } - - @Override - public int getNumberOfOldObjects(Date olderAreOutdated) { - return 0; - } - - @Override - public List<NetworkElementConnectionEntity> getNetworkElementConnections() { - return new ArrayList<>(); - } - - @Override - public void doWritePerformanceData(List<PmdataEntity> list) { - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java deleted file mode 100644 index 73d32e418..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import java.util.Optional; -import org.opendaylight.mdsal.binding.api.BindingService; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.mdsal.binding.api.NotificationService; -import org.opendaylight.mdsal.binding.api.ReadTransaction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class MountPointMock implements MountPoint { - - private boolean databrokerAbsent = true; - private final DataBrokerMountpointMock dataBroker = new DataBrokerMountpointMock(); - private final RpcConsumerRegistryMock rpcConsumerRegistry = new RpcConsumerRegistryMock(); - private NotificationService setReadOnlyTransaction; - - private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID = - InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, - new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))); - - @Override - public InstanceIdentifier<?> getIdentifier() { - return NETCONF_TOPO_IID; - } - - @SuppressWarnings("unchecked") - @Override - public <T extends BindingService> Optional<T> getService(Class<T> service) { - - System.out.println("Requested mountpoint service: "+service.getSimpleName()+" databrokerAbsent state: "+databrokerAbsent); - - Optional<?> res; - if (service.isInstance(dataBroker)) { - System.out.println("Delivering databroker"); - res = databrokerAbsent ? Optional.empty() : Optional.of(dataBroker); - } else if (service.isInstance(rpcConsumerRegistry)) { - System.out.println("Delivering RpcConsumerRegistryMock"); - res = Optional.of(rpcConsumerRegistry); - } else if (service.isInstance(setReadOnlyTransaction)) { - System.out.println("Delivering notificationService"); - res = Optional.of(setReadOnlyTransaction); - } else { - System.out.println("Delivering no service"); - res = Optional.empty(); - } - return (Optional<T>)res; - } - - public void setDatabrokerAbsent( boolean state) { - this.databrokerAbsent = state; - } - - public <T extends NotificationService&ReadTransaction>void setReadOnlyTransaction(T readOnlyTransaction) { - this.setReadOnlyTransaction = readOnlyTransaction; - dataBroker.setReadOnlyTransaction(readOnlyTransaction); - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java deleted file mode 100644 index 113ead29f..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import java.util.Optional; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.mdsal.binding.api.MountPointService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * @author herbert - * - */ -public class MountPointServiceMock implements MountPointService { - - private final MountPoint mountpoint; - - public MountPointServiceMock(MountPoint mountpoint) { - this.mountpoint = mountpoint; - } - - @Override - public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> instanceId) { - - Optional<MountPoint> optional = Optional.of(mountpoint); - return optional; - } - - @Override - public <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path, - T listener) { - return null; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java deleted file mode 100644 index 5a000a52a..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; - -/** - * @author herbert - * - */ -public class NetconfNodeStateServiceMock implements NetconfNodeStateService { - - Object object = new Object(); - private final ListenerRegistration<? extends NetconfNodeConnectListener> lr = new ListenerRegistration() { - - @Override - public @NonNull Object getInstance() { - return object; - } - - @Override - public void close() { - } - - }; - - - @Override - public void close() { - } - - @Override - public <L extends NetconfNodeConnectListener> @NonNull ListenerRegistration<L> registerNetconfNodeConnectListener( - @NonNull L netconfNodeConnectListener) { - return (ListenerRegistration<L>) lr; - } - - @Override - public <L extends NetconfNodeStateListener> @NonNull ListenerRegistration<L> registerNetconfNodeStateListener( - @NonNull L netconfNodeStateListener) { - return (ListenerRegistration<L>) lr; - } - - @Override - public <L extends VesNotificationListener> @NonNull ListenerRegistration<L> registerVesNotifications( - @NonNull L netconfNodeStateListener) { - return (ListenerRegistration<L>) lr; - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java deleted file mode 100644 index fc3318b9e..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.TimeUnit; -import org.opendaylight.mdsal.binding.api.NotificationPublishService; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * @author herbert - * - */ -public class NotificationPublishServiceMock implements NotificationPublishService { - - @Override - public ListenableFuture<?> offerNotification(Notification notification) { - return null; - } - - @Override - public ListenableFuture<?> offerNotification(Notification notification, int timeout, TimeUnit unit) - throws InterruptedException { - return null; - } - - @Override - public void putNotification(Notification notification) throws InterruptedException { - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java deleted file mode 100644 index 89864c2c5..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - ******************************************************************************/ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.yangtools.yang.binding.RpcService; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class RpcConsumerRegistryMock implements RpcConsumerRegistry { - - @Override - public <T extends RpcService> T getRpcService(Class<T> serviceInterface) { - return null; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java index 4aaa1ed48..6ecafea9f 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java @@ -22,16 +22,22 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; import java.util.Set; import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; -public class RpcProviderRegistryMock implements RpcProviderService { +public class RpcProviderServiceMock implements RpcProviderService { + + private DevicemanagerService deviceManagerApi; @Override public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, T implementation) { System.out.println("Register class "+implementation); + if (implementation instanceof DevicemanagerService) { + deviceManagerApi = (DevicemanagerService)implementation; + } return null; } @@ -41,4 +47,8 @@ public class RpcProviderRegistryMock implements RpcProviderService { return null; } + public DevicemanagerService getDeviceManagerApiService() { + return deviceManagerApi; + } + } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java deleted file mode 100644 index 79688280e..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util; - -import java.util.Date; -import java.util.concurrent.TimeUnit; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; - -public class DBCleanServiceHelper { - - private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter(); - - private final DataProvider databaseEventService; - - /** - * Helper to fill data into the database - * @param deviceManager devicemanger to get services - */ - public DBCleanServiceHelper(DeviceManagerImpl deviceManager) { - this.databaseEventService = deviceManager.getDatabaseClientEvents(); - } - - /** - * Write data into database with specific date and content profile. - * @param number of data to be written for each log - * @param days starting day, relative to actual date - * @param hours starting hour ... increased by one hour for each write - * @return integer with the amount of written data - */ - public int writeDataToLogs(int number, int days, int hours) { - int res = 0; - for (Integer t=0; t < number; t++) { //Test "sdnevents", "eventlog" - ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml( - "Testpoint"+t, t, getInternalDateAndTime(days, hours+t), "ObjectId"+t); - databaseEventService.writeConnectionLog(notificationXml.getConnectionlogEntity()); - res++; - } - - for (Integer t=0; t < number; t++) { //Test "sdnevents", "faultlog" - ProblemNotificationXml fault = new ProblemNotificationXml( - "ProblemNode"+t, "Problemuuid", "Problemname", InternalSeverity.Major, t, getInternalDateAndTime(days, hours+t)); - databaseEventService.writeFaultLog(fault.getFaultlog(SourceType.Unknown)); - res++; - } - - return res; - } - - /************************************************************** - * Private section - */ - - private InternalDateAndTime getInternalDateAndTime(int days, int hours) { - Date actual = new Date(new Date().getTime() - TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS) - TimeUnit.MILLISECONDS.convert(hours, TimeUnit.HOURS)); - InternalDateAndTime timeStamp = InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp(actual)); - return timeStamp; - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java deleted file mode 100644 index 9a926fd64..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -public class ZipFile implements AutoCloseable { - - private final ZipOutputStream zos; - private final FileOutputStream fos; - - public ZipFile(String zipPath) throws FileNotFoundException { - fos = new FileOutputStream(zipPath); - zos = new ZipOutputStream(fos); - } - - public void addToZipFile(String fileName) throws FileNotFoundException, IOException { - - System.out.println("Writing '" + fileName + "' to zip file"); - - InputStream fis = ZipFile.class.getClassLoader().getResourceAsStream(fileName); - if (fis == null) { - throw new FileNotFoundException("Resource not found: " + fileName); - } - - ZipEntry zipEntry = new ZipEntry(fileName); - zos.putNextEntry(zipEntry); - byte[] bytes = new byte[1024]; - int length; - while ((length = fis.read(bytes)) >= 0) { - zos.write(bytes, 0, length); - } - zos.closeEntry(); - fis.close(); - } - - @Override - public void close() throws IOException { - zos.close(); - fos.close(); - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties index 9af26dc96..1c2f131c5 100644 --- a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties +++ b/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties @@ -25,7 +25,7 @@ # Default logging detail level for all instances of SimpleLogger. # Must be one of ("trace", "debug", "info", "warn", or "error"). # If not specified, defaults to "info". -org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simpleLogger.defaultLogLevel=debug # Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz". # Must be one of ("trace", "debug", "info", "warn", or "error"). diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md index e1eefcd8e..663aed520 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/connect/README.md @@ -1,15 +1,19 @@ # Connect -The 'Connect' application on OpenDaylight provides up-to-date connectivity information about the wireless devices in the network. It automatically displays new network elements and their connection status. Despite the network elements usually automatically mount themselves, an additional small window allows manually mounting devices/mediators. For better understanding alarms and status, a connection status log lists all the connection status changes of OpenDaylight mount points. +The 'Connect' application on OpenDaylight provides up-to-date connectivity information about the wireless devices in the network. It automatically displays new Network Elements and their connection status. Usually, the Network Elements mount themselves. If necessary, they can be mounted manually by right-clicking on the element. For better understanding of alarms and status, a connection status log lists all the connection status changes of OpenDaylight mount points. ## Views -The graphical user interfaces is divided in two sections. +The graphical user interface is divided into two sections. ### Network Elements -Network Elements are physical network functions (PNFs). A table view show configured and connected NetConf Servers to the SDN-R cluster. -This view also offer to manually configure/mount the device with the '+' icon. The SDN controller will start connecting the NetConf server. +Network Elements are physical network functions (PNFs). A table view shows all configured and connected NetConf Servers of the SDN-R cluster. This view also allows to manually configure/mount a device via the '+' button. The SDN controller will start connecting to the NetConf server. + +Network Elements can be marked as 'required'. If an element is required, it will stay available even if disconnected. If an element is not required, it will be deleted once disconnected. + +By right-clicking on an element, an action menu opens. The menu allows to mount, unmount, view the details, edit and remove the element. Additionally, it links to several applications like [Fault](../pnfFault/README.md) and [Configure](../pnfConfig/README.md), which will be filtered to display information relevant to the selected element. + ### Connection Status Log diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/general.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/general.md new file mode 100644 index 000000000..d908d1221 --- /dev/null +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/general.md @@ -0,0 +1,25 @@ +# General functionality + +The following functionality is common to all applications. + +### Table data export + +Every table can export its data via the '︙' button. +The data, which gets exported is the currently viewed data in the table. As the default pagination is set to 10, only the first 10 rows or filtered rows will be exported. To increase the number of exported rows, change the pagination. + +The behavior of the export can vary based on the browser: + +a) Some browsers allow you to save the file with the predefined name export.csv. In case your browser does not offer this function please use the 'Save as...' option and define the filename with extension csv. + +b) Some browsers save the file automatically with the alphanumeric name but without an extension. In such a case navigate to the downloaded file location and rename the file. The extension (csv) must be appended to the name. The result should look like 'export_file.csv'. + +### Table filters + +The following filters are supported by all tables based on the data type of the column. + +|Data type | Possible Filter | Example | +| ---------|---------------|---------| +| Text | Any characters or numbers, matches exactly unless a * is used. The * acts as a wildcard and can be used for contains, ends with and begins with queries. |Test, Tes*, *t | +| Numeric | < or <= or > or >= or exact number |>5000, 20, <=82 | +| Boolean |None (no filter set), true or false |true, false | + diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfConfig/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfConfig/README.md index 98c9f946c..7bc27d10a 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfConfig/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfConfig/README.md @@ -1,12 +1,12 @@ # Configuration -The application shows the actual values of all attributes of the ONF-TR-532 for a selected physical network function (PNF). Each view of a functional element is divide into capabilities, configuration, status, current problem, current performance and history performance information according to TR-532. +The application shows the actual values of all attributes of the ONF-TR-532 for a selected physical network function (PNF). Each view of a functional element is divided into capabilities, configuration, status, current problem, current performance and history performance information according to TR-532. A separate window is available for modifying the configuration. All changes made are sent to the device in a single NetConf bulk request. The operator is notified about successfully configuring the device. ## Implementation -The applications are implemented as OpenDaylight-DLUX web application using the RestConf northbound interface of the SDN controller. The key frameworks are: Typescript, react and material-ui. +The application is implemented as OpenDaylight-DLUX web application using the RestConf northbound interface of the SDN controller. The key frameworks are: Typescript, React and material-ui. -Connections status information are updated automatically due to a web socket for notifications from OpenDaylight to the browser. +Connection status information is updated automatically using a web socket for notifications from OpenDaylight to the browser. diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfEventLog/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfEventLog/README.md new file mode 100644 index 000000000..e289f422c --- /dev/null +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfEventLog/README.md @@ -0,0 +1,6 @@ +# Event Log + +The 'EventLog' application displays application logs and messages automatically created by the different active applications. +SDN-R offers a common log service so that PNFs or other ONAP components can log their data and users can analyze and export the data in a common way. + + diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfFault/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfFault/README.md index b7db4388e..2d9d35a32 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfFault/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfFault/README.md @@ -1,18 +1,18 @@ # Fault Management -To operate a network, it is important to get an overview about the currently raised alarms. The application offers basic fault management of devices supporting ONF-TR-532. The alarms are classified according to the severity level (warning, minor, major, critical). +To operate a network, it is important to get an overview about the currently raised alarms. The application offers basic fault management of devices supporting ONF-TR-532. The alarms are classified according to the severity level (warning, minor, major, critical). ## Views -The graphical user interface is separated in three views. +The graphical user interface is separated into three views. ### Current Alarms -It list all current active faults in the network. In addition it also list alarms sent by the SDN controller itself, which detects connections losses to the NetConf server (connectionLossOAM) or which detects connection loss to a devices via a mediator to a device (connectionLossNeOAM). +Lists all current active faults in the network. In addition, it also lists alarms sent by the SDN controller itself, which detects connection losses to the NetConf server (connectionLossOAM) or to a device via a mediator to a device (connectionLossNeOAM). ### Alarm Notifications -As long as the view is open, it lists all alarm notification reached by the SDN Controller. Please note that refreshing the view will start the collection again. Previous alarm notification can be viewed in the alarm log. +As long as the view is open, all alarm notifications received by the SDN Controller are listed. Please note that refreshing the view will start the collection again. Previous alarm notification can be viewed in the alarm log. ### Alarm Log @@ -20,11 +20,12 @@ Next to the current active alarms an alarm log lists all alarm notifications of ## Implementation -The application has two parts. While the server is listening for NetConf notifications to store them in the database the client retrieves the information from the database and displays them in a grid view. +The application has two parts. While the server is listening for NetConf notifications to store them in the database, the client retrieves the information from the database and displays them in a table. -The server synchronizes with the current alarm lists of the devices and calculates based on raise and clear notifications the current alarm status of the network. The current alarms are stored in a database. In addition all Problem Notifications received by the SDN controller are stored. There is no logic implemented on the client. +The server synchronizes with the current alarm lists of the devices. Based on raised and cleared notifications, the current alarm status of the network is calculated. The current alarms are stored in a database. In addition, all Problem Notifications received by the SDN controller are stored. There is no logic implemented on the client side. -An alarm status bar on top of each graphical user interface informs the operator about the health status of the network. +An alarm status bar in the header of the web application informs the operator about the health status of the network. + +The OpenDaylight-DLUX web application uses web sockets to update the graphical user interface of the Problem Notifications (devices) and Connection Status Notifications (ODL) in real-time. -The OpenDaylight DLUX web application uses web sockets for updating the graphical user interface in case of Problem Notification (devices) and Connection Status Notifications (ODL). diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfInventory/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfInventory/README.md index 8308c0530..f09a492d7 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfInventory/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfInventory/README.md @@ -1,21 +1,20 @@ # Inventory -The application offers basic inventory management of devices supporting ONF-TR-512 and ietf-hardware. +The application offers basic inventory management of devices supporting ONF-TR-512 and ietf-hardware. + +The view displays the inventory data of the network element – for example, serial-numbers and part-numbers according to the containment of the equipment. -The view displays the inventory data of the network element - basically serial-numbers and part-numbers are displaced according to the containment of the equipment. ##### Inventory Export: -As the default pagination size is set to 10, when you export the data only first 10 rows or the first 10 filtered rows shown on the page will be exported to a file. -The inventory export allows the export of up to 1000 entries, when the pagination size is increased to 1000. -So, It is recommended to change the pagination size 'Rows per page' to 1000 if you want to export the complete Inventory data. +The '︙' button in the upper right corner of the table allows exporting the inventory data as a CSV file. + +Only the currently viewed table data is exported. As the default pagination is set to 10, only the first 10 rows or filtered rows would be exported. To increase the number of exported rows change the pagination. + +The behavior of the export can vary based on different browsers: -To export the Inventory data: -The behaviour is different depending on the browser: +a) Some browsers allow you to save the file with the predefined name export.csv. In case your browser does not offer this function please use the 'Save as...' option and define the filename with extension csv. -a) Some browsers allows you to save the file with the predefined name export.csv. In case your browser does not offer this function please use 'Save as..' - option and define the filename with extension csv. +b) Some browsers save the file automatically with the alphanumeric name but without an extension. In such a case navigate to the downloaded file location and rename the file. The extension (csv) must be appended to the name. The result should look like export_file.csv. -b) Some browsers saves the file automatically with the alphanumeric name without an extension. In such case please go to the downloaded file location and rename the file - with the extension after the download. (eg: export_file.csv) diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMaintenance/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMaintenance/README.md index 2deadcafc..f6bf53889 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMaintenance/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMaintenance/README.md @@ -1,10 +1,7 @@ # Maintenance -The 'Maintenance' application on the OpenDaylight provides the information of the Network Elements which are set for Maintenance, currently or in the future. -User can manage devices to set the maintenance mode so that no unnecessary alarms are created. -When the device is in Maintenace alarms are not forwarded to DCAE and when the device maintenance is turned off the alarms will start flowing again. +The 'Maintenance' application on OpenDaylight provides information about planned maintenances of Network Elements, currently or in the future. Users can manage devices to set the maintenance mode so that no unnecessary alarms are created. When the device is in maintenance mode, alarms are not forwarded to DCAE. As soon as the maintenance is finished, the alarms will start flowing again. -'Active' field in this application shows if the Network Element is in maintenance mode currently or not. -If it is 'active' it means the Network Element is currently undergoing maintenance, If 'not active' it means maintenance might have been set for future or maintenance is already completed. +The 'active' field in the table shows if the Network Element is currently in maintenance mode or not. If it is 'active' it means the Network Element is currently undergoing maintenance, if 'not active' it means maintenance might have been set for a future date or is already completed. -Users have access to disable the Maintenance mode or change the maintenance start and end dates at any point of time by using the available options in actions column. +Users can disable the maintenance mode or change its start and end dates by using the available options in the actions column. diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMediator/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMediator/README.md index 246e77b70..ef20c15bc 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMediator/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfMediator/README.md @@ -1,3 +1,7 @@ # Mediator -Some device vendors (Altiostar, CommScope, Dragonwave-X) uses the [generic mediator framework](https://github.com/Melacon/NetConf2SNMP). Such mediator offers an API to create, delete, start and stop mediator instances.
\ No newline at end of file +Some device vendors (Altiostar, CommScope, Dragonwave-X) use the [generic mediator framework](https://github.com/Melacon/NetConf2SNMP). Such mediators offer an API to create, delete, start and stop mediator instances. + +New mediator servers can be added via the '+' button. Afterward, a server can be selected to view all available mediator instances. + +A mediator instance can be started, stopped and deleted using the available actions. Additionally, its details can be viewed. The '+' button allows the user to add a new instance. During the creation, at least one 'ODL auto connect' configuration must be added. diff --git a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfPerformance/README.md b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfPerformance/README.md index 2db5eda81..ec9f8d597 100644 --- a/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfPerformance/README.md +++ b/sdnr/wt/helpserver/provider/src/main/resources/help/sdnr/pnfPerformance/README.md @@ -1,8 +1,9 @@ # Performance -Performance Monitoring values measured by the devices are necessary to analyze and optimize the network. Therefore the application automatically retrieves all historical performance values from the devices and stores them in a database. The client part just retrieves the values from the database and displays them in graphical user interface. +Performance Monitoring values measured by the devices are necessary to analyze and optimize the network. Therefore the application automatically retrieves all historical performance values from the devices and stores them in a database. The client retrieves the values from the database and displays them in a graphical user interface. ## Performance history values -After selection of a connected PNF supporting ONF-TR-532 and an physical interface, the application collects the received and centralized stored performance values for this interface and displays them in table views. +After selecting a connected PNF supporting ONF-TR-532 and a physical interface, the application collects the received and centralized stored performance values for this interface. The data gets displayed as a line chart to visualize the data in a given time period and a corresponding table. If the table gets filtered, the chart updates itself. + diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java index dcc6ec24f..72069d72c 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java @@ -2,7 +2,10 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,23 +23,6 @@ */ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - ******************************************************************************/ import java.io.IOException; import java.util.Collection; diff --git a/sdnr/wt/odlux/apps/apiDemo/package.json b/sdnr/wt/odlux/apps/apiDemo/package.json index d6f74278b..44dae6854 100644 --- a/sdnr/wt/odlux/apps/apiDemo/package.json +++ b/sdnr/wt/odlux/apps/apiDemo/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/package.json b/sdnr/wt/odlux/apps/configurationApp/package.json index 2985ba4fb..b18d1ce10 100644 --- a/sdnr/wt/odlux/apps/configurationApp/package.json +++ b/sdnr/wt/odlux/apps/configurationApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementUnion.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementUnion.tsx index dc158c05a..25378d767 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementUnion.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementUnion.tsx @@ -35,7 +35,6 @@ export const UIElementUnion = (props: UiElementUnionProps) => { const verifyValues = (data: string) => { - debugger; let foundObjectElements = 0; let errorMessage = ""; let isPatternCorrect = null; diff --git a/sdnr/wt/odlux/apps/configurationApp/webpack.config.js b/sdnr/wt/odlux/apps/configurationApp/webpack.config.js index 6a5c5d55e..dccf34919 100644 --- a/sdnr/wt/odlux/apps/configurationApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/configurationApp/webpack.config.js @@ -127,27 +127,27 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/yang-schema/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/database/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/restconf/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/help/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/websocket": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", ws: true, changeOrigin: false, secure: false diff --git a/sdnr/wt/odlux/apps/connectApp/package.json b/sdnr/wt/odlux/apps/connectApp/package.json index 04653d520..774daba6b 100644 --- a/sdnr/wt/odlux/apps/connectApp/package.json +++ b/sdnr/wt/odlux/apps/connectApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/connectionStatusLog.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/connectionStatusLog.tsx index 4e5ca65e1..ad7b247b0 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/connectionStatusLog.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/connectionStatusLog.tsx @@ -38,7 +38,7 @@ type ConnectionStatusLogComponentProps = Connect<typeof mapProps, typeof mapDisp class ConnectionStatusLogComponent extends React.Component<ConnectionStatusLogComponentProps> { render(): JSX.Element { return ( - <ConnectionStatusTable tableId="connection-status-table" columns={[ + <ConnectionStatusTable stickyHeader tableId="connection-status-table" columns={[ { property: "timestamp", title: "Time", type: ColumnType.text }, { property: "nodeId", title: "Node Name", type: ColumnType.text }, { property: "status", title: "Connection status", type: ColumnType.text }, diff --git a/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx b/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx index 0f4b0e8ff..0370df7cb 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/components/networkElements.tsx @@ -24,11 +24,6 @@ import LinkOffIcon from '@material-ui/icons/LinkOff'; import RemoveIcon from '@material-ui/icons/RemoveCircleOutline'; import EditIcon from '@material-ui/icons/Edit'; import Info from '@material-ui/icons/Info'; -import ComputerIcon from '@material-ui/icons/Computer'; - -import Button from '@material-ui/core/Button'; -import IconButton from '@material-ui/core/IconButton'; -import Tooltip from '@material-ui/core/Tooltip'; import { MaterialTable, ColumnType, MaterialTableCtorType } from '../../../../framework/src/components/material-table'; import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore'; @@ -43,6 +38,7 @@ import EditNetworkElementDialog, { EditNetworkElementDialogMode } from './editNe import InfoNetworkElementDialog, { InfoNetworkElementDialogMode } from './infoNetworkElementDialog'; import { loadAllInfoElementAsync } from '../actions/infoNetworkElementActions'; import { TopologyNode } from '../models/topologyNetconf'; +import { MenuItem, Divider, Typography } from '@material-ui/core'; const styles = (theme: Theme) => createStyles({ connectionStatusConnected: { @@ -68,6 +64,7 @@ const styles = (theme: Theme) => createStyles({ const mapProps = (state: IApplicationStoreState) => ({ networkElementsProperties: createNetworkElementsProperties(state), + applicationState: state, }); const mapDispatch = (dispatcher: IDispatcher) => ({ @@ -105,6 +102,7 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement render(): JSX.Element { const { classes } = this.props; + const { framework, connect, configuration, fault, help, inventory, maintenance, mediator } = this.props.applicationState as any; const { networkElementToEdit } = this.state; const addRequireNetworkElementAction = { icon: AddIcon, tooltip: 'Add', onClick: () => { @@ -117,7 +115,7 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement let counter = 0; return ( <> - <NetworkElementTable tableId="network-element-table" customActionButtons={[addRequireNetworkElementAction]} columns={[ + <NetworkElementTable stickyHeader tableId="network-element-table" customActionButtons={[addRequireNetworkElementAction]} columns={[ { property: "nodeId", title: "Node Name", type: ColumnType.text }, { property: "isRequired", title: "Required", type: ColumnType.boolean }, { property: "status", title: "Connection Status", type: ColumnType.text }, @@ -125,44 +123,26 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement { property: "port", title: "Port", type: ColumnType.numeric }, { property: "coreModelCapability", title: "Core Model", type: ColumnType.text }, { property: "deviceType", title: "Type", type: ColumnType.text }, - { - property: "actions", title: "Actions", type: ColumnType.custom, customControl: ({ rowData }) => { - counter++; - return ( - <> - <div className={classes.spacer}> - { - rowData.webUri && <Tooltip title={"Web Client"} ><IconButton aria-label={"web-client-button-" + counter} className={classes.button} onClick={event => { console.log(rowData); window.open(rowData.webUri, "_blank") }}><ComputerIcon /></IconButton></Tooltip> - } - <Tooltip title={"Mount"} > - <IconButton aria-label={"mount-button-" + counter} className={classes.button} onClick={event => this.onOpenMountdNetworkElementsDialog(event, rowData)} > - <LinkIcon /></IconButton> - </Tooltip> - <Tooltip title={"Unmount"} > - <IconButton aria-label={"unmount-button-" + counter} className={classes.button} onClick={event => this.onOpenUnmountdNetworkElementsDialog(event, rowData)} > - <LinkOffIcon /></IconButton> - </Tooltip> - <Tooltip title={"Info"} ><IconButton aria-label={"info-button-" + counter} className={classes.button} onClick={event => this.onOpenInfoNetworkElementDialog(event, rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected"} > - <Info /></IconButton> - </Tooltip> - <Tooltip title={"Edit"} ><IconButton aria-label={"edit-button-" + counter} className={classes.button} onClick={event => this.onOpenEditNetworkElementDialog(event, rowData)} ><EditIcon /></IconButton></Tooltip> - <Tooltip title={"Remove"} ><IconButton aria-label={"remove-button-" + counter} className={classes.button} onClick={event => this.onOpenRemoveNetworkElementDialog(event, rowData)} ><RemoveIcon /></IconButton></Tooltip> - </div> - <div className={classes.spacer}> - <Tooltip title={"Inventory"} ><Button aria-label={"inventory-button-" + counter} className={classes.button} onClick={this.navigateToApplicationHandlerCreator("inventory", rowData)} >I</Button></Tooltip> - </div> - <div className={classes.spacer}> - <Tooltip title={"Fault"} ><Button aria-label={"fault-button-" + counter} className={classes.button} onClick={this.navigateToApplicationHandlerCreator("fault", rowData)} >F</Button></Tooltip> - <Tooltip title={"Configure"} ><Button aria-label={"configure-button-" + counter} className={classes.button} onClick={this.navigateToApplicationHandlerCreator("configuration", rowData)} >C</Button></Tooltip> - <Tooltip title={"Accounting "} ><Button className={classes.button} onClick={this.navigateToApplicationHandlerCreator("accounting", rowData)} disabled={true} >A</Button></Tooltip> - <Tooltip title={"Performance"} ><Button aria-label={"performance-button-" + counter} className={classes.button} onClick={this.navigateToApplicationHandlerCreator("performanceHistory", rowData)}>P</Button></Tooltip> - <Tooltip title={"Security"} ><Button className={classes.button} onClick={this.navigateToApplicationHandlerCreator("security", rowData)} disabled={true} >S</Button></Tooltip> - </div> - </> - ) - } - }, - ]} idProperty="id" {...this.props.networkElementsActions} {...this.props.networkElementsProperties} asynchronus > + ]} idProperty="id" {...this.props.networkElementsActions} {...this.props.networkElementsProperties} asynchronus createContextMenu={rowData => { + return [ + <MenuItem onClick={event => this.onOpenMountdNetworkElementsDialog(event, rowData)} ><LinkIcon /><Typography>Mount</Typography></MenuItem>, + <MenuItem onClick={event => this.onOpenUnmountdNetworkElementsDialog(event, rowData)}><LinkOffIcon /><Typography>Unmount</Typography></MenuItem>, + <Divider />, + <MenuItem onClick={event => this.onOpenInfoNetworkElementDialog(event, rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected"} ><Info /><Typography>Info</Typography></MenuItem>, + <MenuItem onClick={event => this.onOpenEditNetworkElementDialog(event, rowData)}><EditIcon /><Typography>Edit</Typography></MenuItem>, + !rowData.isRequired + ? <MenuItem onClick={event => this.onOpenAddNetworkElementDialog(event, rowData)} ><AddIcon /><Typography>Add</Typography></MenuItem> + : <MenuItem onClick={event => this.onOpenRemoveNetworkElementDialog(event, rowData)} ><RemoveIcon /><Typography>Remove</Typography></MenuItem>, + <Divider />, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("inventory", rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected" || !inventory}><Typography>Inventory</Typography></MenuItem>, + <Divider />, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("fault", rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected" || !fault}><Typography>Fault</Typography></MenuItem>, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("configuration", rowData)} disabled={rowData.status === "Connecting" || rowData.status === "Disconnected" || !configuration}><Typography>Configure</Typography></MenuItem>, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("accounting", rowData)} disabled={true}><Typography>Accounting</Typography></MenuItem>, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("performanceHistory", rowData)} disabled={true}><Typography>Performance</Typography></MenuItem>, + <MenuItem onClick={event => this.navigateToApplicationHandlerCreator("security", rowData)} disabled={true} ><Typography>Security</Typography></MenuItem>, + ]; + }} > </NetworkElementTable> <EditNetworkElementDialog initialNetworkElement={networkElementToEdit} @@ -182,13 +162,18 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement this.props.networkElementsActions.onRefresh(); } + private onOpenAddNetworkElementDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { + this.setState({ + networkElementToEdit: element, + networkElementEditorMode: EditNetworkElementDialogMode.AddNewNetworkElement + }); + } + private onOpenRemoveNetworkElementDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { this.setState({ networkElementToEdit: element, networkElementEditorMode: EditNetworkElementDialogMode.RemoveNetworkElement }); - event.preventDefault(); - event.stopPropagation(); } private onOpenEditNetworkElementDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { @@ -203,8 +188,6 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement }, networkElementEditorMode: EditNetworkElementDialogMode.EditNetworkElement }); - event.preventDefault(); - event.stopPropagation(); } private onOpenUnmountdNetworkElementsDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { @@ -212,8 +195,6 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement networkElementToEdit: element, networkElementEditorMode: EditNetworkElementDialogMode.UnmountNetworkElement }); - event.preventDefault(); - event.stopPropagation(); } private onOpenMountdNetworkElementsDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { @@ -221,8 +202,6 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement networkElementToEdit: element, networkElementEditorMode: EditNetworkElementDialogMode.MountNetworkElement }); - event.preventDefault(); - event.stopPropagation(); } private onOpenInfoNetworkElementDialog = (event: React.MouseEvent<HTMLElement>, element: NetworkElementConnection) => { @@ -231,8 +210,6 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement networkElementToEdit: element, infoNetworkElementEditorMode: InfoNetworkElementDialogMode.InfoNetworkElement, }); - event.preventDefault(); - event.stopPropagation(); } private onCloseEditNetworkElementDialog = () => { @@ -250,8 +227,6 @@ export class NetworkElementsListComponent extends React.Component<NetworkElement private navigateToApplicationHandlerCreator = (applicationName: string, element: NetworkElementConnection) => (event: React.MouseEvent<HTMLElement>) => { this.props.navigateToApplication(applicationName, element.nodeId); - event.preventDefault(); - event.stopPropagation(); } } diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx index f8c0f3a82..a96d3d635 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx @@ -28,6 +28,7 @@ import { ConnectionStatusLog } from '../components/connectionStatusLog'; import { setPanelAction, findWebUrisForGuiCutThroughAsyncAction, SetWeburiSearchBusy } from '../actions/commonNetworkElementsActions'; import { PanelId } from '../models/panelId'; import { NetworkElementConnection } from 'models/networkElementConnection'; +import { AppBar, Tabs, Tab } from '@material-ui/core'; const mapProps = (state: IApplicationStoreState) => ({ panelId: state.connect.currentOpenPanel, @@ -56,7 +57,15 @@ type ConnectApplicationComponentProps = Connect<typeof mapProps, typeof mapDispa class ConnectApplicationComponent extends React.Component<ConnectApplicationComponentProps>{ - componentDidUpdate = async () => { + public componentDidMount() { + if (this.props.panelId === null) { //don't change tabs, if one is selected already + this.onTogglePanel("NetworkElements"); + } + this.props.networkElementsActions.onToggleFilter(); + this.props.connectionStatusLogActions.onToggleFilter(); + } + + public componentDidUpdate = async () => { // search for guicutthroughs after networkelements were found const networkElements = this.props.netWorkElements; @@ -66,7 +75,7 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp } private onTogglePanel = (panelId: PanelId) => { - const nextActivePanel = panelId === this.props.panelId ? null : panelId; + const nextActivePanel = panelId; this.props.switchActivePanel(nextActivePanel); switch (nextActivePanel) { @@ -86,25 +95,31 @@ class ConnectApplicationComponent extends React.Component<ConnectApplicationComp }; + private onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: PanelId) => { + this.props.switchActivePanel(newValue); + } + render(): JSX.Element { - const { panelId } = this.props; + const { panelId: activePanelId } = this.props; return ( <> - <Panel activePanel={panelId} panelId={'NetworkElements'} onToggle={this.onTogglePanel} title={"Network Elements"}> - <NetworkElementsList /> - </Panel> - <Panel activePanel={panelId} panelId={'ConnectionStatusLog'} onToggle={this.onTogglePanel} title={"Connection Status Log"}> - <ConnectionStatusLog /> - </Panel> + <AppBar position="static"> + <Tabs value={activePanelId} onChange={this.onHandleTabChange} aria-label="simple tabs example"> + <Tab label="Network Elements" value="NetworkElements" /> + <Tab label="Connection Status Log" value="ConnectionStatusLog" /> + </Tabs> + </AppBar> + {activePanelId === 'NetworkElements' + ? <NetworkElementsList /> + : activePanelId === 'ConnectionStatusLog' + ? <ConnectionStatusLog /> + : null} </> ); }; - public componentDidMount() { - this.onTogglePanel("NetworkElements"); - this.props.networkElementsActions.onToggleFilter(); - this.props.connectionStatusLogActions.onToggleFilter(); - } + + } export const ConnectApplication = (connect(mapProps, mapDispatcher)(ConnectApplicationComponent)); diff --git a/sdnr/wt/odlux/apps/connectApp/webpack.config.js b/sdnr/wt/odlux/apps/connectApp/webpack.config.js index aa3acf00c..b72f5da76 100644 --- a/sdnr/wt/odlux/apps/connectApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/connectApp/webpack.config.js @@ -126,23 +126,23 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/database/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/restconf/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/help/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/websocket": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", ws: true, changeOrigin: true, secure: false diff --git a/sdnr/wt/odlux/apps/demoApp/package.json b/sdnr/wt/odlux/apps/demoApp/package.json index f692d69ed..b5857099b 100644 --- a/sdnr/wt/odlux/apps/demoApp/package.json +++ b/sdnr/wt/odlux/apps/demoApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/eventLogApp/package.json b/sdnr/wt/odlux/apps/eventLogApp/package.json index 2594debc1..ce8b8859d 100644 --- a/sdnr/wt/odlux/apps/eventLogApp/package.json +++ b/sdnr/wt/odlux/apps/eventLogApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/package.json b/sdnr/wt/odlux/apps/faultApp/package.json index 909626303..b922df351 100644 --- a/sdnr/wt/odlux/apps/faultApp/package.json +++ b/sdnr/wt/odlux/apps/faultApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/src/actions/panelChangeActions.ts b/sdnr/wt/odlux/apps/faultApp/src/actions/panelChangeActions.ts index f032c139a..58da19d46 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/actions/panelChangeActions.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/actions/panelChangeActions.ts @@ -24,3 +24,7 @@ export class SetPanelAction extends Action { } } +export const setPanelAction = (panelId: PanelId) => { + return new SetPanelAction(panelId); +} + diff --git a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx index fd1c48ac5..5adc9d49c 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx @@ -33,13 +33,13 @@ import { PanelId } from '../models/panelId'; import { createCurrentProblemsProperties, createCurrentProblemsActions, currentProblemsReloadAction } from '../handlers/currentProblemsHandler'; import { createAlarmLogEntriesProperties, createAlarmLogEntriesActions, alarmLogEntriesReloadAction } from '../handlers/alarmLogEntriesHandler'; -import { SetPanelAction } from '../actions/panelChangeActions'; -import { Tooltip, IconButton } from '@material-ui/core'; +import { setPanelAction } from '../actions/panelChangeActions'; +import { Tooltip, IconButton, AppBar, Tabs, Tab } from '@material-ui/core'; import RefreshIcon from '@material-ui/icons/Refresh'; import ClearStuckAlarmsDialog, { ClearStuckAlarmsDialogMode } from '../components/clearStuckAlarmsDialog'; const mapProps = (state: IApplicationStoreState) => ({ - activePanel: state.fault.currentOpenPanel, + panelId: state.fault.currentOpenPanel, currentProblemsProperties: createCurrentProblemsProperties(state), faultNotifications: state.fault.faultNotifications, alarmLogEntriesProperties: createAlarmLogEntriesProperties(state) @@ -50,7 +50,9 @@ const mapDisp = (dispatcher: IDispatcher) => ({ alarmLogEntriesActions: createAlarmLogEntriesActions(dispatcher.dispatch), reloadCurrentProblems: () => dispatcher.dispatch(currentProblemsReloadAction), reloadAlarmLogEntries: () => dispatcher.dispatch(alarmLogEntriesReloadAction), - setCurrentPanel: (panelId: PanelId) => dispatcher.dispatch(new SetPanelAction(panelId)), + switchActivePanel: (panelId: PanelId) => { + dispatcher.dispatch(setPanelAction(panelId)); + } }); type FaultApplicationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp>; @@ -84,6 +86,29 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen this.setState({ clearAlarmDialogMode: ClearStuckAlarmsDialogMode.Show, stuckAlarms: stuckAlarms }) } + private onHandleTabChange = (event: React.ChangeEvent<{}>, newValue: PanelId) => { + this.props.switchActivePanel(newValue); + //this.onToggleTabs(newValue); + } + + private onToggleTabs = (panelId: PanelId) => { + const nextActivePanel = panelId; + this.props.switchActivePanel(nextActivePanel); + switch (nextActivePanel) { + case 'CurrentProblem': + this.props.reloadCurrentProblems(); + break; + case 'AlarmLog': + this.props.reloadAlarmLogEntries(); + break; + case 'AlarmNotifications': + case null: + default: + // nothing to do + break; + } + }; + render(): JSX.Element { @@ -94,31 +119,19 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen const areFaultsAvailable = this.props.currentProblemsProperties.rows && this.props.currentProblemsProperties.rows.length > 0 const customAction = areFaultsAvailable ? [refreshButton] : []; - const { activePanel } = this.props; - - const onTogglePanel = (panelId: PanelId) => { - const nextActivePanel = panelId === this.props.activePanel ? null : panelId; - this.props.setCurrentPanel(nextActivePanel); - - switch (nextActivePanel) { - case 'CurrentProblem': - this.props.reloadCurrentProblems(); - break; - case 'AlarmLog': - this.props.reloadAlarmLogEntries(); - break; - case 'AlarmNotifications': - case null: - default: - // nothing to do - break; - } - }; + const { panelId: activePanelId } = this.props; return ( <> - <Panel activePanel={activePanel} panelId={'CurrentProblem'} onToggle={onTogglePanel} title={'Current Problem List'}> - <FaultTable idProperty={'id'} customActionButtons={customAction} columns={[ + <AppBar position="static" > + <Tabs value={activePanelId} onChange={this.onHandleTabChange} aria-label="fault tabs"> + <Tab label="Current Problem List" value="CurrentProblem" /> + <Tab label={`Alarm Notifications (${this.props.faultNotifications.faults.length})`} value="AlarmNotifications" /> + <Tab label="Alarm Log" value="AlarmLog" /> + </Tabs> + </AppBar> + { + activePanelId === 'CurrentProblem' && <FaultTable stickyHeader idProperty={'id'} customActionButtons={customAction} columns={[ { property: "icon", title: "", type: ColumnType.custom, customControl: this.renderIcon }, { property: "timestamp", type: ColumnType.text, title: "Time Stamp" }, { property: "nodeId", title: "Node Name", type: ColumnType.text }, @@ -127,9 +140,10 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen { property: "problem", title: "Alarm Type", type: ColumnType.text }, { property: "severity", title: "Severity", type: ColumnType.text, width: "140px" }, ]} {...this.props.currentProblemsProperties} {...this.props.currentProblemsActions} /> - </Panel> - <Panel activePanel={activePanel} panelId={'AlarmNotifications'} onToggle={onTogglePanel} title={`Alarm Notifications ${this.props.faultNotifications.faults.length} since ${this.props.faultNotifications.since}`}> - <FaultAlarmNotificationTable rows={this.props.faultNotifications.faults} asynchronus columns={[ + } + {activePanelId === 'AlarmNotifications' && + + <FaultAlarmNotificationTable stickyHeader rows={this.props.faultNotifications.faults} asynchronus columns={[ { property: "icon", title: "", type: ColumnType.custom, customControl: this.renderIcon }, { property: "timeStamp", title: "Time Stamp" }, { property: "nodeName", title: "Node Name" }, @@ -138,29 +152,35 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen { property: "problem", title: "Alarm Type" }, { property: "severity", title: "Severity", width: "140px" }, ]} idProperty={'id'} /> - </Panel> - <Panel activePanel={activePanel} panelId={'AlarmLog'} onToggle={onTogglePanel} title={'Alarm Log'}> - <FaultTable idProperty={'id'} columns={[ - { property: "icon", title: "", type: ColumnType.custom, customControl: this.renderIcon }, - { property: "timestamp", title: "Time Stamp" }, - { property: "nodeId", title: "Node Name" }, - { property: "counter", title: "Count", type: ColumnType.numeric, width: "100px" }, - { property: "objectId", title: "Object Id" }, - { property: "problem", title: "Alarm Type" }, - { property: "severity", title: "Severity", width: "140px" }, - { property: "sourceType", title: "Source", width: "140px" }, - ]} {...this.props.alarmLogEntriesProperties} {...this.props.alarmLogEntriesActions} /> - </Panel> - { - this.state.clearAlarmDialogMode !== ClearStuckAlarmsDialogMode.None && <ClearStuckAlarmsDialog mode={this.state.clearAlarmDialogMode} numberDevices={this.state.stuckAlarms.length} stuckAlarms={this.state.stuckAlarms} onClose={this.onDialogClose} /> } + {activePanelId === 'AlarmLog' && <FaultTable stickyHeader idProperty={'id'} columns={[ + { property: "icon", title: "", type: ColumnType.custom, customControl: this.renderIcon }, + { property: "timestamp", title: "Time Stamp" }, + { property: "nodeId", title: "Node Name" }, + { property: "counter", title: "Count", type: ColumnType.numeric, width: "100px" }, + { property: "objectId", title: "Object Id" }, + { property: "problem", title: "Alarm Type" }, + { property: "severity", title: "Severity", width: "140px" }, + { property: "sourceType", title: "Source", width: "140px" }, + ]} {...this.props.alarmLogEntriesProperties} {...this.props.alarmLogEntriesActions} /> + + } + { + this.state.clearAlarmDialogMode !== ClearStuckAlarmsDialogMode.None && <ClearStuckAlarmsDialog mode={this.state.clearAlarmDialogMode} numberDevices={this.state.stuckAlarms.length} stuckAlarms={this.state.stuckAlarms} onClose={this.onDialogClose} /> + } </> - ); + ) + }; public componentDidMount() { + + if (this.props.panelId === null) { //don't change tabs, if one is selected already + this.onToggleTabs("CurrentProblem"); + } + this.props.alarmLogEntriesActions.onToggleFilter(); this.props.currentProblemsActions.onToggleFilter(); } diff --git a/sdnr/wt/odlux/apps/faultApp/webpack.config.js b/sdnr/wt/odlux/apps/faultApp/webpack.config.js index 66926edfb..c91b1f4cc 100644 --- a/sdnr/wt/odlux/apps/faultApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/faultApp/webpack.config.js @@ -125,23 +125,23 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:28181/", + target: "http://localhost:48181", secure: false }, "/database/": { - target: "http://10.20.6.29:28181/", + target: "http://localhost:48181", secure: false }, "/restconf/": { - target: "http://10.20.6.29:28181/", + target: "http://localhost:48181", secure: false }, "/help/": { - target: "http://10.20.6.29:28181/", + target: "http://localhost:48181", secure: false }, "/websocket/": { - target: "http://10.20.6.29:28181/", + target: "http://localhost:48181", ws: true, changeOrigin: true, secure: false diff --git a/sdnr/wt/odlux/apps/helpApp/package.json b/sdnr/wt/odlux/apps/helpApp/package.json index 1f106ab65..2a331f68a 100644 --- a/sdnr/wt/odlux/apps/helpApp/package.json +++ b/sdnr/wt/odlux/apps/helpApp/package.json @@ -32,14 +32,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/inventoryApp/package.json b/sdnr/wt/odlux/apps/inventoryApp/package.json index 9e004c112..929ca0fb4 100644 --- a/sdnr/wt/odlux/apps/inventoryApp/package.json +++ b/sdnr/wt/odlux/apps/inventoryApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/package.json b/sdnr/wt/odlux/apps/maintenanceApp/package.json index 96f9f7d2b..edd582744 100644 --- a/sdnr/wt/odlux/apps/maintenanceApp/package.json +++ b/sdnr/wt/odlux/apps/maintenanceApp/package.json @@ -28,14 +28,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx b/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx index 3b7879351..f557e5399 100644 --- a/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx +++ b/sdnr/wt/odlux/apps/maintenanceApp/src/views/maintenenceView.tsx @@ -37,7 +37,7 @@ import { MaintenenceEntry, spoofSymbol } from '../models/maintenenceEntryType'; import EditMaintenenceEntryDialog, { EditMaintenenceEntryDialogMode } from '../components/editMaintenenceEntryDialog'; import { convertToLocaleString } from '../utils/timeUtils'; -import { createmaintenanceEntriesActions, createmaintenanceEntriesProperties, maintenanceEntriesReloadAction } from '../handlers/maintenenceEntriesHandler'; +import { createmaintenanceEntriesActions, createmaintenanceEntriesProperties,maintenanceEntriesReloadAction } from '../handlers/maintenenceEntriesHandler'; const styles = (theme: Theme) => createStyles({ button: { @@ -60,7 +60,7 @@ const mapProps = (state: IApplicationStoreState) => ({ const mapDispatcher = (dispatcher: IDispatcher) => ({ maintenanceEntriesActions: createmaintenanceEntriesActions(dispatcher.dispatch), - onLoadMaintenanceEntries: async () => { + onLoadMaintenanceEntries: async() => { await dispatcher.dispatch(maintenanceEntriesReloadAction) } }); @@ -104,8 +104,8 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP this.setState({ maintenenceEntryToEdit: { ...emptyMaintenenceEntry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), }, maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.AddMaintenenceEntry }); @@ -120,7 +120,7 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP { property: "notifications", title: "Notification", width: 50, align: "center", type: ColumnType.custom, customControl: ({ rowData }) => ( rowData.active && (Date.parse(rowData.start).valueOf() <= now) && (Date.parse(rowData.end).valueOf() >= now) && <FontAwesomeIcon icon={faBan} /> || null - ) + ) }, { property: "active", title: "Activation State", type: ColumnType.boolean, labels: { "true": "active", "false": "not active" }, }, { property: "start", title: "Start Date (UTC)", type: ColumnType.text }, @@ -140,7 +140,7 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP ) }, ] - } idProperty={'_id'}{...this.props.maintenanceEntriesActions} {...this.props.maintenanceEntriesProperties} asynchronus > </MaintenenceEntriesTable> + } idProperty={'_id'}{...this.props.maintenanceEntriesActions} {...this.props.maintenanceEntriesProperties} asynchronus > </MaintenenceEntriesTable> <EditMaintenenceEntryDialog initialMaintenenceEntry={this.state.maintenenceEntryToEdit} mode={this.state.maintenenceEntryEditorMode} onClose={this.onCloseEditMaintenenceEntryDialog} /> </> @@ -160,8 +160,8 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP this.setState({ maintenenceEntryToEdit: { ...entry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), }, maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry }); @@ -175,8 +175,8 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP this.setState({ maintenenceEntryToEdit: { ...entry, - start: convertToLocaleString(startTime), - end: convertToLocaleString(endTime), + start: convertToLocaleString(startTime), + end: convertToLocaleString(endTime), }, maintenenceEntryEditorMode: EditMaintenenceEntryDialogMode.EditMaintenenceEntry }); @@ -190,7 +190,7 @@ class MaintenenceViewComponent extends React.Component<MaintenenceViewComponentP this.setState({ maintenenceEntryToEdit: { ...entry, - ...(entry.start && endTime) + ...(entry.start && endTime) ? { start: convertToLocaleString(entry.start), end: convertToLocaleString(entry.end) } : { start: convertToLocaleString(startTime), end: convertToLocaleString(endTime) } }, diff --git a/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js b/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js index e6d968564..33a3bed73 100644 --- a/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/maintenanceApp/webpack.config.js @@ -127,23 +127,23 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:48181", secure: false }, "/database/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:48181", secure: false }, "/restconf/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:48181", secure: false }, "/help/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:48181", secure: false }, "/websocket/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:48181", ws: true, changeOrigin: true, secure: false diff --git a/sdnr/wt/odlux/apps/mediatorApp/package.json b/sdnr/wt/odlux/apps/mediatorApp/package.json index 718d2fd03..cfd4bd9e9 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/package.json +++ b/sdnr/wt/odlux/apps/mediatorApp/package.json @@ -28,14 +28,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js b/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js index 3efe2d015..94943ecd5 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/mediatorApp/webpack.config.js @@ -127,29 +127,19 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:3000", secure: false }, "/database/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:3000", secure: false }, "/restconf/": { - target: "http://10.20.6.29:28181", + target: "http://localhost:3000", secure: false }, "/help/": { - target: "http://10.20.6.29:28181", - secure: false - }, - "/ms/": { - target: "http://10.20.6.29:28181", - secure: false - }, - "/websocket": { - target: "http://10.20.6.29:28181", - ws: true, - changeOrigin: true, + target: "http://localhost:3000", secure: false } } diff --git a/sdnr/wt/odlux/apps/minimumApp/package.json b/sdnr/wt/odlux/apps/minimumApp/package.json index d9b18a3ce..5a8352e4b 100644 --- a/sdnr/wt/odlux/apps/minimumApp/package.json +++ b/sdnr/wt/odlux/apps/minimumApp/package.json @@ -27,14 +27,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/package.json b/sdnr/wt/odlux/apps/performanceHistoryApp/package.json index 1e6adf7c3..e1ca8013b 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/package.json +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/package.json @@ -30,14 +30,14 @@ "@types/react": "16.9.11", "@types/react-dom": "16.9.4", "@types/react-router-dom": "4.3.1", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", "@types/jquery": "3.3.10", "jquery": "3.3.1", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1" } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/webpack.config.js b/sdnr/wt/odlux/apps/performanceHistoryApp/webpack.config.js index 9c2414864..bbbc3e43e 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/webpack.config.js +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/webpack.config.js @@ -126,15 +126,15 @@ module.exports = (env) => { }, proxy: { "/oauth2/": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/restconf": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false }, "/database": { - target: "http://10.20.6.29:48181", + target: "http://localhost:48181", secure: false } } diff --git a/sdnr/wt/odlux/framework/package.json b/sdnr/wt/odlux/framework/package.json index d0fe49b57..c94568857 100644 --- a/sdnr/wt/odlux/framework/package.json +++ b/sdnr/wt/odlux/framework/package.json @@ -25,17 +25,17 @@ "license": "Apache-2.0",
"peerDependencies": {
"@types/node": "11.9.5",
- "@types/react": "16.9.11",
- "@types/react-dom": "16.9.4",
+ "@types/react": "16.9.19",
+ "@types/react-dom": "16.9.5",
"@types/react-router-dom": "4.3.1",
- "@material-ui/core": "4.6.1",
+ "@material-ui/core": "4.9.0",
"@material-ui/icons": "4.5.1",
"@types/classnames": "2.2.6",
"@types/flux": "3.1.8",
"@types/jquery": "3.3.10",
"jquery": "3.3.1",
- "react": "16.11.0",
- "react-dom": "16.11.0",
+ "react": "16.12.0",
+ "react-dom": "16.12.0",
"react-router-dom": "4.3.1",
"@fortawesome/react-fontawesome": "0.1.3",
"@fortawesome/fontawesome-svg-core": "1.2.12",
diff --git a/sdnr/wt/odlux/framework/pom.xml b/sdnr/wt/odlux/framework/pom.xml index 6d80421b8..39856c5c0 100644 --- a/sdnr/wt/odlux/framework/pom.xml +++ b/sdnr/wt/odlux/framework/pom.xml @@ -46,7 +46,7 @@ <properties> <buildtime>${maven.build.timestamp}</buildtime> <distversion>ONAP Frankfurt (Neon, mdsal ${odl.mdsal.version})</distversion> - <buildno>39.0e1988b(20/01/12)</buildno> + <buildno>40.4a1f067(20/02/11)</buildno> <odlux.version>ONAP SDN-R | ONF Wireless for ${distversion} - Build: ${buildtime} ${buildno} ${project.version}</odlux.version> </properties> diff --git a/sdnr/wt/odlux/framework/src/components/material-table/index.tsx b/sdnr/wt/odlux/framework/src/components/material-table/index.tsx index 520674441..b85319b40 100644 --- a/sdnr/wt/odlux/framework/src/components/material-table/index.tsx +++ b/sdnr/wt/odlux/framework/src/components/material-table/index.tsx @@ -21,6 +21,7 @@ import { withStyles, WithStyles, createStyles, Theme } from '@material-ui/core/s import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; +import TableContainer from '@material-ui/core/TableContainer'; import TablePagination from '@material-ui/core/TablePagination'; import TableRow from '@material-ui/core/TableRow'; import Paper from '@material-ui/core/Paper'; @@ -31,10 +32,13 @@ import { EnhancedTableHead } from './tableHead'; import { EnhancedTableFilter } from './tableFilter'; import { ColumnModel, ColumnType } from './columnModel'; -import { Omit } from '@material-ui/core'; +import { Omit, Menu } from '@material-ui/core'; + import { SvgIconProps } from '@material-ui/core/SvgIcon/SvgIcon'; -import { replaceHyphen } from '../../utilities/yangHelper'; -import { string } from 'prop-types'; + +import { DividerTypeMap } from '@material-ui/core/Divider'; +import { MenuItemProps } from '@material-ui/core/MenuItem'; +import { flexbox } from '@material-ui/system'; export { ColumnModel, ColumnType } from './columnModel'; type propType = string | number | null | undefined | (string | number)[]; @@ -70,14 +74,19 @@ function getSorting(order: 'asc' | 'desc' | null, orderBy: string) { const styles = (theme: Theme) => createStyles({ root: { width: '100%', + overflow: "hidden", marginTop: theme.spacing(3), + position: "relative", + boxSizing: "border-box", + display: "flex", + flexDirection: "column", }, - table: { - minWidth: 1020, - }, - tableWrapper: { - overflowX: 'auto', + container: { + flex: "1 1 100%" }, + pagination: { + overflow: "hidden" + } }); export type MaterialTableComponentState<TData = {}> = { @@ -100,11 +109,13 @@ type MaterialTableComponentBaseProps<TData> = WithStyles<typeof styles> & { idProperty: keyof TData | ((data: TData) => React.Key); tableId?: string; title?: string; + stickyHeader?: boolean; enableSelection?: boolean; disableSorting?: boolean; disableFilter?: boolean; customActionButtons?: { icon: React.ComponentType<SvgIconProps>, tooltip?: string, onClick: () => void }[]; onHandleClick?(event: React.MouseEvent<HTMLTableRowElement>, rowData: TData): void; + createContextMenu?: (row: TData) => React.ReactElement<MenuItemProps | DividerTypeMap<{}, "hr">, React.ComponentType<MenuItemProps | DividerTypeMap<{}, "hr" >>>[]; }; type MaterialTableComponentPropsWithRows<TData = {}> = MaterialTableComponentBaseProps<TData> & { rows: TData[]; asynchronus?: boolean; }; @@ -139,7 +150,7 @@ function isMaterialTableComponentPropsWithRowsAndRequestData(props: MaterialTabl propsWithExternalState.onHandleRequestSort instanceof Function } -class MaterialTableComponent<TData extends {} = {}> extends React.Component<MaterialTableComponentProps, MaterialTableComponentState> { +class MaterialTableComponent<TData extends {} = {}> extends React.Component<MaterialTableComponentProps, MaterialTableComponentState & { contextMenuInfo: { index: number; mouseX?: number; mouseY?: number }; }> { constructor(props: MaterialTableComponentProps) { super(props); @@ -148,6 +159,7 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate const rowsPerPage = isMaterialTableComponentPropsWithRowsAndRequestData(this.props) ? this.props.rowsPerPage || 10 : 10; this.state = { + contextMenuInfo: {index : -1 }, filter: isMaterialTableComponentPropsWithRowsAndRequestData(this.props) ? this.props.filter || {} : {}, showFilter: isMaterialTableComponentPropsWithRowsAndRequestData(this.props) ? this.props.showFilter : false, loading: isMaterialTableComponentPropsWithRowsAndRequestData(this.props) ? this.props.loading : false, @@ -176,10 +188,10 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate const toggleFilter = isMaterialTableComponentPropsWithRowsAndRequestData(this.props) ? this.props.onToggleFilter : () => { !this.props.disableFilter && this.setState({ showFilter: !showFilter }, this.update) } return ( <Paper className={classes.root}> - <TableToolbar tableId={this.props.tableId} numSelected={selected && selected.length} title={this.props.title} customActionButtons={this.props.customActionButtons} onExportToCsv={this.exportToCsv} - onToggleFilter={toggleFilter} /> - <div className={classes.tableWrapper}> - <Table className={classes.table} aria-label={this.props.tableId ? this.props.tableId : 'tableTitle'}> + <TableContainer className={classes.container}> + <TableToolbar tableId={this.props.tableId} numSelected={selected && selected.length} title={this.props.title} customActionButtons={this.props.customActionButtons} onExportToCsv={this.exportToCsv} + onToggleFilter={toggleFilter} /> + <Table aria-label={this.props.tableId ? this.props.tableId : 'tableTitle'} stickyHeader={this.props.stickyHeader || false} > <EnhancedTableHead columns={columns} numSelected={selected && selected.length} @@ -196,10 +208,27 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate .map((entry: TData & { [key: string]: any }, index) => { const entryId = getId(entry); const isSelected = this.isSelected(entryId); + const contextMenu = (this.props.createContextMenu && this.state.contextMenuInfo.index === index && this.props.createContextMenu(entry)) || null; return ( <TableRow hover - onClick={event => this.handleClick(event, entry, entryId)} + onClick={event => { + if (this.props.createContextMenu) { + this.setState({ + contextMenuInfo: { + index: -1 + } + }); + } + this.handleClick(event, entry, entryId); + }} + onContextMenu={event => { + if (this.props.createContextMenu) { + event.preventDefault(); + event.stopPropagation(); + this.setState({ contextMenuInfo: { index, mouseX: event.clientX - 2, mouseY: event.clientY - 4 } }); + } + }} role="checkbox" aria-checked={isSelected} aria-label={`${(this.props.tableId ? this.props.tableId : 'table')}-row-${(index + 1)}`} @@ -230,6 +259,10 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate } ) } + {<Menu open={!!contextMenu} onClose={() => this.setState({ contextMenuInfo: { index: -1 } })} anchorReference="anchorPosition" keepMounted + anchorPosition={this.state.contextMenuInfo.mouseY != null && this.state.contextMenuInfo.mouseX != null ? { top: this.state.contextMenuInfo.mouseY, left: this.state.contextMenuInfo.mouseX } : undefined}> + {contextMenu} + </Menu> || null} </TableRow> ); })} @@ -240,8 +273,8 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate )} </TableBody> </Table> - </div> - <TablePagination + </TableContainer> + <TablePagination className={classes.pagination} rowsPerPageOptions={[5, 10, 20, 50]} component="div" count={rowCount} @@ -489,7 +522,7 @@ class MaterialTableComponent<TData extends {} = {}> extends React.Component<Mate let csv: string[] = []; if (isMaterialTableComponentPropsWithRequestData(this.props)) { - // table with extra request handler + // table with extra request handler this.setState({ loading: true }); const result = await Promise.resolve( this.props.onRequestData(0, 1000, this.state.orderBy, this.state.order, this.state.showFilter && this.state.filter || {}) diff --git a/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx b/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx index 00d43d99c..fee51621e 100644 --- a/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx +++ b/sdnr/wt/odlux/framework/src/components/navigationMenu.tsx @@ -40,7 +40,7 @@ const styles = (theme: Theme) => createStyles({ position: 'relative',
width: drawerWidth,
},
- toolbar: theme.mixins.toolbar,
+ toolbar: theme.mixins.toolbar as any,
drawerOpen: {
width: drawerWidth,
transition: theme.transitions.create('width', {
diff --git a/sdnr/wt/odlux/framework/src/components/routing/appFrame.tsx b/sdnr/wt/odlux/framework/src/components/routing/appFrame.tsx index e6af2eb5d..d212257c8 100644 --- a/sdnr/wt/odlux/framework/src/components/routing/appFrame.tsx +++ b/sdnr/wt/odlux/framework/src/components/routing/appFrame.tsx @@ -1,20 +1,20 @@ -/** - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt odlux - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ +/**
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt odlux
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ */
import * as React from 'react';
import connect, { Connect } from '../../flux/connect';
@@ -38,7 +38,7 @@ export class AppFrame extends React.Component<IAppFrameProps & Connect> { public render(): JSX.Element {
return (
- <div style={{ flex: "1", overflow: "auto", display: "flex", flexDirection: "column" }}>
+ <div style={{ flex: "1", overflow: "hidden", display: "flex", flexDirection: "column" }}>
{ this.props.children }
</div>
)
diff --git a/sdnr/wt/odlux/framework/src/services/forceLogoutService.ts b/sdnr/wt/odlux/framework/src/services/forceLogoutService.ts index ce4faab6b..0c7c38dff 100644 --- a/sdnr/wt/odlux/framework/src/services/forceLogoutService.ts +++ b/sdnr/wt/odlux/framework/src/services/forceLogoutService.ts @@ -27,11 +27,16 @@ let tickTimer = 15; export const startForceLogoutService = (store: ApplicationStore) => { applicationStore = store; - createForceLogoutInterval(); + if (process.env.NODE_ENV === "development") { + console.warn("logout timer not started in development mode"); + } else { + createForceLogoutInterval(); + } + }; const createForceLogoutInterval = () => { - console.log("logout timer running...") + console.log("logout timer running..."); return setInterval(function () { if (applicationStore && applicationStore.state.framework.authenticationState.user) { diff --git a/sdnr/wt/odlux/framework/src/services/notificationService.ts b/sdnr/wt/odlux/framework/src/services/notificationService.ts index 85d3f716b..c90da0946 100644 --- a/sdnr/wt/odlux/framework/src/services/notificationService.ts +++ b/sdnr/wt/odlux/framework/src/services/notificationService.ts @@ -179,10 +179,13 @@ export const startWebsocketSession = () => { }
export const endWebsocketSession = () => {
- socketReady.then(websocket => {
- websocket.close();
- userLoggedOut = true;
- })
+ if (socketReady) {
+ socketReady.then(websocket => {
+ websocket.close();
+ userLoggedOut = true;
+ });
+ }
+
}
diff --git a/sdnr/wt/odlux/framework/src/views/frame.tsx b/sdnr/wt/odlux/framework/src/views/frame.tsx index b93b7ee01..f2f6f66cc 100644 --- a/sdnr/wt/odlux/framework/src/views/frame.tsx +++ b/sdnr/wt/odlux/framework/src/views/frame.tsx @@ -52,7 +52,7 @@ const styles = (theme: Theme) => createStyles({ padding: theme.spacing(3),
minWidth: 0, // So the Typography noWrap works
},
- toolbar: theme.mixins.toolbar
+ toolbar: theme.mixins.toolbar as any
});
type FrameProps = WithStyles<typeof styles>;
diff --git a/sdnr/wt/odlux/framework/webpack.config.js b/sdnr/wt/odlux/framework/webpack.config.js index 93b748d73..e43539dc7 100644 --- a/sdnr/wt/odlux/framework/webpack.config.js +++ b/sdnr/wt/odlux/framework/webpack.config.js @@ -190,12 +190,26 @@ module.exports = (env) => { colors: true
},
proxy: {
- "/oauth2/**/*": {
- target: "http://172.18.0.3:8181",
+ "/oauth2/": {
+ target: "http://localhost:48181",
secure: false
},
- "/about": {
- target: "http://172.18.0.3:8181",
+ "/database/": {
+ target: "http://localhost:48181",
+ secure: false
+ },
+ "/restconf/": {
+ target: "http://localhost:48181",
+ secure: false
+ },
+ "/help/": {
+ target: "http://localhost:48181",
+ secure: false
+ },
+ "/websocket": {
+ target: "http://localhost:48181",
+ ws: true,
+ changeOrigin: true,
secure: false
}
}
diff --git a/sdnr/wt/odlux/package.json b/sdnr/wt/odlux/package.json index 5d4714dac..c6acd563c 100644 --- a/sdnr/wt/odlux/package.json +++ b/sdnr/wt/odlux/package.json @@ -14,7 +14,7 @@ "@fortawesome/fontawesome-svg-core": "1.2.12", "@fortawesome/free-solid-svg-icons": "5.6.3", "@fortawesome/react-fontawesome": "0.1.3", - "@material-ui/core": "4.6.1", + "@material-ui/core": "4.9.0", "@material-ui/icons": "4.5.1", "@types/classnames": "2.2.6", "@types/flux": "3.1.8", @@ -27,13 +27,15 @@ "@types/react-transition-group": "2.0.15", "@types/x2js": "3.1.0", "classnames": "2.2.6", + "csstype": "2.6.8", "jquery": "3.3.1", "jsonwebtoken": "8.3.0", + "jss": "10.0.3", "lerna": "3.13.1", "notistack": "0.9.6", "prop-types": "15.7.2", - "react": "16.11.0", - "react-dom": "16.11.0", + "react": "16.12.0", + "react-dom": "16.12.0", "react-router-dom": "4.3.1", "react-transition-group": "4.3.0", "x2js": "3.2.3" diff --git a/sdnr/wt/odlux/yarn.lock b/sdnr/wt/odlux/yarn.lock index e828763e5..6dbdefecc 100644 --- a/sdnr/wt/odlux/yarn.lock +++ b/sdnr/wt/odlux/yarn.lock @@ -663,10 +663,10 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@emotion/hash@^0.7.1": - version "0.7.3" - resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.7.3.tgz#a166882c81c0c6040975dd30df24fae8549bd96f" - integrity sha512-14ZVlsB9akwvydAdaEnVnvqu6J2P6ySv39hYyl/aoB6w/V+bXX0tay8cF6paqbgZsN2n5Xh15uF4pE+GvE+itw== +"@emotion/hash@^0.7.4": + version "0.7.4" + resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.7.4.tgz#f14932887422c9056b15a8d222a9074a7dfa2831" + integrity sha512-fxfMSBMX3tlIbKUdtGKxqB1fyrH6gVrX39Gsv3y8lRYKUqlgDt3UMqQyGnR1bQMa2B8aGnhLZokZgg8vT0Le+A== "@fimbul/bifrost@^0.21.0": version "0.21.0" @@ -1334,16 +1334,16 @@ npmlog "^4.1.2" write-file-atomic "^2.3.0" -"@material-ui/core@4.6.1": - version "4.6.1" - resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.6.1.tgz#039f97443547a88c41d290deabfb4a044c6031ec" - integrity sha512-TljDMCJmi1zh7JhAFTp8qjIlbkVACiNftrcitzJJ+hAqpuP9PTO4euEkkAuYjISfUFZl3Z4kaOrBwN1HDrhIOQ== +"@material-ui/core@4.9.0": + version "4.9.0" + resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.9.0.tgz#96ca3281ee06216d44fd4d0e306dbe0429eb2ebe" + integrity sha512-zrrr8mPU5DDBYaVil4uJYauW41PjSn5otn7cqGsmWOY0t90fypr9nNgM7rRJaPz2AP6oRSDx1kBQt2igf5uelg== dependencies: "@babel/runtime" "^7.4.4" - "@material-ui/styles" "^4.6.0" - "@material-ui/system" "^4.5.2" - "@material-ui/types" "^4.1.1" - "@material-ui/utils" "^4.5.2" + "@material-ui/styles" "^4.9.0" + "@material-ui/system" "^4.7.1" + "@material-ui/types" "^5.0.0" + "@material-ui/utils" "^4.7.1" "@types/react-transition-group" "^4.2.0" clsx "^1.0.2" convert-css-length "^2.0.1" @@ -1351,6 +1351,7 @@ normalize-scroll-left "^0.2.0" popper.js "^1.14.1" prop-types "^15.7.2" + react-is "^16.8.0" react-transition-group "^4.3.0" "@material-ui/icons@4.5.1": @@ -1360,52 +1361,50 @@ dependencies: "@babel/runtime" "^7.4.4" -"@material-ui/styles@^4.6.0": - version "4.6.0" - resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.6.0.tgz#15679fab6dcbe0cc2416f01a22966f3ea26607c5" - integrity sha512-lqqh4UEMdIYcU1Yth4pQyMTah02uAkg3NOT3MirN9FUexdL8pNA6zCHigEgDSfwmvnXyxHhxTkphfy0DRfnt9w== +"@material-ui/styles@^4.9.0": + version "4.9.0" + resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.9.0.tgz#10c31859f6868cfa9d3adf6b6c3e32c9d676bc76" + integrity sha512-nJHum4RqYBPWsjL/9JET8Z02FZ9gSizlg/7LWVFpIthNzpK6OQ5OSRR4T4x9/p+wK3t1qNn3b1uI4XpnZaPxOA== dependencies: "@babel/runtime" "^7.4.4" - "@emotion/hash" "^0.7.1" - "@material-ui/types" "^4.1.1" - "@material-ui/utils" "^4.5.2" + "@emotion/hash" "^0.7.4" + "@material-ui/types" "^5.0.0" + "@material-ui/utils" "^4.7.1" clsx "^1.0.2" csstype "^2.5.2" hoist-non-react-statics "^3.2.1" - jss "^10.0.0" - jss-plugin-camel-case "^10.0.0" - jss-plugin-default-unit "^10.0.0" - jss-plugin-global "^10.0.0" - jss-plugin-nested "^10.0.0" - jss-plugin-props-sort "^10.0.0" - jss-plugin-rule-value-function "^10.0.0" - jss-plugin-vendor-prefixer "^10.0.0" + jss "^10.0.3" + jss-plugin-camel-case "^10.0.3" + jss-plugin-default-unit "^10.0.3" + jss-plugin-global "^10.0.3" + jss-plugin-nested "^10.0.3" + jss-plugin-props-sort "^10.0.3" + jss-plugin-rule-value-function "^10.0.3" + jss-plugin-vendor-prefixer "^10.0.3" prop-types "^15.7.2" -"@material-ui/system@^4.5.2": - version "4.5.2" - resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.5.2.tgz#7143bd8422a3f33f435c23f378136254004bbd60" - integrity sha512-h9RWvdM9XKlHHqwiuhyvWdobptQkHli+m2jJFs7i1AI/hmGsIc4reDmS7fInhETgt/Txx7uiAIznfRNIIVHmQw== +"@material-ui/system@^4.7.1": + version "4.7.1" + resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.7.1.tgz#d928dacc0eeae6bea569ff3ee079f409efb3517d" + integrity sha512-zH02p+FOimXLSKOW/OT2laYkl9bB3dD1AvnZqsHYoseUaq0aVrpbl2BGjQi+vJ5lg8w73uYlt9zOWzb3+1UdMQ== dependencies: "@babel/runtime" "^7.4.4" - "@material-ui/utils" "^4.5.2" + "@material-ui/utils" "^4.7.1" prop-types "^15.7.2" -"@material-ui/types@^4.1.1": - version "4.1.1" - resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-4.1.1.tgz#b65e002d926089970a3271213a3ad7a21b17f02b" - integrity sha512-AN+GZNXytX9yxGi0JOfxHrRTbhFybjUJ05rnsBVjcB+16e466Z0Xe5IxawuOayVZgTBNDxmPKo5j4V6OnMtaSQ== - dependencies: - "@types/react" "*" +"@material-ui/types@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.0.0.tgz#26d6259dc6b39f4c2e1e9aceff7a11e031941741" + integrity sha512-UeH2BuKkwDndtMSS0qgx1kCzSMw+ydtj0xx/XbFtxNSTlXydKwzs5gVW5ZKsFlAkwoOOQ9TIsyoCC8hq18tOwg== -"@material-ui/utils@^4.5.2": - version "4.5.2" - resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.5.2.tgz#4c2fb531d357cf0da8cece53b588dff9b0bde934" - integrity sha512-zhbNfHd1gLa8At6RPDG7uMZubHxbY+LtM6IkSfeWi6Lo4Ax80l62YaN1QmUpO1IvGCkn/j62tQX3yObiQZrJsQ== +"@material-ui/utils@^4.7.1": + version "4.7.1" + resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.7.1.tgz#dc16c7f0d2cd02fbcdd5cfe601fd6863ae3cc652" + integrity sha512-+ux0SlLdlehvzCk2zdQ3KiS3/ylWvuo/JwAGhvb8dFVvwR21K28z0PU9OQW2PGogrMEdvX3miEI5tGxTwwWiwQ== dependencies: "@babel/runtime" "^7.4.4" prop-types "^15.7.2" - react-is "^16.8.6" + react-is "^16.8.0" "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" @@ -1420,10 +1419,17 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== +"@octokit/auth-token@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f" + integrity sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg== + dependencies: + "@octokit/types" "^2.0.0" + "@octokit/endpoint@^5.5.0": - version "5.5.1" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.1.tgz#2eea81e110ca754ff2de11c79154ccab4ae16b3f" - integrity sha512-nBFhRUb5YzVTCX/iAK1MgQ4uWo89Gu0TH00qQHoYRCsE12dWcG1OiLd7v2EIo2+tpUKPMOQ62QFy9hy9Vg2ULg== + version "5.5.2" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.2.tgz#ed19d01fe85ac58bc2b774661658f9e5429b8164" + integrity sha512-ICDcRA0C2vtTZZGud1nXRrBLXZqFayodXAKZfo3dkdcLNqcHsgaz3YSTupbURusYeucSVRjjG+RTcQhx6HPPcg== dependencies: "@octokit/types" "^2.0.0" is-plain-object "^3.0.0" @@ -1434,10 +1440,30 @@ resolved "https://registry.yarnpkg.com/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-2.2.2.tgz#c0e22067a043e19f96ff9c7832e2a3019f9be75c" integrity sha512-CTZr64jZYhGWNTDGlSJ2mvIlFsm9OEO3LqWn9I/gmoHI4jRBp4kpHoFYNemG4oA75zUAcmbuWblb7jjP877YZw== +"@octokit/plugin-paginate-rest@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz#004170acf8c2be535aba26727867d692f7b488fc" + integrity sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q== + dependencies: + "@octokit/types" "^2.0.1" + +"@octokit/plugin-request-log@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" + integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== + +"@octokit/plugin-rest-endpoint-methods@2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz#3288ecf5481f68c494dd0602fc15407a59faf61e" + integrity sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ== + dependencies: + "@octokit/types" "^2.0.1" + deprecation "^2.3.1" + "@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.0.tgz#a64d2a9d7a13555570cd79722de4a4d76371baaa" - integrity sha512-DNBhROBYjjV/I9n7A8kVkmQNkqFAMem90dSxqvPq57e2hBr7mNTX98y3R2zDpqMQHVRpBDjsvsfIGgBzy+4PAg== + version "1.2.1" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801" + integrity sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA== dependencies: "@octokit/types" "^2.0.0" deprecation "^2.0.0" @@ -1458,10 +1484,14 @@ universal-user-agent "^4.0.0" "@octokit/rest@^16.16.0": - version "16.36.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.36.0.tgz#99892c57ba632c2a7b21845584004387b56c2cb7" - integrity sha512-zoZj7Ya4vWBK4fjTwK2Cnmu7XBB1p9ygSvTk2TthN6DVJXM4hQZQoAiknWFLJWSTix4dnA3vuHtjPZbExYoCZA== - dependencies: + version "16.43.1" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.1.tgz#3b11e7d1b1ac2bbeeb23b08a17df0b20947eda6b" + integrity sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw== + dependencies: + "@octokit/auth-token" "^2.4.0" + "@octokit/plugin-paginate-rest" "^1.1.1" + "@octokit/plugin-request-log" "^1.0.0" + "@octokit/plugin-rest-endpoint-methods" "2.4.0" "@octokit/request" "^5.2.0" "@octokit/request-error" "^1.0.2" atob-lite "^2.0.0" @@ -1475,10 +1505,10 @@ once "^1.4.0" universal-user-agent "^4.0.0" -"@octokit/types@^2.0.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.0.2.tgz#0888497f5a664e28b0449731d5e88e19b2a74f90" - integrity sha512-StASIL2lgT3TRjxv17z9pAqbnI7HGu9DrJlg3sEBFfCLaMEqp+O3IQPUF6EZtQ4xkAu2ml6kMBBCtGxjvmtmuQ== +"@octokit/types@^2.0.0", "@octokit/types@^2.0.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.1.tgz#77e80d1b663c5f1f829e5377b728fa3c4fe5a97d" + integrity sha512-89LOYH+d/vsbDX785NOfLxTW88GjNd0lWRz1DVPVsZgg9Yett5O+3MOvwo7iHgvUwbFz0mf/yPIjBkUbs4kxoQ== dependencies: "@types/node" ">= 8" @@ -1543,9 +1573,9 @@ integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== "@types/node@>= 8": - version "13.1.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.6.tgz#076028d0b0400be8105b89a0a55550c86684ffec" - integrity sha512-Jg1F+bmxcpENHP23sVKkNuU3uaxPnsBMW0cLjleiikFKomJQbsn0Cqk2yDvQArqzZN6ABfBkZ0To7pQ8sLdWDg== + version "13.7.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" + integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== "@types/prop-types@*": version "15.7.3" @@ -3404,7 +3434,7 @@ css-selector-tokenizer@^0.7.0: fastparse "^1.1.1" regexpu-core "^1.0.0" -css-vendor@^2.0.6: +css-vendor@^2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/css-vendor/-/css-vendor-2.0.7.tgz#4e6d53d953c187981576d6a542acc9fb57174bda" integrity sha512-VS9Rjt79+p7M0WkPqcAza4Yq1ZHrsHrwf7hPL/bjQB+c1lwmAI+1FXxYTYt818D/50fFVflw0XKleiBN5RITkg== @@ -3434,6 +3464,11 @@ cssstyle@^1.0.0: dependencies: cssom "0.3.x" +csstype@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.8.tgz#0fb6fc2417ffd2816a418c9336da74d7f07db431" + integrity sha512-msVS9qTuMT5zwAGCVm4mxfrZ18BNc6Csd0oJAtiFMZ1FAx1CCvy2+5MDmYoix63LM/6NDbNtodCiGYGmFgO0dA== + csstype@^2.2.0, csstype@^2.5.2, csstype@^2.6.5, csstype@^2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.7.tgz#20b0024c20b6718f4eda3853a1f5a1cce7f5e4a5" @@ -3642,7 +3677,7 @@ depd@~1.1.2: resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= -deprecation@^2.0.0: +deprecation@^2.0.0, deprecation@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== @@ -4877,9 +4912,9 @@ handlebars@^4.0.3: uglify-js "^3.1.4" handlebars@^4.4.0: - version "4.7.1" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.1.tgz#052bd2618964dcb8aebad0940bfeb2d8d1cfbfde" - integrity sha512-2dd6soo60cwKNJ90VewNLIzdZPR/E2YhszOTgHpN9V0YuwZk7x33/iZoIBnASwDFVHMY7iJ6NPL8d9f/DWYCTA== + version "4.7.3" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.3.tgz#8ece2797826886cf8082d1726ff21d2a022550ee" + integrity sha512-SRGwSYuNfx8DwHD/6InAPzD6RgeruWLT+B8e8a7gGs8FWgHzlExpTFMEq2IA6QpAfOClpKHy6+8IqTjeBCu6Kg== dependencies: neo-async "^2.6.0" optimist "^0.6.1" @@ -6374,69 +6409,69 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -jss-plugin-camel-case@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-camel-case/-/jss-plugin-camel-case-10.0.0.tgz#d601bae2e8e2041cc526add289dcd7062db0a248" - integrity sha512-yALDL00+pPR4FJh+k07A8FeDvfoPPuXU48HLy63enAubcVd3DnS+2rgqPXglHDGixIDVkCSXecl/l5GAMjzIbA== +jss-plugin-camel-case@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-camel-case/-/jss-plugin-camel-case-10.0.3.tgz#ce25f3cdb7f2b80724558361351fe6b644ca9e4f" + integrity sha512-rild/oFKFkmRP7AoiX9D6bdDAUfmJv8c7sEBvFoi+JP31dn2W8nw4txMKGnV1LJKlFkYprdZt1X99Uvztl1hug== dependencies: "@babel/runtime" "^7.3.1" hyphenate-style-name "^1.0.3" - jss "10.0.0" + jss "^10.0.3" -jss-plugin-default-unit@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-default-unit/-/jss-plugin-default-unit-10.0.0.tgz#601caf5f576fc0c66986fbe8a9aa37307a3a3ea3" - integrity sha512-sURozIOdCtGg9ap18erQ+ijndAfEGtTaetxfU3H4qwC18Bi+fdvjlY/ahKbuu0ASs7R/+WKCP7UaRZOjUDMcdQ== +jss-plugin-default-unit@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-default-unit/-/jss-plugin-default-unit-10.0.3.tgz#c4b97b7b18c6cf9e9809e05b8525045decc298d3" + integrity sha512-n+XfVLPF9Qh7IOTdQ8M4oRpjpg6egjr/r0NNytubbCafMgCILJYIVrMTGgOTydH+uvak8onQY3f/F9hasPUx6g== dependencies: "@babel/runtime" "^7.3.1" - jss "10.0.0" + jss "^10.0.3" -jss-plugin-global@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-global/-/jss-plugin-global-10.0.0.tgz#0fed1b6461e0d57d6e394f877529009bc1cb3cb6" - integrity sha512-80ofWKSQUo62bxLtRoTNe0kFPtHgUbAJeOeR36WEGgWIBEsXLyXOnD5KNnjPqG4heuEkz9eSLccjYST50JnI7Q== +jss-plugin-global@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-global/-/jss-plugin-global-10.0.3.tgz#82bc95aa7f2c7171adc3ea47ec7717aca76a2389" + integrity sha512-kNotkAciJIXpIGYnmueaIifBne9rdq31O8Xq1nF7KMfKlskNRANTcEX5rVnsGKl2yubTMYfjKBFCeDgcQn6+gA== dependencies: "@babel/runtime" "^7.3.1" - jss "10.0.0" + jss "^10.0.3" -jss-plugin-nested@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-nested/-/jss-plugin-nested-10.0.0.tgz#d37ecc013c3b0d0e4acc2b48f6b62da6ae53948b" - integrity sha512-waxxwl/po1hN3azTyixKnr8ReEqUv5WK7WsO+5AWB0bFndML5Yqnt8ARZ90HEg8/P6WlqE/AB2413TkCRZE8bA== +jss-plugin-nested@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-nested/-/jss-plugin-nested-10.0.3.tgz#1ff39383154a710008788dbc9f73e6dec77b2852" + integrity sha512-OMucRs9YLvWlZ3Ew+VhdgNVMwSS2zZy/2vy+s/etvopnPUzDHgCnJwdY2Wx/SlhLGERJeKKufyih2seH+ui0iw== dependencies: "@babel/runtime" "^7.3.1" - jss "10.0.0" + jss "^10.0.3" tiny-warning "^1.0.2" -jss-plugin-props-sort@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-props-sort/-/jss-plugin-props-sort-10.0.0.tgz#38a13407384c2a4a7c026659488350669b953b18" - integrity sha512-41mf22CImjwNdtOG3r+cdC8+RhwNm616sjHx5YlqTwtSJLyLFinbQC/a4PIFk8xqf1qpFH1kEAIw+yx9HaqZ3g== +jss-plugin-props-sort@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-props-sort/-/jss-plugin-props-sort-10.0.3.tgz#8bc9f2a670fbd603f110486d28c526eb9efcbdc4" + integrity sha512-ufhvdCMnRcDa0tNHoZ12OcVNQQyE10yLMohxo/UIMarLV245rM6n9D19A12epjldRgyiS13SoSyLFCJEobprYg== dependencies: "@babel/runtime" "^7.3.1" - jss "10.0.0" + jss "^10.0.3" -jss-plugin-rule-value-function@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.0.0.tgz#3ec1b781b7c86080136dbef6c36e91f20244b72e" - integrity sha512-Jw+BZ8JIw1f12V0SERqGlBT1JEPWax3vuZpMym54NAXpPb7R1LYHiCTIlaJUyqvIfEy3kiHMtgI+r2whGgRIxQ== +jss-plugin-rule-value-function@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-rule-value-function/-/jss-plugin-rule-value-function-10.0.3.tgz#1103240cf686bde5baee16cd7b15b0daf79d1103" + integrity sha512-RWwIT2UBAIwf3f6DQtt5gyjxHMRJoeO9TQku+ueR8dBMakqSSe8vFwQNfjXEoe0W+Tez5HZCTkZKNMulv3Z+9A== dependencies: "@babel/runtime" "^7.3.1" - jss "10.0.0" + jss "^10.0.3" -jss-plugin-vendor-prefixer@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.0.0.tgz#400280535b0f483a9c78105afe4eee61b70018eb" - integrity sha512-qslqvL0MUbWuzXJWdUxpj6mdNUX8jr4FFTo3aZnAT65nmzWL7g8oTr9ZxmTXXgdp7ANhS1QWE7036/Q2isFBpw== +jss-plugin-vendor-prefixer@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss-plugin-vendor-prefixer/-/jss-plugin-vendor-prefixer-10.0.3.tgz#cfdf2ac1263e190ee9a0d874cdcc6092df452012" + integrity sha512-zVs6e5z4tFRK/fJ5kuTLzXlTFQbLeFTVwk7lTZiYNufmZwKT0kSmnOJDUukcSe7JLGSRztjWhnHB/6voP174gw== dependencies: "@babel/runtime" "^7.3.1" - css-vendor "^2.0.6" - jss "10.0.0" + css-vendor "^2.0.7" + jss "^10.0.3" -jss@10.0.0, jss@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/jss/-/jss-10.0.0.tgz#998d5026c02accae15708de83bd6ba57bac977d2" - integrity sha512-TPpDFsiBjuERiL+dFDq8QCdiF9oDasPcNqCKLGCo/qED3fNYOQ8PX2lZhknyTiAt3tZrfOFbb0lbQ9lTjPZxsQ== +jss@10.0.3, jss@^10.0.3: + version "10.0.3" + resolved "https://registry.yarnpkg.com/jss/-/jss-10.0.3.tgz#5c160f96aa8ce8b9f851ee0b33505dcd37f490a4" + integrity sha512-AcDvFdOk16If9qvC9KN3oFXsrkHWM9+TaPMpVB9orm3z+nq1Xw3ofHyflRe/mkSucRZnaQtlhZs1hdP3DR9uRw== dependencies: "@babel/runtime" "^7.3.1" csstype "^2.6.5" @@ -7586,7 +7621,7 @@ npm-lifecycle@^2.1.0: umask "^1.1.0" which "^1.3.1" -npm-normalize-package-bin@^1.0.0: +npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== @@ -7602,12 +7637,13 @@ npm-normalize-package-bin@^1.0.0: validate-npm-package-name "^3.0.0" npm-packlist@^1.1.12, npm-packlist@^1.4.1: - version "1.4.7" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.7.tgz#9e954365a06b80b18111ea900945af4f88ed4848" - integrity sha512-vAj7dIkp5NhieaGZxBJB8fF4R0078rqsmhJcAfXZ6O7JJhjhPK96n5Ry1oZcfLXgfun0GWTZPOxaEyqv8GBykQ== + version "1.4.8" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" + integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== dependencies: ignore-walk "^3.0.1" npm-bundled "^1.0.1" + npm-normalize-package-bin "^1.0.1" npm-packlist@^1.1.6: version "1.4.6" @@ -8607,21 +8643,26 @@ react-chartjs-2@2.7.6: lodash "^4.17.4" prop-types "^15.5.8" -react-dom@16.11.0: - version "16.11.0" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.11.0.tgz#7e7c4a5a85a569d565c2462f5d345da2dd849af5" - integrity sha512-nrRyIUE1e7j8PaXSPtyRKtz+2y9ubW/ghNgqKFHHAHaeP0fpF5uXR+sq8IMRHC+ZUxw7W9NyCDTBtwWxvkb0iA== +react-dom@16.12.0: + version "16.12.0" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.12.0.tgz#0da4b714b8d13c2038c9396b54a92baea633fe11" + integrity sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.17.0" + scheduler "^0.18.0" react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6: version "16.11.0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.11.0.tgz#b85dfecd48ad1ce469ff558a882ca8e8313928fa" integrity sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw== +react-is@^16.8.0: + version "16.12.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c" + integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q== + react-router-dom@4.3.1: version "4.3.1" resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.3.1.tgz#4c2619fc24c4fa87c9fd18f4fb4a43fe63fbd5c6" @@ -8657,10 +8698,10 @@ react-transition-group@4.3.0, react-transition-group@^4.3.0: loose-envify "^1.4.0" prop-types "^15.6.2" -react@16.11.0: - version "16.11.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.11.0.tgz#d294545fe62299ccee83363599bf904e4a07fdbb" - integrity sha512-M5Y8yITaLmU0ynd0r1Yvfq98Rmll6q8AxaEe88c8e7LxO8fZ2cNgmFt0aGAS9wzf1Ao32NKXtCl+/tVVtkxq6g== +react@16.12.0: + version "16.12.0" + resolved "https://registry.yarnpkg.com/react/-/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83" + integrity sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -8748,7 +8789,16 @@ read@1, read@~1.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" -"readable-stream@2 || 3", readable-stream@^3.0.2, readable-stream@^3.0.6, readable-stream@^3.1.1: +"readable-stream@2 || 3", readable-stream@^3.0.2: + version "3.5.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.5.0.tgz#465d70e6d1087f6162d079cd0b5db7fbebfd1606" + integrity sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readable-stream@^3.0.6, readable-stream@^3.1.1: version "3.4.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" integrity sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ== @@ -9211,10 +9261,10 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -scheduler@^0.17.0: - version "0.17.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.17.0.tgz#7c9c673e4ec781fac853927916d1c426b6f3ddfe" - integrity sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA== +scheduler@^0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.18.0.tgz#5901ad6659bc1d8f3fdaf36eb7a67b0d6746b1c4" + integrity sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" |