summaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /adapters/mso-network-adapter
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-network-adapter')
-rw-r--r--adapters/mso-network-adapter/README0
-rw-r--r--adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF3
-rw-r--r--adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml21
-rw-r--r--adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml3
-rw-r--r--adapters/mso-network-adapter/WebContent/WEB-INF/web.xml122
-rw-r--r--adapters/mso-network-adapter/WebContent/check.html10
-rw-r--r--adapters/mso-network-adapter/pom.xml178
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java283
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java75
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java66
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java212
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java67
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java58
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java59
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java68
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java67
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java222
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java106
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java686
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java2243
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java606
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java81
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java73
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java97
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java36
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java39
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java40
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java40
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java92
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java1193
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java657
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java298
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java111
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java41
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java48
-rw-r--r--adapters/mso-network-adapter/src/test/resources/logback-test.xml48
37 files changed, 0 insertions, 8050 deletions
diff --git a/adapters/mso-network-adapter/README b/adapters/mso-network-adapter/README
deleted file mode 100644
index e69de29bb2..0000000000
--- a/adapters/mso-network-adapter/README
+++ /dev/null
diff --git a/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e9495128c..0000000000
--- a/adapters/mso-network-adapter/WebContent/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index 1281d32948..0000000000
--- a/adapters/mso-network-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
+++ /dev/null
@@ -1 +0,0 @@
-com.woorea.openstack.connector.HttpClientConnector \ No newline at end of file
diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
deleted file mode 100644
index fb268917f2..0000000000
--- a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<jboss-deployment-structure>
- <deployment>
- <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
- <exclusions>
- <module name="org.apache.log4j" />
- <module name="org.slf4j" />
- <module name="org.slf4j.impl" />
- <module name="org.jboss.resteasy.resteasy-jackson-provider" />
- <module name="org.jboss.resteasy.resteasy-jettison-provider" />
- </exclusions>
- <dependencies>
- <module name="org.jboss.jandex" slot="main" />
- <module name="org.javassist" slot="main" />
- <module name="org.antlr" slot="main" />
- <module name="org.dom4j" slot="main" />
- <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import" />
- <!-- This module contain the ProviderBase class: -->
- <module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" export="true" />
- </dependencies>
- </deployment>
-</jboss-deployment-structure>
diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml
deleted file mode 100644
index 251a78b850..0000000000
--- a/adapters/mso-network-adapter/WebContent/WEB-INF/jboss-web.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<jboss-web>
- <context-root>networks</context-root>
-</jboss-web> \ No newline at end of file
diff --git a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml
deleted file mode 100644
index b7991babb2..0000000000
--- a/adapters/mso-network-adapter/WebContent/WEB-INF/web.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
- <display-name>mso-network-adapter</display-name>
-
- <context-param>
- <param-name>resteasy.jndi.resources</param-name>
- <param-value>java:module/MsoPropertiesFactory,java:module/CloudConfigFactory</param-value>
- </context-param>
-
- <context-param>
- <param-name>log.configuration</param-name>
- <param-value>logback.network.xml</param-value>
- </context-param>
- <context-param>
- <param-name>mso.configuration</param-name>
- <param-value>MSO_PROP_NETWORK_ADAPTER=mso.network.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value>
- </context-param>
- <context-param>
- <param-name>mso.cloud_config.configuration</param-name>
- <param-value>cloud_config.json=2</param-value>
- </context-param>
- <context-param>
- <param-name>resteasy.resources</param-name>
- <param-value>
- org.openecomp.mso.MsoStatusHandler,
- org.openecomp.mso.logger.MsoLoggingServlet,
- org.openecomp.mso.adapters.network.HealthCheckHandler,
- org.openecomp.mso.adapters.network.NetworkAdapterRest
- </param-value>
- </context-param>
- <context-param>
- <param-name>resteasy.providers</param-name>
- <param-value>org.openecomp.mso.adapters.providers.JettisonStyleMapperProvider</param-value>
- </context-param>
- <context-param>
- <param-name>resteasy.servlet.mapping.prefix</param-name>
- <param-value>/rest</param-value>
- </context-param>
- <servlet>
- <servlet-name>Resteasy</servlet-name>
- <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>Resteasy</servlet-name>
- <url-pattern>/rest/*</url-pattern>
- </servlet-mapping>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>SoapRequests</web-resource-name>
- <description>Soap Ingress Requests</description>
- <url-pattern>/NetworkAdapter</url-pattern>
- <url-pattern>/NetworkAdapterAsync</url-pattern>
- <http-method>POST</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>BPEL-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>SiteStatus</web-resource-name>
- <description>SiteStatus APIs</description>
- <url-pattern>/rest/setStatus/*</url-pattern>
- <http-method>POST</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>SiteControl-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>RestRequests</web-resource-name>
- <description>Rest Ingress Requests</description>
- <url-pattern>/rest/v1/networks/*</url-pattern>
- <http-method>DELETE</http-method>
- <http-method>GET</http-method>
- <http-method>POST</http-method>
- <http-method>PUT</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>BPEL-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>MSO internal Requests</web-resource-name>
- <description>Internal Requests</description>
- <url-pattern>/rest/logging/*</url-pattern>
- <url-pattern>/rest/properties/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>MSO-Client</role-name>
- </auth-constraint>
- </security-constraint>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>ApplicationRealm</realm-name>
- </login-config>
- <security-role>
- <role-name>BPEL-Client</role-name>
- </security-role>
- <security-role>
- <role-name>SiteControl-Client</role-name>
- </security-role>
- <security-role>
- <role-name>MSO-Client</role-name>
- </security-role>
- <filter>
- <filter-name>LogFilter</filter-name>
- <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>LogFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <welcome-file-list>
- <welcome-file>check.html</welcome-file>
- </welcome-file-list>
-</web-app>
-
diff --git a/adapters/mso-network-adapter/WebContent/check.html b/adapters/mso-network-adapter/WebContent/check.html
deleted file mode 100644
index 00f37d60d1..0000000000
--- a/adapters/mso-network-adapter/WebContent/check.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="ISO-8859-1">
-<title>Health Check</title>
-</head>
-<body>
-Application ready
-</body>
-</html> \ No newline at end of file
diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml
deleted file mode 100644
index 92c0ae58d5..0000000000
--- a/adapters/mso-network-adapter/pom.xml
+++ /dev/null
@@ -1,178 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-network-adapter</artifactId>
- <packaging>war</packaging>
- <name>mso-network-adapter</name>
- <description>Web service endpoint for Network operations</description>
-
- <!-- <properties> -->
- <!-- <project.build.sourceEncoding/> -->
- <!-- <project.reporting.outputEncoding/> -->
- <!-- </properties> -->
-
- <build>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <warSourceDirectory>WebContent</warSourceDirectory>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- <attachClasses>true</attachClasses>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxws-maven-plugin</artifactId>
- <version>2.4.1</version>
- <executions>
- <execution>
- <goals>
- <goal>wsgen</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <verbose>true</verbose>
- <sei>org.openecomp.mso.adapters.network.MsoNetworkAdapterImpl</sei>
- <genWsdl>true</genWsdl>
- <inlineSchemas>true</inlineSchemas>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-tools</artifactId>
- <version>2.2.7</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.jvnet.jax-ws-commons
- </groupId>
- <artifactId>
- jaxws-maven-plugin
- </artifactId>
- <versionRange>
- [2.3,)
- </versionRange>
- <goals>
- <goal>wsgen</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <dependencies>
- <!-- added for unit testing -->
- <dependency>
- <groupId>javax.json</groupId>
- <artifactId>javax.json-api</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.json</artifactId>
- <version>1.0.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.1</version>
- <scope>test</scope>
- </dependency>
-
-
- <!-- added for unit testing -->
-
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-web-api</artifactId>
- <version>6.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-network-adapter-async-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapters-rest-interface</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>
- <version>1.0.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-ext-api</artifactId>
- <version>2.2.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>status-control</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-</project>
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java
deleted file mode 100644
index c66b4a8207..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.network;
-
-
-import java.io.IOException;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.xml.bind.DatatypeConverter;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-/**
- * This is the class that is used to POST replies from the MSO adapters to the BPEL engine.
- * It can be configured via property file, or modified using the member methods.
- * The properties to use are:
- * org.openecomp.mso.adapters.vnf.bpelauth encrypted authorization string to send to BEPL engine
- * org.openecomp.mso.adapters.vnf.sockettimeout socket timeout value
- * org.openecomp.mso.adapters.vnf.connecttimeout connect timeout value
- * org.openecomp.mso.adapters.vnf.retrycount number of times to retry failed connections
- * org.openecomp.mso.adapters.vnf.retryinterval interval (in seconds) between retries
- * org.openecomp.mso.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code
- * 900 means "connection was not established")
- */
-public class BpelRestClient {
- public static final String MSO_PROP_NETWORK_ADAPTER = "MSO_PROP_NETWORK_ADAPTER";
- private static final String PROPERTY_DOMAIN = "org.openecomp.mso.adapters.network";
- private static final String BPEL_AUTH_PROPERTY = PROPERTY_DOMAIN+".bpelauth";
- private static final String SOCKET_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".sockettimeout";
- private static final String CONN_TIMEOUT_PROPERTY = PROPERTY_DOMAIN+".connecttimeout";
- private static final String RETRY_COUNT_PROPERTY = PROPERTY_DOMAIN+".retrycount";
- private static final String RETRY_INTERVAL_PROPERTY = PROPERTY_DOMAIN+".retryinterval";
- private static final String RETRY_LIST_PROPERTY = PROPERTY_DOMAIN+".retrylist";
- private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
-
- /** Default socket timeout (in seconds) */
- public static final int DEFAULT_SOCKET_TIMEOUT = 5;
- /** Default connect timeout (in seconds) */
- public static final int DEFAULT_CONNECT_TIMEOUT = 5;
- /** By default, retry up to five times */
- public static final int DEFAULT_RETRY_COUNT = 5;
- /** Default interval to wait between retries (in seconds), negative means use backoff algorithm */
- public static final int DEFAULT_RETRY_INTERVAL = -15;
- /** Default list of response codes to trigger a retry */
- public static final String DEFAULT_RETRY_LIST = "408,429,500,502,503,504,900"; // 900 is "connection failed"
- /** Default credentials */
- public static final String DEFAULT_CREDENTIALS = "";
-
- // Properties of the BPEL client -- all are configurable
- private int socketTimeout;
- private int connectTimeout;
- private int retryCount;
- private int retryInterval;
- private Set<Integer> retryList;
- private String credentials;
-
- // last response from BPEL engine
- private int lastResponseCode;
- private String lastResponse;
-
- /**
- * Create a client to send results to the BPEL engine, using configuration from the
- * MSO_PROP_NETWORK_ADAPTER properties.
- */
- public BpelRestClient() {
- socketTimeout = DEFAULT_SOCKET_TIMEOUT;
- connectTimeout = DEFAULT_CONNECT_TIMEOUT;
- retryCount = DEFAULT_RETRY_COUNT;
- retryInterval = DEFAULT_RETRY_INTERVAL;
- setRetryList(DEFAULT_RETRY_LIST);
- credentials = DEFAULT_CREDENTIALS;
- lastResponseCode = 0;
- lastResponse = "";
-
- try {
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- MsoJavaProperties jp = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER);
- socketTimeout = jp.getIntProperty(SOCKET_TIMEOUT_PROPERTY, DEFAULT_SOCKET_TIMEOUT);
- connectTimeout = jp.getIntProperty(CONN_TIMEOUT_PROPERTY, DEFAULT_CONNECT_TIMEOUT);
- retryCount = jp.getIntProperty(RETRY_COUNT_PROPERTY, DEFAULT_RETRY_COUNT);
- retryInterval = jp.getIntProperty(RETRY_INTERVAL_PROPERTY, DEFAULT_RETRY_INTERVAL);
- setRetryList(jp.getProperty(RETRY_LIST_PROPERTY, DEFAULT_RETRY_LIST));
- credentials = jp.getEncryptedProperty(BPEL_AUTH_PROPERTY, DEFAULT_CREDENTIALS, ENCRYPTION_KEY);
- } catch (MsoPropertiesException e) {
- String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Unable to get properties", e);
- }
- }
-
- public int getSocketTimeout() {
- return socketTimeout;
- }
-
- public void setSocketTimeout(int socketTimeout) {
- this.socketTimeout = socketTimeout;
- }
-
- public int getConnectTimeout() {
- return connectTimeout;
- }
-
- public void setConnectTimeout(int connectTimeout) {
- this.connectTimeout = connectTimeout;
- }
-
- public int getRetryCount() {
- return retryCount;
- }
-
- public void setRetryCount(int retryCount) {
- int retCnt = 0;
- if (retryCount < 0)
- retCnt = DEFAULT_RETRY_COUNT;
- this.retryCount = retCnt;
- }
-
- public int getRetryInterval() {
- return retryInterval;
- }
-
- public void setRetryInterval(int retryInterval) {
- this.retryInterval = retryInterval;
- }
-
- public String getCredentials() {
- return credentials;
- }
-
- public void setCredentials(String credentials) {
- this.credentials = credentials;
- }
-
- public String getRetryList() {
- if (retryList.isEmpty())
- return "";
- String t = retryList.toString();
- return t.substring(1, t.length()-1);
- }
-
- public void setRetryList(String retryList) {
- Set<Integer> s = new TreeSet<>();
- for (String t : retryList.split("[, ]")) {
- try {
- s.add(Integer.parseInt(t));
- } catch (NumberFormatException x) {
- LOGGER.debug("Exception while parsing", x);
- }
- }
- this.retryList = s;
- }
-
- public int getLastResponseCode() {
- return lastResponseCode;
- }
-
- public String getLastResponse() {
- return lastResponse;
- }
-
- /**
- * Post a response to the URL of the BPEL engine. As long as the response code is one of those in
- * the retryList, the post will be retried up to "retrycount" times with an interval (in seconds)
- * of "retryInterval". If retryInterval is negative, then each successive retry interval will be
- * double the previous one.
- * @param toBpelStr the content (XML or JSON) to post
- * @param bpelUrl the URL to post to
- * @param isxml true if the content is XML, otherwise assumed to be JSON
- * @return true if the post succeeded, false if all retries failed
- */
- public boolean bpelPost(final String toBpelStr, final String bpelUrl, final boolean isxml) {
- debug("Sending response to BPEL: " + toBpelStr);
- int totalretries = 0;
- int retryint = retryInterval;
- while (true) {
- sendOne(toBpelStr, bpelUrl, isxml);
- // Note: really should handle response code 415 by switching between content types if needed
- if (!retryList.contains(lastResponseCode)) {
- debug("Got response code: " + lastResponseCode + ": returning.");
- return true;
- }
- if (totalretries >= retryCount) {
- debug("Retried " + totalretries + " times, giving up.");
- LOGGER.error(MessageEnum.RA_SEND_VNF_NOTIF_ERR, "Could not deliver response to BPEL after "+totalretries+" tries: "+toBpelStr, "Camunda", "", MsoLogger.ErrorCode.DataError, "Could not deliver response to BPEL");
- return false;
- }
- totalretries++;
- int sleepinterval = retryint;
- if (retryint < 0) {
- // if retry interval is negative double the retry on each pass
- sleepinterval = -retryint;
- retryint *= 2;
- }
- debug("Sleeping for " + sleepinterval + " seconds.");
- try {
- Thread.sleep(sleepinterval * 1000L);
- } catch (InterruptedException e) {
- LOGGER.debug("Exception while Thread sleep", e);
- }
- }
- }
- private void debug(String m) {
- LOGGER.debug(m);
-
- }
- private void sendOne(final String toBpelStr, final String bpelUrl, final boolean isxml) {
- LOGGER.debug("Sending to BPEL server: "+bpelUrl);
- LOGGER.debug("Content is: "+toBpelStr);
-
- //POST
- HttpPost post = new HttpPost(bpelUrl);
- if (credentials != null && !credentials.isEmpty())
- post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(credentials.getBytes()));
-
- //ContentType
- ContentType ctype = isxml ? ContentType.APPLICATION_XML : ContentType.APPLICATION_JSON;
- post.setEntity(new StringEntity(toBpelStr, ctype));
-
- //Timeouts
- RequestConfig requestConfig = RequestConfig
- .custom()
- .setSocketTimeout(socketTimeout * 1000)
- .setConnectTimeout(connectTimeout * 1000)
- .build();
- post.setConfig(requestConfig);
-
- //Client 4.3+
- //Execute & GetResponse
- try (CloseableHttpClient client = HttpClients.createDefault()) {
- CloseableHttpResponse response = client.execute(post);
- if (response != null) {
- lastResponseCode = response.getStatusLine().getStatusCode();
- HttpEntity entity = response.getEntity();
- lastResponse = (entity != null) ? EntityUtils.toString(entity) : "";
- } else {
- lastResponseCode = 900;
- lastResponse = "";
- }
- } catch (Exception e) {
- String error = "Error sending Bpel notification:" + toBpelStr;
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception sending Bpel notification", e);
- lastResponseCode = 900;
- lastResponse = "";
- }
- LOGGER.debug("Response code from BPEL server: "+lastResponseCode);
- LOGGER.debug("Response body is: "+lastResponse);
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java
deleted file mode 100644
index e3c6ffd827..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ContrailPolicyRef {
- private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
-
- @JsonProperty("network_policy_refs_data_sequence")
- private ContrailPolicyRefSeq seq;
-
- public JsonNode toJsonNode()
- {
- JsonNode node = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- node = mapper.convertValue(this, JsonNode.class);
- }
- catch (Exception e)
- {
- logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e);
- }
-
- return node;
- }
-
- public String toJsonString()
- {
- String jsonString = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- jsonString = mapper.writeValueAsString(this);
- }
- catch (Exception e)
- {
- logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e);
- }
-
- return jsonString;
- }
-
- public void populate(String major, String minor)
- {
- seq = new ContrailPolicyRefSeq(major, minor);
- return;
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java
deleted file mode 100644
index 56917a9ff4..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ContrailPolicyRefSeq {
-
- @JsonProperty("network_policy_refs_data_sequence_major")
- private String major;
-
- @JsonProperty("network_policy_refs_data_sequence_minor")
- private String minor;
-
- public ContrailPolicyRefSeq() {
- /* To be done */
- }
-
- public ContrailPolicyRefSeq(String major, String minor) {
- super();
- this.major = major;
- this.minor = minor;
- }
-
- public String getMajor() {
- return major;
- }
-
- public void setMajor(String major) {
- this.major = major;
- }
-
- public String getMinor() {
- return minor;
- }
-
- public void setMinor(String minor) {
- this.minor = minor;
- }
-
- @Override
- public String toString() {
- return "ContrailPolicyRefSeq [major=" + major + ", minor=" + minor
- + "]";
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java
deleted file mode 100644
index 9018524126..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.HostRoute;
-import org.openecomp.mso.openstack.beans.Pool;
-import org.openecomp.mso.openstack.beans.Subnet;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ContrailSubnet {
- private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet")
- private ContrailSubnetIp subnet = new ContrailSubnetIp();
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_default_gateway")
- private String defaultGateway;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_name")
- private String subnetName;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_enable_dhcp")
- private Boolean enableDhcp;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_addr_from_start")
- private Boolean addrFromStart = true;
- /** future - leave this commented
- private String subnet_uuid;
- private String dns_server_address;
- private List<String> dns_nameservers;
- private String dhcp_option_list;
- **/
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools")
- private List<ContrailSubnetPool> allocationPools = new ArrayList <> ();
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes")
- private ContrailSubnetHostRoutes host_routes = new ContrailSubnetHostRoutes();
-
- public ContrailSubnet() {
- super();
- }
-
- public String getDefaultGateway() {
- return defaultGateway;
- }
-
- public void setDefaultGateway(String defaultGateway) {
- this.defaultGateway = defaultGateway;
- }
-
- public ContrailSubnetIp getSubnet() {
- return subnet;
- }
-
- public void setSubnet(ContrailSubnetIp subnet) {
- this.subnet = subnet;
- }
-
- public Boolean isEnableDhcp() {
- return enableDhcp;
- }
-
- public void setEnableDhcp(Boolean enableDhcp) {
- this.enableDhcp = enableDhcp;
- }
-
- public String getSubnetName() {
- return subnetName;
- }
-
- public void setSubnetName(String subnetName) {
- this.subnetName = subnetName;
- }
-
- public List<ContrailSubnetPool> getAllocationPools() {
- return allocationPools;
- }
-
- public void setPools(List<ContrailSubnetPool> allocationPools) {
- this.allocationPools = allocationPools;
- }
-
- public Boolean isAddrFromStart() {
- return addrFromStart;
- }
-
- public void setAddrFromStart(Boolean addrFromStart) {
- this.addrFromStart = addrFromStart;
- }
-
- public JsonNode toJsonNode()
- {
- JsonNode node = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- node = mapper.convertValue(this, JsonNode.class);
- }
- catch (Exception e)
- {
- String error = "Error creating JsonNode for Contrail Subnet:" + subnetName;
- logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonNode for Contrail Subnet", e);
- }
-
- return node;
- }
-
- public String toJsonString()
- {
- String jsonString = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- jsonString = mapper.writeValueAsString(this);
- }
- catch (Exception e)
- {
- String error = "Error creating JsonString for Contrail Subnet:" + subnetName;
- logger.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Subnet", e);
- }
-
- return jsonString;
- }
- //poulate contrail subnet with input(from bopel) subnet
- public void populateWith(Subnet inputSubnet)
- {
- if (inputSubnet != null)
- {
- if (!isNullOrEmpty(inputSubnet.getSubnetName()))
- subnetName = inputSubnet.getSubnetName();
- else
- subnetName = inputSubnet.getSubnetId();
- enableDhcp = inputSubnet.getEnableDHCP();
- defaultGateway = inputSubnet.getGatewayIp();
- if (!isNullOrEmpty(inputSubnet.getCidr()) )
- {
- int idx = inputSubnet.getCidr().indexOf("/");
- if (idx != -1)
- {
- subnet.setIpPrefix(inputSubnet.getCidr().substring(0, idx));
- subnet.setIpPrefixLen(inputSubnet.getCidr().substring(idx+1));
- }
- }
- if (inputSubnet.getAllocationPools() != null)
- {
- for (Pool pool : inputSubnet.getAllocationPools())
- {
- if ( !isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd()) )
- {
- ContrailSubnetPool csp = new ContrailSubnetPool();
- csp.populateWith(pool);
- allocationPools.add (csp);
- }
- }
- }
- if (inputSubnet.getHostRoutes() != null)
- {
- List<ContrailSubnetHostRoute> hrList = host_routes.getHost_routes();
- for (HostRoute hr : inputSubnet.getHostRoutes())
- {
- if ( !isNullOrEmpty(hr.getPrefix()) || !isNullOrEmpty(hr.getNextHop()) )
- {
- ContrailSubnetHostRoute cshr = new ContrailSubnetHostRoute();
- cshr.populateWith(hr);
- hrList.add (cshr);
- }
- }
- }
- }
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder ();
- for (ContrailSubnetPool pool : allocationPools)
- {
- buf.append(pool.toString());
- }
- return "ContrailSubnet [subnet=" + subnet.toString() + " default_gateway=" + defaultGateway
- + " enable_dhcp=" + enableDhcp + " addr_from_start=" + addrFromStart + " subnet_name=" + subnetName + " allocation_pools=" + buf + " ]";
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java
deleted file mode 100644
index 3cb16d451c..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import org.openecomp.mso.openstack.beans.HostRoute;
-import com.fasterxml.jackson.annotation.JsonProperty;
-public class ContrailSubnetHostRoute {
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route_prefix")
- private String prefix;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route_next_hop")
- private String nextHop;
-
- public ContrailSubnetHostRoute() {
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- public String getNextHop() {
- return nextHop;
- }
-
- public void setNextHop(String nextHop) {
- this.nextHop = nextHop;
- }
-
- public void populateWith(HostRoute hostRoute)
- {
- if (hostRoute != null)
- {
- prefix = hostRoute.getPrefix();
- nextHop = hostRoute.getNextHop();
- }
- }
-
- @Override
- public String toString() {
- return "ContrailSubnetHostRoute [prefix=" + prefix + ", nextHop=" + nextHop + "]";
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java
deleted file mode 100644
index 91b5aef2cf..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import org.openecomp.mso.openstack.beans.HostRoute;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-public class ContrailSubnetHostRoutes {
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route")
- private List<ContrailSubnetHostRoute> host_routes = new ArrayList <ContrailSubnetHostRoute> ();
-
- public ContrailSubnetHostRoutes() {
- }
-
- public List<ContrailSubnetHostRoute> getHost_routes() {
- return host_routes;
- }
-
- public void setHost_routes(List<ContrailSubnetHostRoute> host_routes) {
- this.host_routes = host_routes;
- }
-
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder ();
- if (host_routes != null)
- {
- for (ContrailSubnetHostRoute hr : host_routes)
- {
- buf.append(hr.toString());
- }
- }
- return "ContrailSubnetHostRoutes [" + buf.toString() + "]";
- }
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java
deleted file mode 100644
index a144de539a..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class ContrailSubnetIp {
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix")
- private String ipPrefix;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len")
- private String ipPrefixLen;
-
- public ContrailSubnetIp() {
- /* Empty constructor */
- }
-
- public String getIpPrefix() {
- return ipPrefix;
- }
-
- public void setIpPrefix(String ipPrefix) {
- this.ipPrefix = ipPrefix;
- }
-
- public String getIpPrefixLen() {
- return ipPrefixLen;
- }
-
- public void setIpPrefixLen(String ipPrefixLen) {
- this.ipPrefixLen = ipPrefixLen;
- }
-
- @Override
- public String toString() {
- return "ContrailSubnetIp [ip_prefix=" + ipPrefix + ", ip_prefix_len=" + ipPrefixLen + "]";
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java
deleted file mode 100644
index 950ca07234..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import org.openecomp.mso.openstack.beans.Pool;
-import com.fasterxml.jackson.annotation.JsonProperty;
-public class ContrailSubnetPool {
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools_start")
- private String start;
-
- @JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools_end")
- private String end;
-
- public ContrailSubnetPool() {
- /* Empty constructor */
- }
-
- public String getStart() {
- return start;
- }
-
- public void setStart(String start) {
- this.start = start;
- }
-
- public String getEnd() {
- return end;
- }
-
- public void setEnd(String end) {
- this.end = end;
- }
-
- public void populateWith(Pool pool)
- {
- if (pool != null)
- {
- start = pool.getStart();
- end = pool.getEnd();
- }
- }
-
- @Override
- public String toString() {
- return "ContrailSubnetPool [start=" + start + ", end=" + end + "]";
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java
deleted file mode 100644
index 5314de0e35..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/HealthCheckHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.utils.UUIDChecker;
-
-
-@Path("/")
- public class HealthCheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
- private static final String MSO_PROP_NETWORK_ADAPTER = "MSO_PROP_NETWORK_ADAPTER";
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces("text/html")
- public Response healthcheck (@QueryParam("requestId") String requestId) {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("Healthcheck");
- UUIDChecker.verifyOldUUID(requestId, msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck(msoLogger)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_NETWORK_ADAPTER)) {
- return HealthCheckUtils.NOT_STARTED_RESPONSE;
- }
-
- if (!healthCheck.catalogDBCheck (msoLogger, startTime)) {
- return HealthCheckUtils.NOT_STARTED_RESPONSE;
- }
- msoLogger.debug("healthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- }
-
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java
deleted file mode 100644
index ebcbe8b0dd..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import java.util.List;
-import java.util.Map;
-
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebParam.Mode;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-
-@WebService (name="NetworkAdapter", targetNamespace="http://org.openecomp.mso/network")
-public interface MsoNetworkAdapter
-{
- // TODO: Rename all of these to include Vlan in the service name? At least for the
- // create and update calls, since they are specific to VLAN-based provider networks.
-
- /**
- * This is the "Create Network" Web Service Endpoint definition.
- */
- @WebMethod
- public void createNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="physicalNetworkName") String physicalNetworkName,
- @WebParam(name="vlans") List<Integer> vlans,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId,
- @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
-
- @WebMethod
- public void createNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="routeTargets") List<RouteTarget> routeTargets,
- @WebParam(name="shared") String shared,
- @WebParam(name="external") String external,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="policyFqdns") List<String> policyFqdns,
- @WebParam(name="routeTableFqdns") List<String> routeTableFqdns,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId,
- @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId,
- @WebParam(name="networkFqdn", mode=Mode.OUT) Holder<String> networkFqdn,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
-
- /**
- * This is the "Update VLANs" Web Service Endpoint definition.
- * This webservice replaces the set of VLANs on a network.
- */
- @WebMethod
- public void updateNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName,
- @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
-
- @WebMethod
- public void updateNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="routeTargets") List<RouteTarget> routeTargets,
- @WebParam(name="shared") String shared,
- @WebParam(name="external") String external,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="policyFqdns") List<String> policyFqdns,
- @WebParam(name="routeTableFqdns") List<String> routeTableFqdns,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
-
- /**
- * TODO:
- * This is the "Add VLAN" Web Service Endpoint definition.
- * This webservice adds a VLAN to a network.
- * This service assumes that PO supports querying the current vlans in real time.
- * Otherwise, the caller must have the complete list and should use updateVlans instead.
- @WebMethod
- public void addVlan (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName,
- @WebParam(name="vlan") @XmlElement(required=true) Integer vlan,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
- */
-
- /**
- * TODO:
- * This is the "Remove VLAN" Web Service Endpoint definition.
- * This webservice removes a VLAN from a network.
- * This service assumes that PO supports querying the current vlans in real time.
- * Otherwise, the caller must have the complete list and should use updateVlans instead.
- *
- * This service returns an indicator (noMoreVLans) if the VLAN that was removed was
- * the last one on the network.
- *
- * It is not clear that Rollback will work for delete. The network can be
- * recreated from the NetworkRollback object, but the network ID (and stack ID
- * for Heat-based orchestration) will be different. The caller will need to know
- * to update these identifiers in the inventory DB (A&AI).
- @WebMethod
- public void removeVlan (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName,
- @WebParam(name="vlan") @XmlElement(required=true) Integer vlan,
- @WebParam(name="noMoreVlans", mode=Mode.OUT) Holder<Boolean> noMoreVlans,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback )
- throws NetworkException;
- */
-
- /**
- * This is the "Query Network" Web Service Endpoint definition.
- * TODO: Should this just return the NetworkInfo complete structure?
- */
- @WebMethod
- public void queryNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="networkExists", mode=Mode.OUT) Holder<Boolean> networkExists,
- @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId,
- @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId,
- @WebParam(name="status", mode=Mode.OUT) Holder<NetworkStatus> status,
- @WebParam(name="vlans", mode=Mode.OUT) Holder<List<Integer>> vlans,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap)
- throws NetworkException;
-
- @WebMethod
- public void queryNetworkContrail (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="networkExists", mode=Mode.OUT) Holder<Boolean> networkExists,
- @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId,
- @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId,
- @WebParam(name="status", mode=Mode.OUT) Holder<NetworkStatus> status,
- @WebParam(name="routeTargets", mode=Mode.OUT) Holder<List<RouteTarget>> routeTargets,
- @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap)
- throws NetworkException;
-
- /**
- * This is the "Delete Network" Web Service endpoint definition.
- */
- @WebMethod
- public void deleteNetwork (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="networkDeleted", mode=Mode.OUT) Holder<Boolean> networkDeleted)
- throws NetworkException;
-
- /**
- * This is the "Rollback Network" Web Service endpoint definition.
- */
- @WebMethod
- public void rollbackNetwork (@WebParam(name="rollback") @XmlElement(required=true) NetworkRollback rollback)
- throws NetworkException;
-
- @WebMethod
- public void healthCheck ();
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java
deleted file mode 100644
index 9c440a1a26..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsync.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import javax.jws.Oneway;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlElement;
-
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-
-import java.util.List;
-/**
- * This webservice defines the Asynchronous versions of NETWORK adapter calls.
- * The notification messages for final responses are documented elsewhere
- * (by the client service WSDL).
- *
- */
-@WebService (name="NetworkAdapterAsync", targetNamespace="http://org.openecomp.mso/networkA")
-public interface MsoNetworkAdapterAsync
-{
- /**
- * This is the "Create NETWORK" Web Service Endpoint definition.
- */
- @WebMethod
- @Oneway
- public void createNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="physicalNetworkName") String physicalNetworkName,
- @WebParam(name="vlans") List<Integer> vlans,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="messageId") @XmlElement(required=true) String messageId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl );
-
- @WebMethod
- @Oneway
- public void updateNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName,
- @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans,
- @WebParam(name="subnets") List<Subnet> subnets,
- @WebParam(name="messageId") @XmlElement(required=true) String messageId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl );
-
- @WebMethod
- @Oneway
- public void queryNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkNameOrId") @XmlElement(required=true) String networkNameOrId,
- @WebParam(name="messageId") @XmlElement(required=true) String messageId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl );
-
- @WebMethod
- @Oneway
- public void deleteNetworkA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="networkType") @XmlElement(required=true) String networkType,
- @WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
- @WebParam(name="networkId") @XmlElement(required=true) String networkId,
- @WebParam(name="messageId") @XmlElement(required=true) String messageId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl );
-
- @WebMethod
- @Oneway
- public void rollbackNetworkA (@WebParam(name="rollback") @XmlElement(required=true) NetworkRollback rollback,
- @WebParam(name="messageId") @XmlElement(required=true) String messageId,
- @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl );
-
- @WebMethod
- public void healthCheckA ();
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java
deleted file mode 100644
index b3ed711cf5..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.network;
-
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jws.WebService;
-import javax.xml.bind.DatatypeConverter;
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Holder;
-import javax.xml.ws.handler.MessageContext;
-
-import org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification;
-import org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory;
-import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify;
-import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify_Service;
-import org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification;
-import org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-
-@WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.openecomp.mso/networkA")
-public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
-
- MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
-
- CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();
-
- public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER";
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.network.bpelauth";
- private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheckA () {
- LOGGER.debug ("Health check call in Network Adapter");
- }
-
- /**
- * This is the "Create Network" web service implementation.
- * It will create a new Network of the requested type in the specified cloud
- * and tenant. The tenant must exist at the time this service is called.
- *
- * If a network with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog.
- * All such networks will have a similar configuration, based on the allowable
- * Openstack networking definitions. This includes basic networks, provider
- * networks (with a single VLAN), and multi-provider networks (one or more VLANs)
- *
- * Initially, all provider networks must be "vlan" type, and multiple segments in
- * a multi-provider network must be multiple VLANs on the same physical network.
- *
- * This service supports two modes of Network creation/update:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition. All Heat-based templates must support some subset of
- * the same input parameters: network_name, physical_network, vlan(s).
- *
- * The method returns the network ID and a NetworkRollback object. This latter
- * object can be passed as-is to the rollbackNetwork operation to undo everything
- * that was created. This is useful if a network is successfully created but
- * the orchestration fails on a subsequent operation.
- */
- @Override
- public void createNetworkA (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- Boolean failIfExists,
- Boolean backout,
- List <Subnet> subnets,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
-
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("CreateNetworkA");
- LOGGER.debug ("Async Create Network: " + networkName
- + " of type "
- + networkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId);
-
- // Use the synchronous method to perform the actual Create
- MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <NetworkRollback> networkRollback = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
-
- try {
- networkAdapter.createNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- failIfExists,
- backout,
- subnets,
- msoRequest,
- networkId,
- neutronNetworkId,
- subnetIdMap,
- networkRollback);
- } catch (NetworkException e) {
- LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null);
- } catch (Exception e1) {
- error = "Error sending createNetwork notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
- LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.createNetworkNotification (messageId,
- true,
- null,
- null,
- networkId.value,
- neutronNetworkId.value,
- copyCreateSubnetIdMap (subnetIdMap),
- copyNrb (networkRollback));
- } catch (Exception e) {
- error = "Error sending createNetwork notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
-
- /**
- * This is the "Update Network" web service implementation.
- * It will update an existing Network of the requested type in the specified cloud
- * and tenant. The typical use will be to replace the VLANs with the supplied
- * list (to add or remove a VLAN), but other properties may be updated as well.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog.
- * All such networks will have a similar configuration, based on the allowable
- * Openstack networking definitions. This includes basic networks, provider
- * networks (with a single VLAN), and multi-provider networks (one or more VLANs).
- *
- * Initially, all provider networks must currently be "vlan" type, and multi-provider
- * networks must be multiple VLANs on the same physical network.
- *
- * This service supports two modes of Network update:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition. All Heat-based templates must support some subset of
- * the same input parameters: network_name, physical_network, vlan, segments.
- *
- * The method returns a NetworkRollback object. This object can be passed
- * as-is to the rollbackNetwork operation to undo everything that was updated.
- * This is useful if a network is successfully updated but orchestration
- * fails on a subsequent operation.
- */
- @Override
- public void updateNetworkA (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- List <Subnet> subnets,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
-
- String serviceName = "UpdateNetworkA";
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext (msoRequest);
- LOGGER.debug ("Async Update Network: " + networkId
- + " of type "
- + networkType
- + "in "
- + cloudSiteId
- + "/"
- + tenantId);
-
- // Use the synchronous method to perform the actual Create
- MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <NetworkRollback> networkRollback = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
-
- try {
- networkAdapter.updateNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkId,
- networkName,
- physicalNetworkName,
- vlans,
- subnets,
- msoRequest,
- subnetIdMap,
- networkRollback);
- MsoLogger.setServiceName (serviceName);
- } catch (NetworkException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Got a NetworkException on updateNetwork: ", e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback));
- } catch (Exception e1) {
- error = "Error sending updateNetwork notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
- LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.updateNetworkNotification (messageId,
- true,
- null,
- null,
- copyUpdateSubnetIdMap (subnetIdMap),
- copyNrb (networkRollback));
- } catch (Exception e) {
- error = "Error sending updateNotification request" + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
-
- /**
- * This is the queryNetwork method. It returns the existence and status of
- * the specified network, along with its Neutron UUID and list of VLANs.
- * This method attempts to find the network using both Heat and Neutron.
- * Heat stacks are first searched based on the provided network name/id.
- * If none is found, the Neutron is directly queried.
- */
- @Override
- public void queryNetworkA (String cloudSiteId,
- String tenantId,
- String networkNameOrId,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
-
- MsoLogger.setLogContext (msoRequest);
- String serviceName = "QueryNetworkA";
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId);
-
- // Use the synchronous method to perform the actual Create
- MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <Boolean> networkExists = new Holder <> ();
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <NetworkStatus> status = new Holder <> ();
- Holder <List <Integer>> vlans = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
-
- try {
- networkAdapter.queryNetwork (cloudSiteId,
- tenantId,
- networkNameOrId,
- msoRequest,
- networkExists,
- networkId,
- neutronNetworkId,
- status,
- vlans,
- subnetIdMap);
- MsoLogger.setServiceName (serviceName);
- } catch (NetworkException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null);
- } catch (Exception e1) {
- error = "Error sending createNetwork notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
- LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- org.openecomp.mso.adapters.network.async.client.NetworkStatus networkS = org.openecomp.mso.adapters.network.async.client.NetworkStatus.fromValue (status.value.name ());
- notifyPort.queryNetworkNotification (messageId,
- true,
- null,
- null,
- networkExists.value,
- networkId.value,
- neutronNetworkId.value,
- networkS,
- vlans.value,
- copyQuerySubnetIdMap (subnetIdMap));
- } catch (Exception e) {
- error = "Error sending createNetwork notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
-
- /**
- * This is the "Delete Network" web service implementation.
- * It will delete a Network in the specified cloud and tenant.
- *
- * If the network is not found, it is treated as a success.
- *
- * This service supports two modes of Network creation/update/delete:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition.
- *
- * For Heat-based orchestration, the networkId should be the stack ID.
- * For Neutron-based orchestration, the networkId should be the Neutron network UUID.
- *
- * The method returns nothing on success. Rollback is not possible for delete
- * commands, so any failure on delete will require manual fallout in the client.
- */
- @Override
- public void deleteNetworkA (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
- MsoLogger.setLogContext (msoRequest);
- String serviceName = "DeleteNetworkA";
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId);
-
- // Use the synchronous method to perform the actual Create
- MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <Boolean> networkDeleted = new Holder <> ();
-
- try {
- networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted);
- MsoLogger.setServiceName (serviceName);
- } catch (NetworkException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null);
- } catch (Exception e1) {
- error = "Error sending createNetwork notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
- LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId);
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value);
- } catch (Exception e) {
- error = "Error sending deleteNetwork notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation.
- * A rollback object is returned to the client in a successful creation
- * response. The client can pass that object as-is back to the rollbackNetwork
- * operation to undo the creation.
- *
- * The rollback includes removing the VNF and deleting the tenant if the
- * tenant did not exist prior to the VNF creation.
- */
- @Override
- public void rollbackNetworkA (NetworkRollback rollback, String messageId, String notificationUrl) {
- String error;
- String serviceName = "RollbackNetworkA";
- MsoLogger.setServiceName (serviceName);
- // rollback may be null (e.g. if network already existed when Create was called)
- if (rollback == null) {
- LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null");
- return;
- }
-
- MsoLogger.setLogContext (rollback.getMsoRequest ());
- LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", "");
- // Use the synchronous method to perform the actual Create
- MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- try {
- networkAdapter.rollbackNetwork (rollback);
- MsoLogger.setServiceName (serviceName);
- } catch (NetworkException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e);
- // Build and send Asynchronous error response
- MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg);
- } catch (Exception e1) {
- error = "Error sending createNetwork notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
- LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ());
- // Build and send Asynchronous response
- try {
- NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null);
- } catch (Exception e) {
- error = "Error sending rollbackNetwork notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- return;
- }
-
- private org.openecomp.mso.adapters.network.async.client.NetworkRollback copyNrb (Holder <NetworkRollback> hNrb) {
- org.openecomp.mso.adapters.network.async.client.NetworkRollback cnrb = new org.openecomp.mso.adapters.network.async.client.NetworkRollback ();
-
- if (hNrb != null && hNrb.value != null) {
- org.openecomp.mso.adapters.network.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.network.async.client.MsoRequest ();
-
- cnrb.setCloudId (hNrb.value.getCloudId ());
- cmr.setRequestId (hNrb.value.getMsoRequest ().getRequestId ());
- cmr.setServiceInstanceId (hNrb.value.getMsoRequest ().getServiceInstanceId ());
- cnrb.setMsoRequest (cmr);
- cnrb.setNetworkId (hNrb.value.getNetworkId ());
- cnrb.setNetworkStackId (hNrb.value.getNetworkStackId ());
- cnrb.setNeutronNetworkId (hNrb.value.getNeutronNetworkId ());
- cnrb.setTenantId (hNrb.value.getTenantId ());
- cnrb.setNetworkType (hNrb.value.getNetworkType ());
- cnrb.setNetworkCreated (hNrb.value.getNetworkCreated ());
- cnrb.setNetworkName (hNrb.value.getNetworkName ());
- cnrb.setPhysicalNetwork (hNrb.value.getPhysicalNetwork ());
- List <Integer> vlansc = cnrb.getVlans ();
- List <Integer> vlansh = hNrb.value.getVlans ();
- if (vlansh != null) {
- vlansc.addAll (vlansh);
- }
- }
- return cnrb;
- }
-
- private NetworkAdapterNotify getNotifyEP (String notificationUrl) {
-
- URL warWsdlLoc = null;
- try {
- warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl");
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e);
- }
- if (warWsdlLoc == null) {
- LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found");
- } else {
- try {
- LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e);
- }
- }
-
- NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc,
- new QName ("http://org.openecomp.mso/networkNotify",
- "networkAdapterNotify"));
-
- NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort ();
-
- BindingProvider bp = (BindingProvider) notifyPort;
-
- URL epUrl = null;
- try {
- epUrl = new URL (notificationUrl);
- } catch (MalformedURLException e1) {
- LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1);
- }
-
- if(null != epUrl) {
- LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());
- bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());
- }
- else {
- LOGGER.debug ("Notification Endpoint URL is NULL: ");
- }
-
- // authentication
- try {
- Map <String, Object> reqCtx = bp.getRequestContext ();
- Map <String, List <String>> headers = new HashMap <> ();
-
- String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP,
- "",
- ENCRYPTION_KEY);
-
- String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ());
- reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers);
- headers.put ("Authorization", Collections.singletonList (basicAuth));
- } catch (Exception e) {
- String error1 = "Unable to set authorization in callback request" + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error1);
- }
-
- return notifyPort;
- }
-
- private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap (Holder <Map <String, String>> hMap) {
-
- CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
- CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry ();
-
- for (String key : sMap.keySet ()) {
- entry.setKey (key);
- entry.setValue (sMap.get (key));
- subnetIdMap.getEntry ().add (entry);
- }
- }
- return subnetIdMap;
- }
-
- private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap (Holder <Map <String, String>> hMap) {
-
- UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
- UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry ();
-
- for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey (key);
- entry.setValue (value);
- subnetIdMap.getEntry ().add (entry);
- }
- }
- return subnetIdMap;
- }
-
- private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap (Holder <Map <String, String>> hMap) {
-
- QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
- QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry ();
-
- for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey (key);
- entry.setValue (value);
- subnetIdMap.getEntry ().add (entry);
- }
- }
- return subnetIdMap;
- }
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
deleted file mode 100644
index 7f0f988a4f..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
+++ /dev/null
@@ -1,2243 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.network;
-
-import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import java.util.Optional;
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-import org.openecomp.mso.openstack.beans.NetworkInfo;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.Pool;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openecomp.mso.openstack.utils.MsoNeutronUtils;
-import org.openecomp.mso.openstack.utils.MsoNeutronUtils.NetworkType;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@WebService(serviceName = "NetworkAdapter", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapter", targetNamespace = "http://org.openecomp.mso/network")
-public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
-
- MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
-
- CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();
-
- protected MsoNeutronUtils neutron;
-
- protected MsoHeatUtils heat;
-
- protected MsoHeatUtilsWithUpdate heatWithUpdate;
-
- private static final String AIC3_NW_PROPERTY= "org.openecomp.mso.adapters.network.aic3nw";
- private static final String AIC3_NW="OS::ContrailV2::VirtualNetwork";
- public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER";
- private static final String VLANS = "vlans";
- private static final String PHYSICAL_NETWORK = "physical_network";
- private static final String UPDATE_NETWORK_CONTEXT = "UpdateNetwork";
- private static final String NETWORK_ID = "network_id";
- private static final String NETWORK_FQDN = "network_fqdn";
- private static final String CREATE_NETWORK_CONTEXT = "CreateNetwork";
- private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
- private static final String NEUTRON_MODE = "NEUTRON";
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck () {
- LOGGER.debug ("Health check call in Network Adapter");
- }
-
- /**
- * Do not use this constructor or the msoPropertiesFactory will be NULL.
- *
- * @see MsoNetworkAdapterImpl#MsoNetworkAdapterImpl(MsoPropertiesFactory)
- */
- public MsoNetworkAdapterImpl() {
- }
-
- /**
- * This constructor MUST be used if this class if called with the new operator.
- * @param msoPropFactory
-
- */
- public MsoNetworkAdapterImpl(MsoPropertiesFactory msoPropFactory,CloudConfigFactory cloudConfigFact) {
- this.msoPropertiesFactory = msoPropFactory;
- this.cloudConfigFactory=cloudConfigFact;
- neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
- heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
- heatWithUpdate = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
- }
-
- @Override
- public void createNetwork (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- Boolean failIfExists,
- Boolean backout,
- List <Subnet> subnets,
- MsoRequest msoRequest,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- Holder <String> networkFqdn = new Holder <> ();
- createNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- null,
- null,
- null,
- failIfExists,
- backout,
- subnets,
- null,
- null,
- msoRequest,
- networkId,
- neutronNetworkId,
- networkFqdn,
- subnetIdMap,
- rollback);
- }
-
- @Override
- public void createNetworkContrail (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkName,
- List <RouteTarget> routeTargets,
- String shared,
- String external,
- Boolean failIfExists,
- Boolean backout,
- List <Subnet> subnets,
- List <String> policyFqdns,
- List<String> routeTableFqdns,
- MsoRequest msoRequest,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <String> networkFqdn,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- createNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkName,
- null,
- null,
- routeTargets,
- shared,
- external,
- failIfExists,
- backout,
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- networkId,
- neutronNetworkId,
- networkFqdn,
- subnetIdMap,
- rollback);
- }
-
- /**
- * This is the "Create Network" web service implementation.
- * It will create a new Network of the requested type in the specified cloud
- * and tenant. The tenant must exist at the time this service is called.
- *
- * If a network with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog.
- * All such networks will have a similar configuration, based on the allowable
- * Openstack networking definitions. This includes basic networks, provider
- * networks (with a single VLAN), and multi-provider networks (one or more VLANs)
- *
- * Initially, all provider networks must be "vlan" type, and multiple segments in
- * a multi-provider network must be multiple VLANs on the same physical network.
- *
- * This service supports two modes of Network creation/update:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition. All Heat-based templates must support some subset of
- * the same input parameters: network_name, physical_network, vlan(s).
- *
- * The method returns the network ID and a NetworkRollback object. This latter
- * object can be passed as-is to the rollbackNetwork operation to undo everything
- * that was created. This is useful if a network is successfully created but
- * the orchestration fails on a subsequent operation.
- */
-
- protected void createNetwork (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- List <RouteTarget> routeTargets,
- String shared,
- String external,
- Boolean failIfExists,
- Boolean backout,
- List <Subnet> subnets,
- List <String> policyFqdns,
- List <String> routeTableFqdns,
- MsoRequest msoRequest,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <String> networkFqdn,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("CreateNetwork");
-
- LOGGER.debug ("*** CREATE Network: " + networkName
- + " of type "
- + networkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Build a default rollback object (no actions performed)
- NetworkRollback networkRollback = new NetworkRollback ();
- networkRollback.setCloudId (cloudSiteId);
- networkRollback.setTenantId (tenantId);
- networkRollback.setMsoRequest (msoRequest);
- networkRollback.setModelCustomizationUuid(modelCustomizationUuid);
-
- // tenant query is not required here.
- // If the tenant doesn’t exist, the Heat calls will fail anyway (when the HeatUtils try to obtain a token).
- // So this is just catching that error in a bit more obvious way up front.
-
- CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
- Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
- if (!cloudSiteOpt.isPresent())
- {
- String error = "Configuration Error. Stack " + networkName + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + " CloudSite does not exist in MSO Configuration";
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Configuration Error");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
- // Set the detailed error as the Exception 'message'
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
- }
-
- // Get a handle to the Catalog Database
-
- // Make sure DB connection is always closed
- try (CatalogDatabase db = getCatalogDB()) {
- NetworkResource networkResource = networkCheck(db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
- String mode = networkResource.getOrchestrationMode();
- NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
-
- if (NEUTRON_MODE.equals(mode)) {
-
- // See if the Network already exists (by name)
- NetworkInfo netInfo = null;
- long queryNetworkStarttime = System.currentTimeMillis();
- try {
- netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
- "QueryNetwork", null);
- } catch (MsoException me) {
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack",
- "OpenStack", "QueryNetwork", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack",
- me);
- me.addContext(CREATE_NETWORK_CONTEXT);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack");
- throw new NetworkException(me);
- }
-
- if (netInfo != null) {
- // Exists. If that's OK, return success with the network ID.
- // Otherwise, return an exception.
- if (failIfExists != null && failIfExists) {
- String error = "Create Nework: Network " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " with ID " + netInfo.getId();
- LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId,
- "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
- error);
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- } else {
- // Populate the outputs from the existing network.
- networkId.value = netInfo.getId();
- neutronNetworkId.value = netInfo.getId();
- rollback.value = networkRollback; // Default rollback - no updates performed
- String msg = "Found Existing network, status=" + netInfo.getStatus() + " for Neutron mode";
- LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
- MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus());
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- msg);
- }
- return;
- }
-
- long createNetworkStarttime = System.currentTimeMillis();
- try {
- netInfo = neutron.createNetwork(cloudSiteId,
- tenantId,
- neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
- "CreateNetwork", null);
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack",
- "OpenStack", "CreateNetwork", null);
- String error = "Create Network: type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
-
- throw new NetworkException(me);
- }
-
- // Note: ignoring MsoNetworkAlreadyExists because we already checked.
-
- // If reach this point, network creation is successful.
- // Since directly created via Neutron, networkId tracked by MSO is the same
- // as the neutron network ID.
- networkId.value = netInfo.getId();
- neutronNetworkId.value = netInfo.getId();
-
- networkRollback.setNetworkCreated(true);
- networkRollback.setNetworkId(netInfo.getId());
- networkRollback.setNeutronNetworkId(netInfo.getId());
- networkRollback.setNetworkType(networkType);
-
- LOGGER.debug("Network " + networkName + " created, id = " + netInfo.getId());
- } else if ("HEAT".equals(mode)) {
-
- //HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db
- .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
- if (heatTemplate == null) {
- String error = "Network error - undefined Heat Template. Network Type = " + networkType;
- LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
- "Openstack", "", MsoLogger.ErrorCode.DataError,
- "Network error - undefined Heat Template. Network Type = " + networkType);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
- }
-
- LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
-
- // "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate();
- template = template.replaceAll("\r\n", "\n");
-
- boolean aic3template = false;
- String aic3nw = AIC3_NW;
- try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
- .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
- } catch (MsoPropertiesException e) {
- String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError,
- "Exception - Unable to get properties", e);
- }
-
- if (template.contains(aic3nw))
- aic3template = true;
-
- // First, look up to see if the Network already exists (by name).
- // For HEAT orchestration of networks, the stack name will always match the network name
- StackInfo heatStack = null;
- long queryNetworkStarttime = System.currentTimeMillis();
- try {
- heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
- "QueryNetwork", null);
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack",
- "OpenStack", "QueryNetwork", null);
- String error = "Create Network (heat): query network " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) {
- // Stack exists. Return success or error depending on input directive
- if (failIfExists != null && failIfExists) {
- String error = "CreateNetwork: Stack " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " as " + heatStack.getCanonicalName();
- LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
- MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
- error);
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- } else {
- // Populate the outputs from the existing stack.
- networkId.value = heatStack.getCanonicalName();
- neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
- rollback.value = networkRollback; // Default rollback - no updates performed
- if (aic3template) {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
- }
- Map<String, Object> outputs = heatStack.getOutputs();
- Map<String, String> sMap = new HashMap<>();
- if (outputs != null) {
- for (String key : outputs.keySet()) {
- if (key != null && key.startsWith("subnet")) {
- if (aic3template) //one subnet_id output
- {
- Map<String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- } else //multiples subnet_%aaid% outputs
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put(key.substring("subnet_id_".length()), subnetUUId);
- }
- }
- }
- }
- subnetIdMap.value = sMap;
- LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
- MsoLogger.ErrorCode.DataError,
- "Found Existing network stack, status=" + heatStack.getStatus());
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc,
- "Found Existing network stack");
- }
- return;
- }
-
- // Ready to deploy the new Network
- // Build the common set of HEAT template parameters
- Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
-
- // Validate (and update) the input parameters against the DB definition
- // Shouldn't happen unless DB config is wrong, since all networks use same inputs
- // and inputs were already validated.
- try {
- stackParams = heat.validateStackParams(stackParams, heatTemplate);
- } catch (IllegalArgumentException e) {
- String error = "Create Network: Configuration Error: " + e.getMessage();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "",
- MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError,
- error);
- // Input parameters were not valid
- throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
- }
-
- if (subnets != null) {
- try {
- if (aic3template) {
- template = mergeSubnetsAIC3(template, subnets, stackParams);
- } else {
- template = mergeSubnets(template, subnets);
- }
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
- "Exception Create Network, merging subnets", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) {
- try {
- mergePolicyRefs(policyFqdns, stackParams);
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
- "Exception Create Network, merging policyRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) {
- try {
- mergeRouteTableRefs(routeTableFqdns, stackParams);
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
- "Exception Create Network, merging routeTableRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- // Deploy the network stack
- // Ignore MsoStackAlreadyExists exception because we already checked.
- try {
- if (backout == null)
- backout = true;
- heatStack = heat.createStack(cloudSiteId,
- tenantId,
- networkName,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes(),
- null,
- null,
- null,
- backout.booleanValue());
- } catch (MsoException me) {
- me.addContext(CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "",
- MsoLogger.ErrorCode.DataError, "Exception creating network", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- // Reach this point if createStack is successful.
-
- // For Heat-based orchestration, the MSO-tracked network ID is the heat stack,
- // and the neutronNetworkId is the network UUID returned in stack outputs.
- networkId.value = heatStack.getCanonicalName();
- neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
- if (aic3template) {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
- }
- Map<String, Object> outputs = heatStack.getOutputs();
- Map<String, String> sMap = new HashMap<>();
- if (outputs != null) {
- for (String key : outputs.keySet()) {
- if (key != null && key.startsWith("subnet")) {
- if (aic3template) //one subnet output expected
- {
- Map<String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- } else //multiples subnet_%aaid% outputs allowed
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put(key.substring("subnet_id_".length()), subnetUUId);
- }
- }
- }
- }
- subnetIdMap.value = sMap;
-
- rollback.value = networkRollback;
- // Populate remaining rollback info and response parameters.
- networkRollback.setNetworkStackId(heatStack.getCanonicalName());
- networkRollback.setNeutronNetworkId((String) heatStack.getOutputs().get(NETWORK_ID));
- networkRollback.setNetworkCreated(true);
- networkRollback.setNetworkType(networkType);
-
- LOGGER.debug("Network " + networkName + " successfully created via HEAT");
- }
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network");
- return;
- }
-
- @Override
- public void updateNetwork (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- List <Subnet> subnets,
- MsoRequest msoRequest,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- updateNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkId,
- networkName,
- physicalNetworkName,
- vlans,
- null,
- null,
- null,
- subnets,
- null,
- null,
- msoRequest,
- subnetIdMap,
- rollback);
-
- }
-
- @Override
- public void updateNetworkContrail (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- String networkName,
- List <RouteTarget> routeTargets,
- String shared,
- String external,
- List <Subnet> subnets,
- List <String> policyFqdns,
- List<String> routeTableFqdns,
- MsoRequest msoRequest,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- updateNetwork (cloudSiteId,
- tenantId,
- networkType,
- modelCustomizationUuid,
- networkId,
- networkName,
- null,
- null,
- routeTargets,
- shared,
- external,
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- subnetIdMap,
- rollback);
- }
-
- /**
- * This is the "Update Network" web service implementation.
- * It will update an existing Network of the requested type in the specified cloud
- * and tenant. The typical use will be to replace the VLANs with the supplied
- * list (to add or remove a VLAN), but other properties may be updated as well.
- *
- * There will be a pre-defined set of network types defined in the MSO Catalog.
- * All such networks will have a similar configuration, based on the allowable
- * Openstack networking definitions. This includes basic networks, provider
- * networks (with a single VLAN), and multi-provider networks (one or more VLANs).
- *
- * Initially, all provider networks must currently be "vlan" type, and multi-provider
- * networks must be multiple VLANs on the same physical network.
- *
- * This service supports two modes of Network update:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition. All Heat-based templates must support some subset of
- * the same input parameters: network_name, physical_network, vlan, segments.
- *
- * The method returns a NetworkRollback object. This object can be passed
- * as-is to the rollbackNetwork operation to undo everything that was updated.
- * This is useful if a network is successfully updated but orchestration
- * fails on a subsequent operation.
- */
- private void updateNetwork (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- List <RouteTarget> routeTargets,
- String shared,
- String external,
- List <Subnet> subnets,
- List <String> policyFqdns,
- List<String> routeTableFqdns,
- MsoRequest msoRequest,
- Holder <Map <String, String>> subnetIdMap,
- Holder <NetworkRollback> rollback) throws NetworkException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("UpdateNetwork");
- LOGGER.debug ("***UPDATE Network adapter with Network: " + networkName
- + " of type "
- + networkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId);
-
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Build a default rollback object (no actions performed)
- NetworkRollback networkRollback = new NetworkRollback ();
- networkRollback.setCloudId (cloudSiteId);
- networkRollback.setTenantId (tenantId);
- networkRollback.setMsoRequest (msoRequest);
-
- CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
- Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite (cloudSiteId);
- if (!cloudSiteOpt.isPresent()) {
- String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + " CloudSite does not exist in MSO Configuration";
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "CloudSite does not exist in MSO Configuration");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
- // Set the detailed error as the Exception 'message'
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
- }
-
- // Get a handle to the Catalog Database
-
- // Make sure DB connection is always closed
- try (CatalogDatabase db = getCatalogDB()) {
- NetworkResource networkResource = networkCheck(db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
- String mode = networkResource.getOrchestrationMode();
- NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
-
- if (NEUTRON_MODE.equals(mode)) {
-
- // Verify that the Network exists
- // For Neutron-based orchestration, the networkId is the Neutron Network UUID.
- NetworkInfo netInfo = null;
- long queryNetworkStarttime = System.currentTimeMillis();
- try {
- netInfo = neutron.queryNetwork(networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "QueryNetwork", null);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "Update Network (neutron): query " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
- "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- if (netInfo == null) {
- String error = "Update Nework: Network " + networkId
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
- error);
- // Does not exist. Throw an exception (can't update a non-existent network)
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
- long updateNetworkStarttime = System.currentTimeMillis();
- try {
- netInfo = neutron.updateNetwork(cloudSiteId,
- tenantId,
- networkId,
- neutronNetworkType,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "UpdateNetwork", null);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "Update Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack",
- "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- // Add the network ID and previously queried vlans to the rollback object
- networkRollback.setNetworkId(netInfo.getId());
- networkRollback.setNeutronNetworkId(netInfo.getId());
- networkRollback.setNetworkType(networkType);
- // Save previous parameters
- networkRollback.setNetworkName(netInfo.getName());
- networkRollback.setPhysicalNetwork(netInfo.getProvider());
- networkRollback.setVlans(netInfo.getVlans());
-
- LOGGER.debug("Network " + networkId + " updated, id = " + netInfo.getId());
- } else if ("HEAT".equals(mode)) {
-
- // First, look up to see that the Network already exists.
- // For Heat-based orchestration, the networkId is the network Stack ID.
- StackInfo heatStack = null;
- long queryStackStarttime = System.currentTimeMillis();
- try {
- heatStack = heatWithUpdate.queryStack(cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "QueryStack", null);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "UpdateNetwork (heat): query " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
- "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- if (heatStack == null || (heatStack.getStatus() == HeatStatus.NOTFOUND)) {
- String error = "UpdateNetwork: Stack " + networkName
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack",
- "queryStack", MsoLogger.ErrorCode.DataError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
- error);
- // Network stack does not exist. Return an error
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Get the previous parameters for rollback
- Map<String, Object> heatParams = heatStack.getParameters();
-
- String previousNetworkName = (String) heatParams.get("network_name");
- String previousPhysicalNetwork = (String) heatParams.get(PHYSICAL_NETWORK);
-
- List<Integer> previousVlans = new ArrayList<>();
- String vlansParam = (String) heatParams.get(VLANS);
- if (vlansParam != null) {
- for (String vlan : vlansParam.split(",")) {
- try {
- previousVlans.add(Integer.parseInt(vlan));
- } catch (NumberFormatException e) {
- LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "",
- MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e);
- }
- }
- }
- LOGGER.debug("Update Stack: Previous VLANS: " + previousVlans);
-
- // Ready to deploy the updated Network via Heat
-
- //HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db
- .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
- if (heatTemplate == null) {
- String error = "Network error - undefined Heat Template. Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
- "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError,
- "Network error - undefined Heat Template. Network Type=" + networkType);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
- error);
- throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
- }
-
- LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
-
- // "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate();
- template = template.replaceAll("\r\n", "\n");
-
- boolean aic3template = false;
- String aic3nw = AIC3_NW;
- try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
- .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
- } catch (MsoPropertiesException e) {
- String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError,
- "Exception - Unable to get properties", e);
- }
- if (template.contains(aic3nw))
- aic3template = true;
-
- // Build the common set of HEAT template parameters
- Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
-
- // Validate (and update) the input parameters against the DB definition
- // Shouldn't happen unless DB config is wrong, since all networks use same inputs
- try {
- stackParams = heatWithUpdate.validateStackParams(stackParams, heatTemplate);
- } catch (IllegalArgumentException e) {
- String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error");
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
- error);
- throw new NetworkException(error, MsoExceptionCategory.INTERNAL, e);
- }
-
- if (subnets != null) {
- try {
- if (aic3template) {
- template = mergeSubnetsAIC3(template, subnets, stackParams);
- } else {
- template = mergeSubnets(template, subnets);
- }
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "Update Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
- "Exception - UpdateNetwork mergeSubnets ", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- if (policyFqdns != null && aic3template) {
- try {
- mergePolicyRefs(policyFqdns, stackParams);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
- "Exception - UpdateNetwork mergePolicyRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) {
- try {
- mergeRouteTableRefs(routeTableFqdns, stackParams);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
- tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
- "Exception - UpdateNetwork mergeRouteTableRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException(me);
- }
- }
-
- // Update the network stack
- // Ignore MsoStackNotFound exception because we already checked.
- long updateStackStarttime = System.currentTimeMillis();
- try {
- heatStack = heatWithUpdate.updateStack(cloudSiteId,
- tenantId,
- networkId,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes());
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "UpdateStack", null);
- } catch (MsoException me) {
- me.addContext(UPDATE_NETWORK_CONTEXT);
- String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Exception - update network", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
-
- Map<String, Object> outputs = heatStack.getOutputs();
- Map<String, String> sMap = new HashMap<>();
- if (outputs != null) {
- for (String key : outputs.keySet()) {
- if (key != null && key.startsWith("subnet")) {
- if (aic3template) //one subnet output expected
- {
- Map<String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- } else //multiples subnet_%aaid% outputs allowed
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put(key.substring("subnet_id_".length()), subnetUUId);
- }
- }
- }
- }
- subnetIdMap.value = sMap;
-
- // Reach this point if createStack is successful.
- // Populate remaining rollback info and response parameters.
- networkRollback.setNetworkStackId(heatStack.getCanonicalName());
- if (null != outputs) {
- networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID));
- } else {
- LOGGER.debug("outputs is NULL");
- }
- networkRollback.setNetworkType(networkType);
- // Save previous parameters
- networkRollback.setNetworkName(previousNetworkName);
- networkRollback.setPhysicalNetwork(previousPhysicalNetwork);
- networkRollback.setVlans(previousVlans);
-
- rollback.value = networkRollback;
-
- LOGGER.debug("Network " + networkId + " successfully updated via HEAT");
- }
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network");
- return;
- }
-
- protected NetworkResource networkCheck (CatalogDatabase db,
- long startTime,
- String networkType,
- String modelCustomizationUuid,
- String networkName,
- String physicalNetworkName,
- List <Integer> vlans,
- List <RouteTarget> routeTargets,
- CloudSite cloudSite) throws NetworkException {
- // Retrieve the Network Resource definition
- NetworkResource networkResource = null;
- try {
- if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource(networkType);
- } else {
- networkResource = db
- .getNetworkResourceByModelCustUuid(modelCustomizationUuid);
- }
- if (networkResource == null) {
- String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:"
- + networkType
- + " or ModelCustomizationUUID:"
- + modelCustomizationUuid;
- LOGGER.error(MessageEnum.RA_UNKOWN_PARAM,
- "NetworkType/ModelCustomizationUUID", networkType + "/"
- + modelCustomizationUuid, "OpenStack", "",
- MsoLogger.ErrorCode.DataError,
- "Create/UpdateNetwork: Unknown NetworkType/ModelCustomizationUUID");
-
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
- LOGGER.debug("Got Network definition from Catalog: "
- + networkResource.toString());
-
- String mode = networkResource.getOrchestrationMode();
- NetworkType neutronNetworkType = NetworkType
- .valueOf(networkResource.getNeutronNetworkType());
-
- // All Networks are orchestrated via HEAT or Neutron
- if (!("HEAT".equals(mode) || NEUTRON_MODE.equals(mode))) {
- String error = "CreateNetwork: Configuration Error: Network Type = "
- + networkType;
- LOGGER.error(MessageEnum.RA_NETWORK_ORCHE_MODE_NOT_SUPPORT,
- mode, "OpenStack", "", MsoLogger.ErrorCode.DataError,
- "CreateNetwork: Configuration Error");
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
-
- throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
- }
-
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.getAic_version());
- if ((aicV.isMoreRecentThan(networkResource.getAicVersionMin()) || aicV
- .isTheSameVersion(networkResource.getAicVersionMin())) // aic
- // >=
- // min
- && (aicV.isTheSameVersion(networkResource
- .getAicVersionMax()) || !(aicV
- .isMoreRecentThan(networkResource
- .getAicVersionMax())))) // aic <= max
- {
- LOGGER.debug("Network Type:" + networkType + " VersionMin:"
- + networkResource.getAicVersionMin() + " VersionMax:"
- + networkResource.getAicVersionMax()
- + " supported on Cloud:" + cloudSite.getId()
- + " with AIC_Version:" + cloudSite.getAic_version());
- } else {
- String error = "Network Type:" + networkType + " Version_Min:"
- + networkResource.getAicVersionMin() + " Version_Max:"
- + networkResource.getAicVersionMax()
- + " not supported on Cloud:" + cloudSite.getId()
- + " with AIC_Version:" + cloudSite.getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
- MsoLogger.ErrorCode.DataError,
- "Network Type not supported on Cloud");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.DataError, error);
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Validate the Network parameters.
- String missing = validateNetworkParams(neutronNetworkType,
- networkName, physicalNetworkName, vlans, routeTargets);
- if (!missing.isEmpty()) {
- String error = "Create Network: Missing parameters: " + missing;
- LOGGER.error(MessageEnum.RA_MISSING_PARAM, missing,
- "OpenStack", "", MsoLogger.ErrorCode.DataError,
- "Create Network: Missing parameters");
-
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
- } finally {
- db.close();
- }
- return networkResource;
- }
-
- @Override
- public void queryNetwork (String cloudSiteId,
- String tenantId,
- String networkNameOrId,
- MsoRequest msoRequest,
- Holder <Boolean> networkExists,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <NetworkStatus> status,
- Holder <List <Integer>> vlans,
- Holder <Map <String, String>> subnetIdMap) throws NetworkException {
- queryNetworkInfo(cloudSiteId,
- tenantId,
- networkNameOrId,
- msoRequest,
- networkExists,
- networkId,
- neutronNetworkId,
- status,
- vlans,
- null,
- subnetIdMap);
- }
-
- @Override
- public void queryNetworkContrail (String cloudSiteId,
- String tenantId,
- String networkNameOrId,
- MsoRequest msoRequest,
- Holder <Boolean> networkExists,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <NetworkStatus> status,
- Holder <List <RouteTarget>> routeTargets,
- Holder <Map <String, String>> subnetIdMap) throws NetworkException {
- queryNetworkInfo(cloudSiteId,
- tenantId,
- networkNameOrId,
- msoRequest,
- networkExists,
- networkId,
- neutronNetworkId,
- status,
- null,
- routeTargets,
- subnetIdMap);
- }
-
- /**
- * This is the queryNetworkInfo method. It returns the existence and status of
- * the specified network, along with its Neutron UUID and list of VLANs.
- * This method attempts to find the network using both Heat and Neutron.
- * Heat stacks are first searched based on the provided network name/id.
- * If none is found, the Neutron is directly queried.
- */
- private void queryNetworkInfo(String cloudSiteId,
- String tenantId,
- String networkNameOrId,
- MsoRequest msoRequest,
- Holder <Boolean> networkExists,
- Holder <String> networkId,
- Holder <String> neutronNetworkId,
- Holder <NetworkStatus> status,
- Holder <List <Integer>> vlans,
- Holder <List <RouteTarget>> routeTargets,
- Holder <Map <String, String>> subnetIdMap) throws NetworkException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("QueryNetwork");
- LOGGER.debug ("*** QUERY Network with Network: " + networkNameOrId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- if (isNullOrEmpty (cloudSiteId)
- || isNullOrEmpty(tenantId)
- || isNullOrEmpty(networkNameOrId)) {
-
- String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId";
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkNameOrId", "OpenStack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
- }
-
- CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig();
- Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
- if (!cloudSiteOpt.isPresent())
- {
- String error = "Configuration Error. Stack " + networkNameOrId + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + " CloudSite does not exist in MSO Configuration";
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Configuration Error");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
- // Set the detailed error as the Exception 'message'
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
- }
-
- String mode;
- String neutronId;
- // Try Heat first, since networks may be named the same as the Heat stack
- StackInfo heatStack = null;
- long queryStackStarttime = System.currentTimeMillis ();
- try {
- heatStack = heat.queryStack (cloudSiteId, tenantId, networkNameOrId);
- LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- me.addContext ("QueryNetwork");
- String error = "Query Network (heat): " + networkNameOrId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "BPMN", "QueryStack", null);
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - Query Network (heat)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
- }
-
- // Populate the outputs based on the returned Stack information
- if (heatStack != null && heatStack.getStatus () != HeatStatus.NOTFOUND) {
- // Found it. Get the neutronNetworkId for further query
- Map <String, Object> outputs = heatStack.getOutputs ();
- neutronId = (String) outputs.get (NETWORK_ID);
- mode = "HEAT";
-
- Map <String, String> sMap = new HashMap <> ();
- if (outputs != null) {
- for (String key : outputs.keySet ()) {
- if (key != null && key.startsWith ("subnet_id_")) //multiples subnet_%aaid% outputs
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put (key.substring("subnet_id_".length()), subnetUUId);
- }
- else if (key != null && key.startsWith ("subnet")) //one subnet output expected
- {
- Map <String, String> map = getSubnetUUId(key, outputs, null);
- sMap.putAll(map);
- }
-
- }
- }
- subnetIdMap.value = sMap;
- } else {
- // Input ID was not a Heat stack ID. Try it directly in Neutron
- neutronId = networkNameOrId;
- mode = NEUTRON_MODE;
- }
-
- // Query directly against the Neutron Network for the details
- // no RouteTargets available for ContrailV2 in neutron net-show
- // networkId is heatStackId
- long queryNetworkStarttime = System.currentTimeMillis ();
- try {
- NetworkInfo netInfo = neutron.queryNetwork (neutronId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null);
- if (netInfo != null) {
- // Found. Populate the output elements
- networkExists.value = Boolean.TRUE;
- if ("HEAT".equals (mode)) {
- networkId.value = heatStack.getCanonicalName ();
- } else {
- networkId.value = netInfo.getId ();
- }
- neutronNetworkId.value = netInfo.getId ();
- status.value = netInfo.getStatus ();
- if (vlans != null)
- vlans.value = netInfo.getVlans ();
-
- LOGGER.debug ("Network " + networkNameOrId
- + " found ("
- + mode
- + "), ID = "
- + networkId.value
- + ("HEAT".equals (mode) ? ",NeutronId = " + neutronNetworkId.value : ""));
- } else {
- // Not found. Populate the status fields, leave the rest null
- networkExists.value = Boolean.FALSE;
- status.value = NetworkStatus.NOTFOUND;
- neutronNetworkId.value = null;
- if (vlans != null)
- vlans.value = new ArrayList<>();
-
- LOGGER.debug ("Network " + networkNameOrId + " not found");
- }
- } catch (MsoException me) {
- me.addContext ("QueryNetwork");
- String error = "Query Network (neutron): " + networkNameOrId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkNameOrId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Query Network (neutron)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully queried network");
- return;
- }
-
- /**
- * This is the "Delete Network" web service implementation.
- * It will delete a Network in the specified cloud and tenant.
- *
- * If the network is not found, it is treated as a success.
- *
- * This service supports two modes of Network creation/update/delete:
- * - via Heat Templates
- * - via Neutron API
- * The network orchestration mode for each network type is declared in its
- * catalog definition.
- *
- * For Heat-based orchestration, the networkId should be the stack ID.
- * For Neutron-based orchestration, the networkId should be the Neutron network UUID.
- *
- * The method returns nothing on success. Rollback is not possible for delete
- * commands, so any failure on delete will require manual fallout in the client.
- */
- @Override
- public void deleteNetwork (String cloudSiteId,
- String tenantId,
- String networkType,
- String modelCustomizationUuid,
- String networkId,
- MsoRequest msoRequest,
- Holder <Boolean> networkDeleted) throws NetworkException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteNetwork");
- LOGGER.debug ("*** DELETE Network adapter with Network: " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Get a handle to the Catalog Database
-
- // Make sure DB connection is always closed
- try (CatalogDatabase db = getCatalogDB()) {
- if (isNullOrEmpty(cloudSiteId)
- || isNullOrEmpty(tenantId)
- || isNullOrEmpty(networkId)) {
- String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId";
- LOGGER.error(MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "",
- MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
- LOGGER
- .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new NetworkException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Retrieve the Network Resource definition
- NetworkResource networkResource = null;
- if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource(networkType);
- } else if (!isNullOrEmpty(networkType)) {
- networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
- }
- String mode = "";
- if (networkResource != null) {
- LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
-
- mode = networkResource.getOrchestrationMode();
- }
-
- if (NEUTRON_MODE.equals(mode)) {
- long deleteNetworkStarttime = System.currentTimeMillis();
- try {
- // The deleteNetwork function in MsoNeutronUtils returns success if the network
- // was not found. So don't bother to query first.
- boolean deleted = neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "DeleteNetwork", null);
- networkDeleted.value = deleted;
- } catch (MsoException me) {
- me.addContext("DeleteNetwork");
- String error = "Delete Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
- MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
- } else { // DEFAULT to ("HEAT".equals (mode))
- long deleteStackStarttime = System.currentTimeMillis();
-
- try {
- // The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted.
- // So query first to report back if stack WAS deleted or just NOTOFUND
- StackInfo heatStack = null;
- heatStack = heat.queryStack(cloudSiteId, tenantId, networkId);
- if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
- heat.deleteStack(tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "DeleteStack", null);
- networkDeleted.value = true;
- } else {
- networkDeleted.value = false;
- }
- } catch (MsoException me) {
- me.addContext("DeleteNetwork");
- String error = "Delete Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
- MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
- }
- }
-
- // On success, nothing is returned.
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully deleted network");
- return;
- }
-
- public CatalogDatabase getCatalogDB() {
- return CatalogDatabase.getInstance();
- }
-
- public CloudConfigFactory getCloudConfigFactory() {
- return cloudConfigFactory;
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation.
- * A rollback object is returned to the client in a successful creation
- * response. The client can pass that object as-is back to the rollbackVnf
- * operation to undo the creation.
- *
- * The rollback includes removing the VNF and deleting the tenant if the
- * tenant did not exist prior to the VNF creation.
- */
- @Override
- public void rollbackNetwork (NetworkRollback rollback) throws NetworkException {
- MsoLogger.setServiceName ("RollbackNetwork");
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- if (rollback == null) {
- LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "Openstack", "", MsoLogger.ErrorCode.DataError, "rollback is null");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "No action to perform");
- return;
- }
-
- MsoLogger.setLogContext (rollback.getMsoRequest());
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudId ();
- String tenantId = rollback.getTenantId ();
- String networkId = rollback.getNetworkStackId ();
- String networkType = rollback.getNetworkType ();
- String modelCustomizationUuid = rollback.getModelCustomizationUuid();
-
- LOGGER.debug ("*** ROLLBACK Network " + networkId + " in " + cloudSiteId + "/" + tenantId);
-
- // rollback may be null (e.g. if network already existed when Create was called)
- // Get a handle to the Catalog Database
-
- // Make sure DB connection is always closed
- try (CatalogDatabase db = getCatalogDB()) {
-
- // Retrieve the Network Resource definition
- NetworkResource networkResource = null;
- if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource(networkType);
- } else {
- networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
- }
- String mode = "";
- if (networkResource != null) {
-
- LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
-
- mode = networkResource.getOrchestrationMode();
- }
-
- if (rollback.getNetworkCreated()) {
- // Rolling back a newly created network, so delete it.
- if (NEUTRON_MODE.equals(mode)) {
- // Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, getCloudConfigFactory());
- long deleteNetworkStarttime = System.currentTimeMillis();
- try {
- // The deleteNetwork function in MsoNeutronUtils returns success if the network
- // was not found. So don't bother to query first.
- neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "DeleteNetwork", null);
- } catch (MsoException me) {
- me.addContext("RollbackNetwork");
- String error = "Rollback Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER
- .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)",
- me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
- } else { // DEFAULT to if ("HEAT".equals (mode))
- // Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- getCloudConfigFactory());
- long deleteStackStarttime = System.currentTimeMillis();
- try {
- // The deleteStack function in MsoHeatUtils returns success if the stack
- // was not found. So don't bother to query first.
- heat.deleteStack(tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
- "DeleteStack", null);
- } catch (MsoException me) {
- me.addContext("RollbackNetwork");
- String error = "Rollback Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER
- .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException(me);
- }
- }
- }
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network");
- return;
- }
-
- private String validateNetworkParams (NetworkType neutronNetworkType,
- String networkName,
- String physicalNetwork,
- List <Integer> vlans,
- List <RouteTarget> routeTargets) {
- String sep = "";
- StringBuilder missing = new StringBuilder ();
- if (isNullOrEmpty(networkName)) {
- missing.append ("networkName");
- sep = ",";
- }
-
- if (neutronNetworkType == NetworkType.PROVIDER || neutronNetworkType == NetworkType.MULTI_PROVIDER) {
- if (isNullOrEmpty(physicalNetwork)) {
- missing.append (sep).append ("physicalNetworkName");
- sep = ",";
- }
- if (vlans == null || vlans.isEmpty ()) {
- missing.append (sep).append (VLANS);
- }
- }
-
- return missing.toString ();
- }
-
- protected Map <String, Object> populateNetworkParams (NetworkType neutronNetworkType,
- String networkName,
- String physicalNetwork,
- List <Integer> vlans,
- List <RouteTarget> routeTargets,
- String shared,
- String external,
- boolean aic3template) {
- // Build the common set of HEAT template parameters
- Map <String, Object> stackParams = new HashMap <> ();
- stackParams.put ("network_name", networkName);
-
- if (neutronNetworkType == NetworkType.PROVIDER) {
- // For Provider type
- stackParams.put (PHYSICAL_NETWORK, physicalNetwork);
- stackParams.put ("vlan", vlans.get (0).toString ());
- } else if (neutronNetworkType == NetworkType.MULTI_PROVIDER) {
- // For Multi-provider, PO supports a custom resource extension of ProviderNet.
- // It supports all ProviderNet properties except segmentation_id, and adds a
- // comma-separated-list of VLANs as a "segments" property.
- // Note that this does not match the Neutron definition of Multi-Provider network,
- // which contains a list of 'segments', each having physical_network, network_type,
- // and segmentation_id.
- StringBuilder buf = new StringBuilder ();
- String sep = "";
- for (Integer vlan : vlans) {
- buf.append (sep).append (vlan.toString ());
- sep = ",";
- }
- String csl = buf.toString ();
-
- stackParams.put (PHYSICAL_NETWORK, physicalNetwork);
- stackParams.put (VLANS, csl);
- }
-
- if (routeTargets != null) {
-
- String rtGlobal = "";
- String rtImport = "";
- String rtExport = "";
- String sep = "";
- for (RouteTarget rt : routeTargets) {
- boolean rtIsNull = false;
- if (rt != null) {
- String routeTarget = rt.getRouteTarget();
- String routeTargetRole = rt.getRouteTargetRole();
- LOGGER.debug("Checking for an actually null route target: " + rt.toString());
- if (routeTarget == null || routeTarget.equals("") || routeTarget.equalsIgnoreCase("null"))
- rtIsNull = true;
- if (routeTargetRole == null || routeTargetRole.equals("") || routeTargetRole.equalsIgnoreCase("null"))
- rtIsNull = true;
- } else {
- rtIsNull = true;
- }
- if (!rtIsNull)
- {
- LOGGER.debug("Input RT:" + rt.toString());
- String role = rt.getRouteTargetRole();
- String rtValue = rt.getRouteTarget();
-
- if ("IMPORT".equalsIgnoreCase(role))
- {
- sep = rtImport.isEmpty() ? "" : ",";
- rtImport = aic3template ? rtImport + sep + "target:" + rtValue : rtImport + sep + rtValue ;
- }
- else if ("EXPORT".equalsIgnoreCase(role))
- {
- sep = rtExport.isEmpty() ? "" : ",";
- rtExport = aic3template ? rtExport + sep + "target:" + rtValue : rtExport + sep + rtValue ;
- }
- else // covers BOTH, empty etc
- {
- sep = rtGlobal.isEmpty() ? "" : ",";
- rtGlobal = aic3template ? rtGlobal + sep + "target:" + rtValue : rtGlobal + sep + rtValue ;
- }
- }
- }
-
- if (!rtImport.isEmpty())
- {
- stackParams.put ("route_targets_import", rtImport);
- }
- if (!rtExport.isEmpty())
- {
- stackParams.put ("route_targets_export", rtExport);
- }
- if (!rtGlobal.isEmpty())
- {
- stackParams.put ("route_targets", rtGlobal);
- }
- }
- if (isNullOrEmpty(shared)) {
- stackParams.put ("shared", "False");
- } else {
- stackParams.put ("shared", shared);
- }
- if (isNullOrEmpty(external)) {
- stackParams.put ("external", "False");
- } else {
- stackParams.put ("external", external);
- }
- return stackParams;
- }
-
-
-
- /** policyRef_list structure in stackParams
- [
- {
- "network_policy_refs_data_sequence": {
- "network_policy_refs_data_sequence_major": "1",
- "network_policy_refs_data_sequence_minor": "0"
- }
- },
- {
- "network_policy_refs_data_sequence": {
- "network_policy_refs_data_sequence_major": "2",
- "network_policy_refs_data_sequence_minor": "0"
- }
- }
- ]
- **/
- private void mergePolicyRefs(List <String> pFqdns, Map <String, Object> stackParams) throws MsoException {
- //Resource Property
- List<ContrailPolicyRef> prlist = new ArrayList <> ();
- int index = 1;
- for (String pf : pFqdns) {
- if (!isNullOrEmpty(pf))
- {
- ContrailPolicyRef pr = new ContrailPolicyRef();
- pr.populate(String.valueOf(index), "0");
- index++;
- LOGGER.debug("Contrail PolicyRefs Data:" + pr.toString());
- prlist.add(pr);
- }
- }
-
- String jsonString = null;
- if (!prlist.isEmpty())
- {
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- jsonString = mapper.writeValueAsString(prlist);
- LOGGER.debug("Json PolicyRefs Data:" + jsonString);
- }
- catch (Exception e)
- {
- String error = "Error creating JsonNode for policyRefs Data";
- LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "Openstack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception creating JsonNode for policyRefs Data", e);
- throw new MsoAdapterException (error);
- }
- }
- //update parameters
- if (pFqdns != null && !isNullOrEmpty(jsonString))
- {
- StringBuilder buf = new StringBuilder ();
- String sep = "";
- for (String pf : pFqdns) {
- if (!isNullOrEmpty(pf))
- {
- buf.append (sep).append (pf);
- sep = ",";
- }
- }
- String csl = buf.toString ();
- stackParams.put ("policy_refs", csl);
- stackParams.put ("policy_refsdata", jsonString);
- LOGGER.debug ("StackParams updated with policy refs:" + csl + " refs data:" + jsonString);
- }
- return;
- }
-
- private void mergeRouteTableRefs(List <String> rtFqdns, Map <String, Object> stackParams) throws MsoException {
-
- //update parameters
- if (rtFqdns != null)
- {
- StringBuilder buf = new StringBuilder ();
- String sep = "";
- for (String rtf : rtFqdns) {
- if (!isNullOrEmpty(rtf))
- {
- buf.append (sep).append (rtf);
- sep = ",";
- }
- }
- String csl = buf.toString ();
- stackParams.put ("route_table_refs", csl);
- }
-
- LOGGER.debug ("StackParams updated with route_table refs");
- return;
- }
-
-
- /*** Subnet Output structure from Juniper
- {
- "ipam_subnets": [
- {
- "subnet": {
- "ip_prefix": "10.100.1.0",
- "ip_prefix_len": 28
- },
- "addr_from_start": null,
- "enable_dhcp": false,
- "default_gateway": "10.100.1.1",
- "dns_nameservers": [],
- "dhcp_option_list": null,
- "subnet_uuid": "10391fbf-6b9c-4160-825d-2d018b7649cf",
- "allocation_pools": [
- {
- "start": "10.100.1.3",
- "end": "10.100.1.5"
- },
- {
- "start": "10.100.1.6",
- "end": "10.100.1.9"
- }
- ],
- "host_routes": null,
- "dns_server_address": "10.100.1.13",
- "subnet_name": "subnet_MsoNW1_692c9032-e1a2-4d64-828c-7b9a4fcc05b0"
- },
- {
- "subnet": {
- "ip_prefix": "10.100.2.16",
- "ip_prefix_len": 28
- },
- "addr_from_start": null,
- "enable_dhcp": true,
- "default_gateway": "10.100.2.17",
- "dns_nameservers": [],
- "dhcp_option_list": null,
- "subnet_uuid": "c7aac5ea-66fe-443a-85f9-9c38a608c0f6",
- "allocation_pools": [
- {
- "start": "10.100.2.18",
- "end": "10.100.2.20"
- }
- ],
- "host_routes": null,
- "dns_server_address": "10.100.2.29",
- "subnet_name": "subnet_MsoNW1_692c9032-e1a2-4d64-828c-7b9a4fcc05b1"
- }
- ],
- "host_routes": null
- }
- ***/
- private String mergeSubnetsAIC3 (String heatTemplate, List <Subnet> subnets, Map <String, Object> stackParams) throws MsoException {
-
- //Resource Property
- List<ContrailSubnet> cslist = new ArrayList <> ();
- for (Subnet subnet : subnets) {
- ContrailSubnet cs = new ContrailSubnet();
- LOGGER.debug("Input Subnet:" + subnet.toString());
- cs.populateWith(subnet);
- LOGGER.debug("Contrail Subnet:" + cs.toString());
- cslist.add(cs);
- }
-
- String jsonString = null;
- if (!cslist.isEmpty())
- {
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- jsonString = mapper.writeValueAsString(cslist);
- LOGGER.debug("Json Subnet List:" + jsonString);
- }
- catch (Exception e)
- {
- String error = "Error creating JsonNode from input subnets";
- LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.DataError, "Exception creating JsonNode from input subnets", e);
- throw new MsoAdapterException (error);
- }
- }
- //update parameters
- if (!isNullOrEmpty(jsonString))
- {
- stackParams.put ("subnet_list", jsonString);
- }
- //Outputs - All subnets are in one ipam_subnets structure
- String outputTempl = " subnet:\n" + " description: Openstack subnet identifier\n"
- + " value: { get_attr: [network, network_ipam_refs, 0, attr]}\n";
-
- // append outputs in heatTemplate
- int outputsIdx = heatTemplate.indexOf ("outputs:");
- heatTemplate = insertStr (heatTemplate, outputTempl, outputsIdx + 8);
- LOGGER.debug ("Template updated with all AIC3.0 subnets:" + heatTemplate);
- return heatTemplate;
- }
-
-
- private String mergeSubnets (String heatTemplate, List <Subnet> subnets) throws MsoException {
-
- String resourceTempl = " subnet_%subnetId%:\n" + " type: OS::Neutron::Subnet\n"
- + " properties:\n"
- + " name: %name%\n"
- + " network_id: { get_resource: network }\n"
- + " cidr: %cidr%\n";
-
- /* make these optional
- + " ip_version: %ipversion%\n"
- + " enable_dhcp: %enabledhcp%\n"
- + " gateway_ip: %gatewayip%\n"
- + " allocation_pools:\n"
- + " - start: %poolstart%\n"
- + " end: %poolend%\n";
-
- */
-
- String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n"
- + " value: {get_resource: subnet_%subnetId%}\n";
-
- StringBuilder curR;
- String curO;
- StringBuilder resourcesBuf = new StringBuilder ();
- StringBuilder outputsBuf = new StringBuilder ();
- for (Subnet subnet : subnets) {
-
- // build template for each subnet
- curR = new StringBuilder(resourceTempl);
- if (subnet.getSubnetId () != null) {
- curR = new StringBuilder(curR.toString().replace("%subnetId%", subnet.getSubnetId()));
- } else {
- String error = "Missing Required AAI SubnetId for subnet in HEAT Template";
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required AAI ID for subnet in HEAT Template");
- throw new MsoAdapterException (error);
- }
-
- if (subnet.getSubnetName () != null) {
- curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetName()));
- } else {
- curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetId()));
- }
-
- if (subnet.getCidr () != null) {
- curR = new StringBuilder(curR.toString().replace("%cidr%", subnet.getCidr()));
- } else {
- String error = "Missing Required cidr for subnet in HEAT Template";
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required cidr for subnet in HEAT Template");
- throw new MsoAdapterException (error);
- }
-
- if (subnet.getIpVersion () != null) {
- curR.append(" ip_version: " + subnet.getIpVersion() + "\n");
- }
- if (subnet.getEnableDHCP () != null) {
- curR.append(" enable_dhcp: ").append(Boolean.toString(subnet.getEnableDHCP())).append("\n");
- }
- if (subnet.getGatewayIp () != null && !subnet.getGatewayIp ().isEmpty() ) {
- curR.append(" gateway_ip: " + subnet.getGatewayIp() + "\n");
- }
-
- if (subnet.getAllocationPools() != null) {
- curR.append(" allocation_pools:\n");
- for (Pool pool : subnet.getAllocationPools())
- {
- if (!isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd()))
- {
- curR.append(" - start: " + pool.getStart() + "\n");
- curR.append(" end: " + pool.getEnd() + "\n");
- }
- }
- }
-
- resourcesBuf.append (curR);
-
- curO = outputTempl;
- curO = curO.replace ("%subnetId%", subnet.getSubnetId ());
-
- outputsBuf.append (curO);
-
- }
- // append resources and outputs in heatTemplate
- LOGGER.debug ("Tempate initial:" + heatTemplate);
- int outputsIdx = heatTemplate.indexOf ("outputs:");
- heatTemplate = insertStr (heatTemplate, outputsBuf.toString (), outputsIdx + 8);
- int resourcesIdx = heatTemplate.indexOf ("resources:");
- heatTemplate = insertStr (heatTemplate, resourcesBuf.toString (), resourcesIdx + 10);
-
- LOGGER.debug ("Template updated with all subnets:" + heatTemplate);
- return heatTemplate;
- }
-
- private Map <String, String> getSubnetUUId(String key, Map <String, Object> outputs, List <Subnet> subnets) {
-
- Map <String, String> sMap = new HashMap <> ();
-
- try{
- Object obj = outputs.get(key);
- ObjectMapper mapper = new ObjectMapper();
- String jStr = mapper.writeValueAsString(obj);
- LOGGER.debug ("Subnet_Ipam Output JSON String:" + obj.getClass() + " " + jStr);
-
- JsonNode rootNode = mapper.readTree(jStr);
- for (JsonNode sNode : rootNode.path("ipam_subnets"))
- {
- LOGGER.debug("Output Subnet Node" + sNode.toString());
- String name = sNode.path("subnet_name").textValue();
- String uuid = sNode.path("subnet_uuid").textValue();
- String aaiId = name; // default
- // try to find aaiId for name in input subnetList
- if (subnets != null)
- {
- for (Subnet subnet : subnets)
- {
- if ( subnet != null && !isNullOrEmpty(subnet.getSubnetName()))
- {
- if (subnet.getSubnetName().equals(name))
- {
- aaiId = subnet.getSubnetId();
- break;
- }
- }
- }
- }
- sMap.put(aaiId, uuid); //bpmn needs aaid to uuid map
- }
- }
- catch (Exception e)
- {
- LOGGER.error (MessageEnum.RA_MARSHING_ERROR, "error getting subnet-uuids", "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception getting subnet-uuids", e);
- }
-
- LOGGER.debug ("Return sMap" + sMap.toString());
- return sMap;
- }
-
- private static String insertStr (String template, String snippet, int index) {
-
- String updatedTemplate;
-
- LOGGER.debug ("Index:" + index + " Snippet:" + snippet);
-
- String templateBeg = template.substring (0, index);
- String templateEnd = template.substring (index);
-
- updatedTemplate = templateBeg + "\n" + snippet + templateEnd;
-
- LOGGER.debug ("Template updated with a subnet:" + updatedTemplate);
- return updatedTemplate;
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java
deleted file mode 100644
index 80d3331d42..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.network;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-
-import org.apache.http.HttpStatus;
-
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkError;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkError;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkError;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkError;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkError;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-@Path("/v1/networks")
-public class NetworkAdapterRest {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static final String TESTING_KEYWORD = "___TESTING___";
- private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- private final MsoNetworkAdapterImpl adapter = new MsoNetworkAdapterImpl(msoPropertiesFactory, cloudConfigFactory);
-
- @POST
- @Path("")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createNetwork(CreateNetworkRequest req) {
- LOGGER.debug("createNetwork enter: " + req.toJsonString());
- CreateNetworkTask task = new CreateNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response
- .status(task.getStatusCode())
- .entity(task.getGenericEntityResponse())
- .build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while create network", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("createNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateNetworkTask implements Runnable {
- private final CreateNetworkRequest req;
- private CreateNetworkResponse response = null;
- private CreateNetworkError eresp = null;
- private boolean sendxml;
-
- public CreateNetworkTask(CreateNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<CreateNetworkResponse>(response) {}
- : new GenericEntity<CreateNetworkError>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- LOGGER.debug ("CreateNetworkTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<String> networkFqdn = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
-
- String cloudsite = req.getCloudSiteId();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new NetworkException("testing.");
- }
- networkId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- neutronNetworkId.value = "55e55884-28fa-11e6-8971-0017f20fe1b8";
- networkFqdn.value = "086f70b6-28fb-11e6-8260-0017f20fe1b8";
- subnetIdMap.value = testMap();
- rollback.value = new NetworkRollback();
- } else if (req.isContrailRequest()) {
- ContrailNetwork ctn = req.getContrailNetwork();
- if (ctn == null) {
- ctn = new ContrailNetwork();
- req.setContrailNetwork(ctn);
- }
- adapter.createNetworkContrail(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getNetworkType(),
- req.getModelCustomizationUuid(),
- req.getNetworkName(),
- req.getContrailNetwork().getRouteTargets(),
- req.getContrailNetwork().getShared(),
- req.getContrailNetwork().getExternal(),
- req.getFailIfExists(),
- req.getBackout(),
- req.getSubnets(),
- req.getContrailNetwork().getPolicyFqdns(),
- req.getContrailNetwork().getRouteTableFqdns(),
- req.getMsoRequest(),
- networkId,
- neutronNetworkId,
- networkFqdn,
- subnetIdMap,
- rollback);
- } else {
- ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
- if (pvn == null) {
- pvn = new ProviderVlanNetwork();
- req.setProviderVlanNetwork(pvn);
- }
- adapter.createNetwork(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getNetworkType(),
- req.getModelCustomizationUuid(),
- req.getNetworkName(),
- req.getProviderVlanNetwork().getPhysicalNetworkName(),
- req.getProviderVlanNetwork().getVlans(),
- req.getFailIfExists(),
- req.getBackout(),
- req.getSubnets(),
- req.getMsoRequest(),
- networkId,
- neutronNetworkId,
- subnetIdMap,
- rollback);
- }
- response = new CreateNetworkResponse(
- req.getNetworkId(),
- neutronNetworkId.value,
- rollback.value.getNetworkStackId(),
- networkFqdn.value,
- rollback.value.getNetworkCreated(),
- subnetIdMap.value,
- rollback.value,
- req.getMessageId());
- } catch (NetworkException e) {
- LOGGER.debug ("Exception:", e);
- eresp = new CreateNetworkError(
- e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug ("CreateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiNetworkId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteNetwork(
- @PathParam("aaiNetworkId") String aaiNetworkId,
- DeleteNetworkRequest req)
- {
- LOGGER.debug("deleteNetwork enter: " + req.toJsonString());
- if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("A&AI NetworkId in URL ("+aaiNetworkId+") does not match content ("+req.getNetworkId()+")")
- .build();
- }
- DeleteNetworkTask task = new DeleteNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response
- .status(task.getStatusCode())
- .entity(task.getGenericEntityResponse())
- .build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while delete network", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("deleteNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteNetworkTask implements Runnable {
- private final DeleteNetworkRequest req;
- private DeleteNetworkResponse response = null;
- private DeleteNetworkError eresp = null;
- private boolean sendxml;
-
- public DeleteNetworkTask(DeleteNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<DeleteNetworkResponse>(response) {}
- : new GenericEntity<DeleteNetworkError>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- LOGGER.debug("DeleteNetworkTask start");
- try {
- Holder<Boolean> networkDeleted = new Holder<>();
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- networkDeleted.value = true;
- } else {
- adapter.deleteNetwork(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getNetworkType(),
- req.getModelCustomizationUuid(),
- req.getNetworkStackId(),
- req.getMsoRequest(),
- networkDeleted);
- }
- response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId());
- } catch (NetworkException e) {
- LOGGER.debug ("Exception:", e);
- eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug("DeleteNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @GET
- @Path("{aaiNetworkId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryNetwork(
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("tenantId") String tenantId,
- @QueryParam("networkStackId") String networkStackId,
- @QueryParam("skipAAI") String skipAAI,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @PathParam("aaiNetworkId") String aaiNetworkId)
- {
- //This request responds synchronously only
- LOGGER.debug ("Query network enter:" + aaiNetworkId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null);
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<RouteTarget>> routeTargets = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
-
- adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest,
- networkExists, networkId, neutronNetworkId, status, routeTargets, subnetIdMap);
-
- if (!networkExists.value) {
- LOGGER.debug ("network not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- LOGGER.debug ("network found" + networkId.value + ", status=" + status.value);
- resp.setNetworkExists(networkExists.value);
- resp.setNetworkId(networkId.value);
- resp.setNeutronNetworkId(neutronNetworkId.value);
- resp.setNetworkStatus(status.value);
- resp.setRouteTargets(routeTargets.value);
- resp.setSubnetIdMap(subnetIdMap.value);
- }
- LOGGER.debug ("Query network exit");
- return Response
- .status(respStatus)
- .entity(new GenericEntity<QueryNetworkResponse>(resp) {})
- .build();
- } catch (NetworkException e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, aaiNetworkId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception when query VNF", e);
- QueryNetworkError err = new QueryNetworkError();
- err.setMessage(e.getMessage());
- err.setCategory(MsoExceptionCategory.INTERNAL);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<QueryNetworkError>(err) {})
- .build();
- }
- }
-
- @DELETE
- @Path("{aaiNetworkId}/rollback")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackNetwork(
- RollbackNetworkRequest req)
- {
- LOGGER.debug("rollbackNetwork enter: " + req.toJsonString());
- RollbackNetworkTask task = new RollbackNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response
- .status(task.getStatusCode())
- .entity(task.getGenericEntityResponse())
- .build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in rollbackNetwork", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug("rollbackNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackNetworkTask implements Runnable {
- private final RollbackNetworkRequest req;
- private RollbackNetworkResponse response = null;
- private RollbackNetworkError eresp = null;
- private boolean sendxml;
-
- public RollbackNetworkTask(RollbackNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<RollbackNetworkResponse>(response) {}
- : new GenericEntity<RollbackNetworkError>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- LOGGER.debug("RollbackNetworkTask start");
- try {
- NetworkRollback nwr = req.getNetworkRollback();
- adapter.rollbackNetwork(nwr);
- response = new RollbackNetworkResponse(true, req.getMessageId());
- } catch (NetworkException e) {
- LOGGER.debug ("Exception:", e);
- eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug("RollbackNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @PUT
- @Path("{aaiNetworkId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response updateNetwork(
- @PathParam("aaiNetworkId") String aaiNetworkId,
- UpdateNetworkRequest req)
- {
- LOGGER.debug("updateNetwork enter: " + req.toJsonString());
- if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("A&AI NetworkId in URL ("+aaiNetworkId+") does not match content ("+req.getNetworkId()+")")
- .build();
- }
- UpdateNetworkTask task = new UpdateNetworkTask(req);
- if (req.isSynchronous()) {
- // This is a synchronous request
- task.run();
- return Response
- .status(task.getStatusCode())
- .entity(task.getGenericEntityResponse())
- .build();
- } else {
- // This is an asynchronous request
- try {
- Thread t1 = new Thread(task);
- t1.start();
- } catch (Exception e) {
- // problem handling create, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_UPDATE_NETWORK_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in updateNetwork", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("updateNetwork exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateNetworkTask implements Runnable {
- private final UpdateNetworkRequest req;
- private UpdateNetworkResponse response = null;
- private UpdateNetworkError eresp = null;
- private boolean sendxml;
-
- public UpdateNetworkTask(UpdateNetworkRequest req) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<UpdateNetworkResponse>(response) {}
- : new GenericEntity<UpdateNetworkError>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- LOGGER.debug("UpdateNetworkTask start");
- try {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<> ();
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- subnetIdMap.value = testMap();
- NetworkRollback rb = new NetworkRollback ();
- rb.setCloudId(req.getCloudSiteId());
- rb.setTenantId(req.getTenantId());
- rb.setMsoRequest(req.getMsoRequest());
- rollback.value = rb;
- } else if (req.isContrailRequest()) {
- ContrailNetwork ctn = req.getContrailNetwork();
- if (ctn == null) {
- ctn = new ContrailNetwork();
- req.setContrailNetwork(ctn);
- }
- adapter.updateNetworkContrail(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getNetworkType(),
- req.getModelCustomizationUuid(),
- req.getNetworkStackId(),
- req.getNetworkName(),
- req.getContrailNetwork().getRouteTargets(),
- req.getContrailNetwork().getShared(),
- req.getContrailNetwork().getExternal(),
- req.getSubnets(),
- req.getContrailNetwork().getPolicyFqdns(),
- req.getContrailNetwork().getRouteTableFqdns(),
- req.getMsoRequest(),
- subnetIdMap,
- rollback);
- } else {
- ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
- if (pvn == null) {
- pvn = new ProviderVlanNetwork();
- req.setProviderVlanNetwork(pvn);
- }
- adapter.updateNetwork(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getNetworkType(),
- req.getModelCustomizationUuid(),
- req.getNetworkStackId(),
- req.getNetworkName(),
- req.getProviderVlanNetwork().getPhysicalNetworkName(),
- req.getProviderVlanNetwork().getVlans(),
- req.getSubnets(),
- req.getMsoRequest(),
- subnetIdMap,
- rollback);
- }
- response = new UpdateNetworkResponse(
- req.getNetworkId(),
- null, // NeutronNetworkId is not available from an update
- subnetIdMap.value,
- req.getMessageId());
- } catch (NetworkException e) {
- LOGGER.debug ("Exception:", e);
- eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- // This is asynch, so POST response back to caller
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug("UpdateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- public static Map<String, String> testMap() {
- Map<String, String> m = new HashMap<>();
- m.put("mickey", "7");
- m.put("clyde", "10");
- m.put("wayne", "99");
- return m;
- }
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java
deleted file mode 100644
index b06b8eb509..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network.exceptions;
-
-
-
-import javax.xml.ws.WebFault;
-
-import org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * This class simply extends Exception (without addition additional functionality)
- * to provide an identifier for Network related exceptions on create, delete, query.
- *
- *
- */
-@WebFault (name="NetworkException", faultBean="org.openecomp.mso.adapters.network.exceptions.NetworkExceptionBean", targetNamespace="http://org.openecomp.mso/network")
-public class NetworkException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- private NetworkExceptionBean faultInfo;
-
- public NetworkException (String msg) {
- super(msg);
- faultInfo = new NetworkExceptionBean (msg);
- }
-
- public NetworkException (Throwable e) {
- super(e);
- faultInfo = new NetworkExceptionBean (e.getMessage());
- }
-
- public NetworkException (String msg, Throwable e) {
- super (msg, e);
- faultInfo = new NetworkExceptionBean (msg);
- }
-
- public NetworkException (String msg, MsoExceptionCategory category) {
- super(msg);
- faultInfo = new NetworkExceptionBean (msg, category);
- }
-
- public NetworkException (String msg, MsoExceptionCategory category, Throwable e) {
- super (msg, e);
- faultInfo = new NetworkExceptionBean (msg, category);
- }
-
- public NetworkException (MsoException e) {
- super (e);
- faultInfo = new NetworkExceptionBean (e.getContextMessage(), e.getCategory());
- }
-
- public NetworkExceptionBean getFaultInfo() {
- return faultInfo;
- }
-
- public void setFaultInfo(NetworkExceptionBean faultInfo) {
- this.faultInfo = faultInfo;
- }
-}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java
deleted file mode 100644
index 48d0fa8148..0000000000
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBean.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network.exceptions;
-
-
-import java.io.Serializable;
-
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * Jax-WS Fault Bean for Network Exceptions
- */
-public class NetworkExceptionBean implements Serializable {
-
- private static final long serialVersionUID = 1655343530371342871L;
-
- private String message;
- private MsoExceptionCategory category;
- private Boolean rolledBack;
-
- public NetworkExceptionBean () {}
-
- public NetworkExceptionBean (String message) {
- this.message = message;
- }
-
- public NetworkExceptionBean (String message, MsoExceptionCategory category) {
- this.message = message;
- this.category = category;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public MsoExceptionCategory getCategory () {
- return category;
- }
-
- public void setCategory (MsoExceptionCategory category) {
- this.category = category;
- }
-
- public Boolean isRolledBack() {
- return rolledBack;
- }
-
- public void setRolledBack(Boolean rolledBack) {
- this.rolledBack = rolledBack;
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java
deleted file mode 100644
index 9ab6ce6a70..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei 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.openecomp.mso.adapters.network;
-
-import org.junit.Test;
-
-public class BpelRestClientTest {
-
- BpelRestClient bpelRestClient = new BpelRestClient();
-
- @Test
- public void getSocketTimeoutTest() throws Exception {
- bpelRestClient.getSocketTimeout();
- }
-
- @Test
- public void setSocketTimeoutTest() throws Exception {
- bpelRestClient.setSocketTimeout(300);
- }
-
- @Test
- public void getConnectTimeoutTest() throws Exception {
- bpelRestClient.getConnectTimeout();
- }
-
- @Test
- public void setConnectTimeoutTest() throws Exception {
- bpelRestClient.setConnectTimeout(200);
- }
-
- @Test
- public void getRetryCountTest() throws Exception {
- bpelRestClient.getRetryCount();
- }
-
- @Test
- public void setRetryCountTest() throws Exception {
- bpelRestClient.setRetryCount(3);
- }
-
- @Test
- public void getRetryIntervalTest() throws Exception {
- bpelRestClient.getRetryInterval();
- }
-
- @Test
- public void setRetryIntervalTest() throws Exception {
- bpelRestClient.setRetryInterval(3);
- }
-
- @Test
- public void getCredentialsTest() throws Exception {
- bpelRestClient.getCredentials();
- }
-
- @Test
- public void setCredentialsTest() throws Exception {
- bpelRestClient.setCredentials("test");
- }
-
- @Test
- public void getRetryListTest() throws Exception {
- bpelRestClient.getRetryList();
- }
-
- @Test
- public void setRetryListTest() throws Exception {
- bpelRestClient.setRetryList("retry list");
- }
-
- @Test
- public void getLastResponseCodeTest() throws Exception {
- bpelRestClient.getLastResponseCode();
- }
-
- @Test
- public void getLastResponseTest() throws Exception {
- bpelRestClient.getLastResponse();
- }
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java
deleted file mode 100644
index e407df8267..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ContrailPolicyRefSeqTest {
- @Test
- public void ContrailPolicyRefSeqJson_Test()
- {
- ContrailPolicyRefSeq cprs = new ContrailPolicyRefSeq("majorVersion 1","minorVersion 0.02");
- assertTrue(cprs.toString().contains("majorVersion 1"));
- assertTrue(cprs.toString().contains("minorVersion 0.02"));
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java
deleted file mode 100644
index 674dd35974..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ContrailPolicyRefTest {
-
- @Test
- public void ContrailPolicyRef_Test()
- {
- ContrailPolicyRef ref = new ContrailPolicyRef();
- ref.populate("majorVersion 1", "minorVersion 0.02");
- String strJson = ref.toJsonString();
- assertTrue(strJson.contains("majorVersion 1"));
- assertTrue(strJson.contains("minorVersion 0.02"));
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java
deleted file mode 100644
index ea173f0553..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.adapters.network;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.openstack.beans.HostRoute;
-
-public class ContrailSubnetHostRouteTest {
-
- private ContrailSubnetHostRoute cshr = new ContrailSubnetHostRoute();
- HostRoute hr = new HostRoute();
- @Test
- public void testContrailSubnetHostRoute() {
-
- cshr.setPrefix("prefix");
- cshr.setNextHop("nextHop");
- assertEquals(cshr.getPrefix(), "prefix");
- assertEquals(cshr.getNextHop(), "nextHop");
- assert (cshr.toString() != null);
- cshr.populateWith(hr);
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java
deleted file mode 100644
index df345d83be..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.adapters.network;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class ContrailSubnetHostRoutesTest {
-
- ContrailSubnetHostRoutes cshr = new ContrailSubnetHostRoutes();
- List<ContrailSubnetHostRoute> host_routes;
- StringBuilder buf = new StringBuilder();
- @Test
- public void testContrailSubnetHostRoutes() {
- cshr.setHost_routes(host_routes);
- assertEquals(cshr.getHost_routes(), host_routes);
- assert (cshr.toString() != null);
- }
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java
deleted file mode 100644
index 197840fdc9..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.network;
-
-import java.util.ArrayList;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-
-public class MsoNetworkAdapterAsyncImplTest {
-
- @Test
- public void healthCheckATest() {
- MsoNetworkAdapterAsyncImpl mNAAimpl = new MsoNetworkAdapterAsyncImpl();
- mNAAimpl.healthCheckA();
- }
-
- @Test
- @Ignore // 1802 merge
- public void rollbackNetworkATest() {
- NetworkRollback nrb = new NetworkRollback();
- nrb.setCloudId("cloudId");
- nrb.setMsoRequest(new MsoRequest());
- nrb.setModelCustomizationUuid("modelCustomizationUuid");
- nrb.setNetworkCreated(true);
- nrb.setNetworkId("networkId");
- nrb.setNetworkName("networkName");
- nrb.setNetworkStackId("networkStackId");
- nrb.setNetworkType("networkType");
- nrb.setNeutronNetworkId("neutronNetworkId");
- nrb.setPhysicalNetwork("physicalNetwork");
- nrb.setTenantId("tenantId");
- nrb.setVlans(new ArrayList<>());
-
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.rollbackNetworkA(nrb, "messageId", "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void deleteNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.deleteNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "messageId", new MsoRequest(), "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void updateNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId",
- new MsoRequest(), "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void queryNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.queryNetworkA("cloudSiteId", "tenantId", "networkNameOrId", "messageId", new MsoRequest(),
- "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void createNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.createNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId",
- new MsoRequest(), "/notificationUrl");
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java
deleted file mode 100644
index 1692c0bcfa..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java
+++ /dev/null
@@ -1,1193 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.openecomp.mso.adapters.network;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyList;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.xml.ws.Holder;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-import org.openecomp.mso.openstack.beans.NetworkInfo;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openecomp.mso.openstack.utils.MsoNeutronUtils;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class MsoNetworkAdapterImplTest {
-
- @Test
- public void createNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkExists_FailIfExistsTrue()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkExists_FailIfExistsNotTrue()
- throws NetworkException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoDoesntExist_CreateNetworkException()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = null;
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.createNetwork(any(), any(), any(), any(), any(), any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoDoesntExist_CreateNetwork()
- throws NetworkException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(netInfo.getId()).thenReturn("Id");
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- when(impl.neutron.createNetwork(any(), any(), any(), any(), any(), anyList())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoExists()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = null;
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNull() throws NetworkException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_ThrowMsoPropsException()
- throws NetworkException, MsoPropertiesException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplate");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoPropertiesException exception = Mockito.mock(MsoPropertiesException.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull()
- throws NetworkException, MsoPropertiesException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoPropertiesException exception = Mockito.mock(MsoPropertiesException.class);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStackThrowsException()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- MsoException exception = Mockito.mock(MsoException.class);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNull()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = null;
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_FailIfExists()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_DontFailIfExists()
- throws NetworkException, MsoPropertiesException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- Map<String, Object> outputs = new HashMap<>();
- outputs.put("subnet", "");
- when(heatStack.getOutputs()).thenReturn(outputs);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_DontFailIfExists_Validate()
- throws NetworkException, MsoPropertiesException, MsoException {
- List<Subnet> subnets = new ArrayList<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- Map<String, Object> outputs = new HashMap<>();
- outputs.put("subnet", "");
- when(heatStack.getOutputs()).thenReturn(outputs);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, subnets, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkReturnsNull()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkDoesntExist_UpdateNetworkException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = new NetworkInfo(null);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.updateNetwork(any(), any(), any(), any(), any(), anyList())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkDoesntExist_UpdateNetwork()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = new NetworkInfo(null);
- NetworkInfo mockedNetworkInfo = Mockito.mock(NetworkInfo.class);
- when(mockedNetworkInfo.getId()).thenReturn("Id");
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.updateNetwork(any(), any(), any(), any(), any(), anyList())).thenReturn(mockedNetworkInfo);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackThrowException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackReturnNull()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenReturn(null);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackReturnInfo()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- StackInfo stackInfo = Mockito.mock(StackInfo.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenReturn(stackInfo);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heat.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackReturned()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = Mockito.mock(StackInfo.class);
- when(stackInfo.getStatus()).thenReturn(HeatStatus.CREATED);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(stackInfo);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkThrows()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkReturns()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo networkInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(networkInfo);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkNull()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_NullOrNotPresentCondition() throws NetworkException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.deleteNetwork(null, null, "networkType", "modelCustomizationUuid", null, null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
-
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_DeleteNetworkThrows() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(db.getNetworkResource(any())).thenReturn(resource);
- MsoException exception = Mockito.mock(MsoException.class);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_NeutronDeleteNetwork() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_ModeHeat_QueryStack_DeleteStack() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("HEAT");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = new StackInfo();
- stackInfo.setStatus(HeatStatus.CREATED);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(stackInfo);
- StackInfo stackInfoDeleted = new StackInfo();
- stackInfo.setStatus(HeatStatus.DELETING);
- when(impl.heat.deleteStack(any(), any(), any(), anyBoolean())).thenReturn(stackInfoDeleted);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_ModeHeat_QueryStackException() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("HEAT");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = new StackInfo();
- stackInfo.setStatus(HeatStatus.CREATED);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heat.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
deleted file mode 100644
index 182190b1a7..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-import static org.junit.Assert.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HTTP;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.CreateNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.DeleteNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.RollbackNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.UpdateNetworkTask;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.NetworkTechnology;
-import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-//@RunWith(PowerMockRunner.class)
-@PrepareForTest({NetworkAdapterRest.class, CreateNetworkTask.class, CreateNetworkRequest.class, DeleteNetworkTask.class, DeleteNetworkRequest.class})
-public class NetworkAdapterRestTest {
- @Mock
- private static CreateNetworkTask taskMock;
- @Mock
- private static CreateNetworkRequest reqMock;
- @Mock
- private static DeleteNetworkRequest delReqMock;
- @Mock
- private static DeleteNetworkTask delTaskMock;
- @Mock
- private static RollbackNetworkRequest rollbackReqMock;
- @Mock
- private static RollbackNetworkTask rollbackTaskMock;
-
- private static final String TESTING_KEYWORD = "___TESTING___";
-
- @Test
- public void NetworkAdapterRest_createNetwork_async_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- taskMock = PowerMockito.mock(CreateNetworkTask.class);
- reqMock = PowerMockito.mock(CreateNetworkRequest.class);
-
- try {
- PowerMockito.whenNew(CreateNetworkRequest.class).withAnyArguments().thenReturn(reqMock);
- PowerMockito.when(reqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(reqMock.getNetworkId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getCloudSiteId()).thenReturn(TESTING_KEYWORD);
- PowerMockito.when(reqMock.getTenantId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkType()).thenReturn("PROVIDER");
- PowerMockito.when(reqMock.getModelCustomizationUuid()).thenReturn("modelCustUuid");
- PowerMockito.when(reqMock.getNetworkName()).thenReturn("networkName");
-
- ProviderVlanNetwork vlan = new ProviderVlanNetwork();
- vlan.setPhysicalNetworkName("PhysicalNetworkName");
- vlan.setVlans(new ArrayList<Integer>(Arrays.asList(123,456,654,321)));
- PowerMockito.when(reqMock.getProviderVlanNetwork()).thenReturn(vlan);
-
- PowerMockito.when(reqMock.getFailIfExists()).thenReturn(true);
- PowerMockito.when(reqMock.getBackout()).thenReturn(false);
-
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet s1 = new Subnet();
- s1.setSubnetName("Subnet1");
- subnets.add(s1);
- Subnet s2 = new Subnet();
- s1.setSubnetName("Subnet2");
- subnets.add(s2);
- Subnet s3 = new Subnet();
- s1.setSubnetName("Subnet3");
- subnets.add(s3);
- PowerMockito.when(reqMock.getSubnets()).thenReturn(subnets);
-
- MsoRequest msoRequest = new MsoRequest ();
- msoRequest.setRequestId("MSORequestID123");
- PowerMockito.when(reqMock.getMsoRequest()).thenReturn(msoRequest);
- // setup spy on CreateNetworkTask
-
- PowerMockito.whenNew(CreateNetworkTask.class).withArguments(reqMock).thenReturn(taskMock);
- PowerMockito.spy(taskMock);
-
- Response resp = api.createNetwork(new CreateNetworkRequest());
- assertEquals(resp.getStatus(),HttpStatus.SC_ACCEPTED);
-
- // test if another thread has executed run method
- //Mockito.verify(taskMock, Mockito.times(1)).run();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
-
- }
-
- @Test
- public void NetworkAdapterRest_createNetwork_sync_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- // setup createNetwork parameter
- // setup sync to spy on run method
- CreateNetworkRequest req = new CreateNetworkRequest();
- req.setNetworkId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setTenantId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setNetworkType("PROVIDER");
- req.setModelCustomizationUuid("modelCustUuid");
- req.setNetworkName("networkName");
- ProviderVlanNetwork vlan = new ProviderVlanNetwork();
- vlan.setPhysicalNetworkName("PhysicalNetworkName");
- vlan.setVlans(new ArrayList<Integer>(Arrays.asList(123,456,654,321)));
- req.setProviderVlanNetwork(vlan);
- req.setFailIfExists(true);
- req.setBackout(false);
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet s1 = new Subnet();
- s1.setSubnetName("Subnet1");
- subnets.add(s1);
- Subnet s2 = new Subnet();
- s1.setSubnetName("Subnet2");
- subnets.add(s2);
- Subnet s3 = new Subnet();
- s1.setSubnetName("Subnet3");
- subnets.add(s3);
- req.setSubnets(subnets);
- MsoRequest msoRequest = new MsoRequest ();
- msoRequest.setRequestId("MSORequestID123");
- req.setMsoRequest(msoRequest);
- // set sync
- req.setNotificationUrl(null);
- // setup spy on CreateNetworkTask
- CreateNetworkTask task = api.new CreateNetworkTask(req);
-
- try {
- PowerMockito.whenNew(CreateNetworkTask.class).withArguments(req).thenReturn(task);
- Response resp = api.createNetwork(req);
-
- CreateNetworkResponse cnresp = (CreateNetworkResponse) resp.getEntity();
-
- assertEquals(cnresp.getNetworkFqdn(), "086f70b6-28fb-11e6-8260-0017f20fe1b8");
- assertEquals(cnresp.getNetworkId(), "b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- assertEquals(cnresp.getNeutronNetworkId(), "55e55884-28fa-11e6-8971-0017f20fe1b8");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_deleteNetwork_async_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- delTaskMock = PowerMockito.mock(DeleteNetworkTask.class);
- delReqMock = PowerMockito.mock(DeleteNetworkRequest.class);
-
- try{
- PowerMockito.whenNew(DeleteNetworkRequest.class).withAnyArguments().thenReturn(delReqMock);
- PowerMockito.when(delReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(delReqMock.getCloudSiteId()).thenReturn(TESTING_KEYWORD);
- PowerMockito.when(delReqMock.getNetworkId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(delReqMock.getMessageId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
-
- PowerMockito.whenNew(DeleteNetworkTask.class).withArguments(delReqMock).thenReturn(delTaskMock);
- PowerMockito.spy(delTaskMock);
-
- Response resp = api.deleteNetwork("b4a6af8c-a22b-45d5-a880-29527f8f59a7", delReqMock);
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
-
- // test if another thread has executed run method
- // Mockito.verify(delTaskMock, Mockito.times(1)).run();
-
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_deleteNetwork_sync_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- DeleteNetworkRequest req = new DeleteNetworkRequest();
- req.setNotificationUrl(null);
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setNetworkId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setMessageId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
-
- DeleteNetworkTask task = api.new DeleteNetworkTask(req);
-
- try {
- PowerMockito.whenNew(DeleteNetworkTask.class).withArguments(req).thenReturn(task);
- PowerMockito.spy(task);
- Response resp = api.deleteNetwork("b4a6af8c-a22b-45d5-a880-29527f8f59a7", req);
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_queryNetwork_Test()
- {
- /*
- * test when network found as well as network not found
- */
- String networkStackId = "networkStackId";
- String skipAAI = "skipAAI";
- String requestId = "msoRequest.requestId";
- String serviceInstanceId = "msoRequest.serviceInstanceId";
- String aaiNetworkId = "aaiNetworkId";
- String cloudSiteId = "cloudSiteId";
- String tenantId = "tenantId";
- String networkNameOrId = "networkNameOrId";
- MsoRequest msoRequestMock = Mockito.mock(MsoRequest.class);
- try {
- PowerMockito.whenNew(MsoRequest.class).withArguments("msoRequest.requestId", "msoRequest.serviceInstanceId").thenReturn(msoRequestMock);
-
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- MsoRequest msoRequest = new MsoRequest("msoRequest.requestId", "msoRequest.serviceInstanceId");
- Holder<Boolean> networkExists = new Holder<Boolean>();
- Holder<String> networkId = new Holder<String>();
- Holder<String> neutronNetworkId = new Holder<String>();
- Holder<NetworkStatus> status = new Holder<NetworkStatus>();
- Holder<List<String>> routeTargets = new Holder<List<String>>();
- Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>();
-
- MsoNetworkAdapterImpl mockImpl = Mockito.mock(MsoNetworkAdapterImpl.class);
- CloudConfigFactory cloudConfigMock = Mockito.mock(CloudConfigFactory.class);
- MsoPropertiesFactory msoPropertiesFactoryMock = Mockito.mock(MsoPropertiesFactory.class);
-
- try {
- PowerMockito.whenNew(MsoPropertiesFactory.class).withAnyArguments().thenReturn(msoPropertiesFactoryMock);
- PowerMockito.whenNew(CloudConfigFactory.class).withAnyArguments().thenReturn(cloudConfigMock);
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withArguments(msoPropertiesFactoryMock, cloudConfigMock).thenReturn(mockImpl);
-
- Mockito.doAnswer(new Answer<Void>() {
- @SuppressWarnings("unchecked")
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("called with arguments: " + Arrays.toString(args));
- Holder<Boolean> networkExists = (Holder<Boolean>) args[4];
- networkExists.value = Boolean.TRUE;
-
- Holder<String> networkId = (Holder<String>) args[5];
- networkId.value = "networkId";
-
- Holder<String> neutronNetworkId = (Holder<String>) args[6];
- neutronNetworkId.value = "neutronNetworkId";
-
- Holder<NetworkStatus> status = (Holder<NetworkStatus>) args[7];
- status.value = NetworkStatus.ACTIVE;
-
- Holder<List<String>> routeTargets = (Holder<List<String>>) args[8];
- routeTargets.value = new ArrayList<String>(Arrays.asList("routeTarget1","routeTarget2"));
-
- Holder<Map<String, String>> subnetIdMap = (Holder<Map<String, String>>) args[9];
- subnetIdMap.value = new HashMap<String,String>();
- subnetIdMap.value.put("Key1", "Val1");
- subnetIdMap.value.put("Key2", "Val2");
- subnetIdMap.value.put("Key3", "Val3");
-
- return null;
- }
- }).when(mockImpl).queryNetworkContrail(Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.any(MsoRequest.class),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject());
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.queryNetwork(cloudSiteId, tenantId, networkStackId, skipAAI, requestId, serviceInstanceId, aaiNetworkId);
- QueryNetworkResponse entity = (QueryNetworkResponse) resp.getEntity();
-
- assertEquals(entity.getNetworkExists(), Boolean.TRUE);
- assertEquals(entity.getNetworkId(), "networkId");
- assertEquals(entity.getNeutronNetworkId(), "neutronNetworkId");
- assertEquals(entity.getNetworkStatus(), NetworkStatus.ACTIVE);
- assertEquals(entity.getRouteTargets().size(), 2);
- assertEquals(entity.getRouteTargets().get(0), "routeTarget1");
- assertEquals(entity.getRouteTargets().get(1), "routeTarget2");
-
- assertEquals(entity.getSubnetIdMap().size(), 3);
- assertEquals(entity.getSubnetIdMap().get("Key1"), "Val1");
- assertEquals(entity.getSubnetIdMap().get("Key2"), "Val2");
- assertEquals(entity.getSubnetIdMap().get("Key3"), "Val3");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- }
- catch (NetworkException e)
- {
- e.printStackTrace();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_rollBackNetwork_async_Test()
- {
- rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
- rollbackTaskMock = PowerMockito.mock(RollbackNetworkTask.class);
- NetworkRollback ntRollbackMock = PowerMockito.mock(NetworkRollback.class);
- MsoNetworkAdapterImpl adapterImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
-
- try{
- PowerMockito.whenNew(RollbackNetworkRequest.class).withAnyArguments().thenReturn(rollbackReqMock);
- PowerMockito.when(rollbackReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(rollbackReqMock.getMessageId()).thenReturn("Rollback succeeded !");
-
- PowerMockito.whenNew(RollbackNetworkTask.class).withArguments(rollbackReqMock).thenReturn(rollbackTaskMock);
- PowerMockito.spy(rollbackTaskMock);
-
- // PowerMockito.whenNew(NetworkRollback.class).withAnyArguments().thenReturn(ntRollbackMock);
- PowerMockito.when(rollbackReqMock.getNetworkRollback()).thenReturn(ntRollbackMock);
-
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(adapterImplMock);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("called with arguments: " + Arrays.toString(args));
- return null;
- }
- }).when(adapterImplMock).rollbackNetwork(ntRollbackMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.rollbackNetwork(new RollbackNetworkRequest());
-
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
- // test if another thread has executed run method
- // Mockito.verify(rollbackTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_rollBackNetwork_sync_Test()
- {
- rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
- rollbackTaskMock = PowerMockito.mock(RollbackNetworkTask.class);
-
- try
- {
- PowerMockito.whenNew(RollbackNetworkRequest.class).withAnyArguments().thenReturn(rollbackReqMock);
- PowerMockito.when(rollbackReqMock.isSynchronous()).thenReturn(true);
-
- PowerMockito.whenNew(RollbackNetworkTask.class).withArguments(rollbackReqMock).thenReturn(rollbackTaskMock);
- PowerMockito.when(rollbackTaskMock.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- PowerMockito.when(rollbackTaskMock.getGenericEntityResponse()).thenReturn(null);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- System.out.println("run method called ");
- return null;
- }
- }).when(rollbackTaskMock).run();
- PowerMockito.spy(rollbackTaskMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.rollbackNetwork(new RollbackNetworkRequest());
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- Mockito.verify(rollbackTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
-
-
- }
-
- @Test
- public void NetworkAdapterRest_updateNetwork_sync_TestString_Test()
- {
- UpdateNetworkRequest req = new UpdateNetworkRequest();
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setTenantId("tenantId");
- req.setNotificationUrl(null);
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId("MsoRequestId");
- msoReq.setServiceInstanceId("serviceInstanceId");
- req.setMsoRequest(msoReq);
- req.setNetworkId("UpdateNetworkRequestNetworkId");
- req.setMessageId("UpdateNetworkMessageWithTestString");
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- UpdateNetworkTask task = api.new UpdateNetworkTask(req);
-
- try {
- PowerMockito.whenNew(UpdateNetworkTask.class).withArguments(req).thenReturn(task);
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", req);
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- UpdateNetworkResponse unResp = (UpdateNetworkResponse) resp.getEntity();
- assertEquals(unResp.getNetworkId(),"UpdateNetworkRequestNetworkId");
- assertEquals(unResp.getMessageId(),"UpdateNetworkMessageWithTestString");
-
- Map<String, String> map = unResp.getSubnetMap();
- for (Map.Entry<String, String> entry : map.entrySet()) {
- String key = entry.getKey();
- if(key.equalsIgnoreCase("mickey"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "7");
- }
-
- if(key.equalsIgnoreCase("clyde"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "10");
- }
-
- if(key.equalsIgnoreCase("wayne"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "99");
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void NetworkAdapterRest_updateNetwork_sync_ContrailRequest_Test()
- {
- try {
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId("MsoRequestId");
- msoReq.setServiceInstanceId("serviceInstanceId");
-
- UpdateNetworkRequest reqMock = PowerMockito.mock(UpdateNetworkRequest.class);
- PowerMockito.whenNew(UpdateNetworkRequest.class).withAnyArguments().thenReturn(reqMock);
- PowerMockito.when(reqMock.getCloudSiteId()).thenReturn("NON_"+TESTING_KEYWORD);
- PowerMockito.when(reqMock.getTenantId()).thenReturn("tenantId");
- PowerMockito.when(reqMock.getNetworkType()).thenReturn("NetworkType");
- PowerMockito.when(reqMock.getModelCustomizationUuid()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkStackId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkName()).thenReturn("NetworkName");
- PowerMockito.when(reqMock.getSubnets()).thenReturn(new ArrayList<Subnet>());
-
- PowerMockito.when(reqMock.isSynchronous()).thenReturn(true);
- PowerMockito.when(reqMock.getNetworkId()).thenReturn("UpdateNetworkRequestNetworkId");
- PowerMockito.when(reqMock.getMessageId()).thenReturn("UpdateNetworkMessageWithTestString");
- PowerMockito.when(reqMock.getMsoRequest()).thenReturn(msoReq);
- PowerMockito.when(reqMock.isContrailRequest()).thenReturn(true);
- ContrailNetwork cn = new ContrailNetwork();
- cn.setRouteTargets(new ArrayList<RouteTarget>());
- cn.setPolicyFqdns(new ArrayList<String>());
- cn.setRouteTableFqdns(new ArrayList<String>());
-
- PowerMockito.when(reqMock.getContrailNetwork()).thenReturn(cn);
-
- MsoNetworkAdapterImpl msoImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(msoImplMock);
-
- Mockito.doAnswer(new Answer<Void>() {
- @SuppressWarnings("unchecked")
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("updateNetworkContrail called with arguments: " + Arrays.toString(args));
-
- return null;
- }
- }).when(msoImplMock).updateNetworkContrail
- (Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
- PowerMockito.spy(msoImplMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", reqMock);
-
- Mockito.verify(msoImplMock, Mockito.times(1)).updateNetworkContrail
- (Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- UpdateNetworkResponse unResp = (UpdateNetworkResponse) resp.getEntity();
- assertEquals(unResp.getNetworkId(),"UpdateNetworkRequestNetworkId");
- assertEquals(unResp.getMessageId(),"UpdateNetworkMessageWithTestString");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void NetworkAdapterRest_updateNetwork_async_Test()
- {
- UpdateNetworkRequest updateReqMock = PowerMockito.mock(UpdateNetworkRequest.class);
- UpdateNetworkTask updateTaskMock = PowerMockito.mock(UpdateNetworkTask.class);
- MsoNetworkAdapterImpl adapterImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
-
- try{
- PowerMockito.whenNew(UpdateNetworkRequest.class).withAnyArguments().thenReturn(updateReqMock);
- PowerMockito.when(updateReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(updateReqMock.getMessageId()).thenReturn("Update succeeded !");
- PowerMockito.when(updateReqMock.getNetworkId()).thenReturn("UpdateNetworkRequestNetworkId");
-
- PowerMockito.whenNew(UpdateNetworkTask.class).withArguments(updateReqMock).thenReturn(updateTaskMock);
- PowerMockito.spy(updateTaskMock);
-
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(adapterImplMock);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("updateNetworkContrail called with arguments: " + Arrays.toString(args));
- return null;
- }
- }).when(adapterImplMock).updateNetworkContrail
- (
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", updateReqMock);
-
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
- // test if another thread has executed run method
- // Mockito.verify(updateTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java
deleted file mode 100644
index 417ea80e59..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.openecomp.mso.adapters.network;
-
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.beans.Subnet;
-
-public class NetworkAdapterTest {
-
- @Mock
- private static MsoNetworkAdapterImpl adapter;
-
- @Mock
- private static CatalogDatabase db;
-
- @Mock
- private static CloudConfigFactory cloudConfigFactory;
-
- @BeforeClass
- public static final void prepare () {
- adapter = Mockito.spy (new MsoNetworkAdapterImpl ());
- db = Mockito.mock (CatalogDatabase.class);
- cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- NetworkResource networkResource = new NetworkResource ();
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResource(networkResource);
- nrc.setNetworkType("PROVIDER");
- networkResource.setNeutronNetworkType ("PROVIDER");
- networkResource.setModelUUID("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- nrc.setNetworkResourceModelUuid(networkResource.getModelUUID());
- networkResource.setOrchestrationMode ("toto");
- Mockito.when (db.getNetworkResource ("PROVIDER")).thenReturn (networkResource);
- Mockito.when (adapter.getCatalogDB ()).thenReturn (db);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- Mockito.when(cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Mockito.when (adapter.getCloudConfigFactory()).thenReturn(cloudConfigFactory);
- }
-
- @Test
- public void createTest () {
-
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- subnets.add (new Subnet ());
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.createNetwork ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkName",
- "physicalNetworkName",
- vlans,
- Boolean.TRUE,
- Boolean.TRUE,
- subnets,
- msoRequest,
- networkId,
- neutronNetworkId,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void createTest2 () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- List <RouteTarget> routeTargets = new LinkedList <> ();
- subnets.add (new Subnet ());
- List <String> policyFqdns = new LinkedList <> ();
- policyFqdns.add("pfqdn1");
- policyFqdns.add("pfqdn2");
- List <String> routeTableFqdns = new LinkedList <> ();
- routeTableFqdns.add("rtfqdn1");
- routeTableFqdns.add("rtfqdn2");
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- Holder <String> networkFqdn= new Holder <> ();
- try {
- adapter.createNetworkContrail ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkName",
- routeTargets,
- "shared",
- "external",
- Boolean.TRUE,
- Boolean.TRUE,
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- networkId,
- neutronNetworkId,
- networkFqdn,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void updateTest () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- subnets.add (new Subnet ());
- MsoRequest msoRequest = new MsoRequest ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.updateNetwork ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkId",
- "networkName",
- "physicalNetworkName",
- vlans,
- subnets,
- msoRequest,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void updateTest2 () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- List <RouteTarget> routeTargets = new LinkedList <> ();
- subnets.add (new Subnet ());
- List <String> policyFqdns = new LinkedList <> ();
- policyFqdns.add("pfqdn1");
- List <String> routeTableFqdns = new LinkedList <> ();
- routeTableFqdns.add("rtfqdn1");
- routeTableFqdns.add("rtfqdn2");
- MsoRequest msoRequest = new MsoRequest ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.updateNetworkContrail ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkId",
- "networkName",
- routeTargets,
- "shared",
- "external",
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void queryTest () {
- Holder <List <Integer>> vlans = new Holder <> ();
- Holder <NetworkStatus> status = new Holder <> ();
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <Boolean> result = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- try {
- adapter.queryNetwork (null,
- "tenant",
- "networkName",
- msoRequest,
- result,
- networkId,
- neutronNetworkId,
- status,
- vlans,
- subnetIdMap);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Missing mandatory parameter"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void queryTest2 () {
- Holder <List <RouteTarget>> routeTargets = new Holder <> ();
- Holder <NetworkStatus> status = new Holder <> ();
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <Boolean> result = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- try {
- adapter.queryNetworkContrail (null,
- "tenant",
- "networkName",
- msoRequest,
- result,
- networkId,
- neutronNetworkId,
- status,
- routeTargets,
- subnetIdMap);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Missing mandatory parameter"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void deleteTest () {
- Holder <Boolean> networkDeleted = new Holder<> ();
- MsoRequest msoRequest = new MsoRequest ();
- try {
- adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "modelCustUuid", "networkId", msoRequest, networkDeleted);
- } catch (NetworkException e) {
- e.printStackTrace();
- assertTrue (e.getMessage ().contains ("Cloud Site [toto] not found"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
deleted file mode 100644
index ae198142bd..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei 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.openecomp.mso.adapters.network;
-
-import java.util.ArrayList;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.beans.Pool;
-import org.openecomp.mso.openstack.beans.Subnet;
-
-public class NetworkBeansTest {
-
- /**
- * Test case for coverage
- */
- @Test()
- public final void bpelRestClientPOJOTest() {
- try {
- BpelRestClient bpelRestClient = new BpelRestClient();
- bpelRestClient.setConnectTimeout(180);
- bpelRestClient.setCredentials("credentials");
- bpelRestClient.setRetryCount(-1);
- bpelRestClient.setRetryInterval(2);
- bpelRestClient.setSocketTimeout(10);
- bpelRestClient.equals(bpelRestClient);
- bpelRestClient.bpelPost("toBpelStr", "bpelUrl", true);
- bpelRestClient.getConnectTimeout();
- bpelRestClient.getCredentials();
- bpelRestClient.getLastResponse();
- bpelRestClient.getLastResponseCode();
- bpelRestClient.getRetryCount();
- bpelRestClient.getRetryInterval();
- bpelRestClient.getRetryList();
- bpelRestClient.getSocketTimeout();
- bpelRestClient.hashCode();
- bpelRestClient.toString();
-
- ContrailPolicyRef contrailPolicyRef = new ContrailPolicyRef();
- contrailPolicyRef.populate("major", "minor");
- contrailPolicyRef.toJsonNode();
- contrailPolicyRef.toJsonString();
- contrailPolicyRef.toString();
-
- ContrailPolicyRefSeq contrailPolicyRefSeq = new ContrailPolicyRefSeq();
- ContrailPolicyRefSeq contrailPolicyRefSeq2 = new ContrailPolicyRefSeq("", "");
- contrailPolicyRefSeq.setMajor("major");
- contrailPolicyRefSeq.setMinor("minor");
- contrailPolicyRefSeq.getMajor();
- contrailPolicyRefSeq.getMinor();
- contrailPolicyRefSeq.toString();
-
- ContrailSubnet contrailSubnet = new ContrailSubnet();
- contrailSubnet.setAddrFromStart(true);
- contrailSubnet.setDefaultGateway("defaultGateway");
- contrailSubnet.setEnableDhcp(true);
- contrailSubnet.setPools(new ArrayList<>());
- contrailSubnet.setSubnet(new ContrailSubnetIp());
- contrailSubnet.setSubnetName("subnetName");
- contrailSubnet.getAllocationPools();
- contrailSubnet.getDefaultGateway();
- contrailSubnet.getSubnet();
- contrailSubnet.getSubnetName();
- contrailSubnet.isAddrFromStart();
- contrailSubnet.isEnableDhcp();
- contrailSubnet.populateWith(new Subnet());
- contrailSubnet.toJsonNode();
- contrailSubnet.toJsonString();
- contrailSubnet.toString();
-
- ContrailSubnetIp contrailSubnetIp = new ContrailSubnetIp();
- contrailSubnetIp.setIpPrefix("ipPrefix");
- contrailSubnetIp.setIpPrefixLen("ipPrefixLen");
- contrailSubnetIp.getIpPrefix();
- contrailSubnetIp.getIpPrefixLen();
- contrailSubnetIp.toString();
-
- ContrailSubnetPool contrailSubnetPool = new ContrailSubnetPool();
- contrailSubnetPool.setEnd("end");
- contrailSubnetPool.setStart("start");
- contrailSubnetPool.getEnd();
- contrailSubnetPool.getStart();
- contrailSubnetPool.populateWith(new Pool());
- contrailSubnetPool.toString();
-
- // HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
- // healthCheckHandler.healthcheck("60c3e96e-0970-4871-b6e0-3b6de7561519");
- // healthCheckHandler.healthcheck("requestId");
- } catch (Exception e) {
- assert (false);
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java
deleted file mode 100644
index 0ea4dd4fca..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.adapters.network.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class NetworkExceptionBeanTest {
-
- NetworkExceptionBean neb=new NetworkExceptionBean();
- MsoExceptionCategory msc=MsoExceptionCategory.INTERNAL;
-
- @Test
- public void test() {
- neb.setRolledBack(true);
- neb.setMessage("message");
- neb.setCategory(msc);
- assertEquals(neb.getMessage(),"message");
- assertEquals(neb.getCategory(), msc);
- assertEquals(neb.isRolledBack(), true);
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java
deleted file mode 100644
index 9790ec676d..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.adapters.network.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class NetworkExceptionTest{
-
- NetworkException ne=new NetworkException("msg");
- NetworkExceptionBean neb =new NetworkExceptionBean();
- MsoException msoException= new MsoException("msoException") {};
- MsoExceptionCategory msc=MsoExceptionCategory.INTERNAL;
- NetworkException ne1=new NetworkException(msoException);
- NetworkException ne2=new NetworkException(ne);
- NetworkException ne3=new NetworkException("msg", ne);
- NetworkException ne4=new NetworkException("msg", msoException);
- NetworkException ne5=new NetworkException("msg", msc);
- NetworkException ne6=new NetworkException("msg", msc, ne);
-
- @Test
- public void test() {
- ne.setFaultInfo(neb);
- assertEquals(ne.getFaultInfo(), neb);
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/test/resources/logback-test.xml b/adapters/mso-network-adapter/src/test/resources/logback-test.xml
deleted file mode 100644
index d2c17192ea..0000000000
--- a/adapters/mso-network-adapter/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-
-<configuration >
-
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.error" level="trace" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
-
-</configuration>