summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnf-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-vnf-adapter')
-rw-r--r--adapters/mso-vnf-adapter/README.md11
-rw-r--r--adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF3
-rw-r--r--adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml21
-rw-r--r--adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml3
-rw-r--r--adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml122
-rw-r--r--adapters/mso-vnf-adapter/WebContent/check.html10
-rw-r--r--adapters/mso-vnf-adapter/pom.xml169
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java145
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java281
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java66
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java145
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java103
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java652
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java2176
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImpl.java1254
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java1243
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java137
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java621
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestUtils.java85
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2.java629
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java583
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2.java578
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java42
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java80
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java74
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java43
-rwxr-xr-xadapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java90
-rwxr-xr-xadapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java130
-rwxr-xr-xadapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java248
-rwxr-xr-xadapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java37
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java (renamed from adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java)20
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java52
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/HealthCheckHandlerTest.java33
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java114
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java542
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java151
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImplTest.java151
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java121
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VfRollbackTest.java69
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2ExceptionTest.java109
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java87
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java52
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java64
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2ExceptionTest.java97
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java81
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java89
-rw-r--r--adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--adapters/mso-vnf-adapter/src/test/resources/cloud_config.json94
-rw-r--r--adapters/mso-vnf-adapter/src/test/resources/logback-test.xml48
-rw-r--r--adapters/mso-vnf-adapter/src/test/resources/mso.properties27
51 files changed, 10 insertions, 11774 deletions
diff --git a/adapters/mso-vnf-adapter/README.md b/adapters/mso-vnf-adapter/README.md
deleted file mode 100644
index 2085fc90b6..0000000000
--- a/adapters/mso-vnf-adapter/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-This artifact is the MSO VNF adapter. It serves both SOAP and REST requests to the following URLs:
-
- * http://host:port/vnfs/VnfAdapter?wsdl
- * http://host:port/vnfs/VnfAdapterAsync?wsdl
- * http://host:port/vnfs/rest/v1/vnfs/healthcheck
- * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules
- * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules/{aaiVfModuleId}
- * http://host:port/vnfs/rest/v1/vnfs/{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback
- * http://host:port/vnfs/rest/v1/volume-groups
- * http://host:port/vnfs/rest/v1/volume-groups/{aaiVolumeGroupId}
- * http://host:port/vnfs/rest/v1/volume-groups/{aaiVolumeGroupId}/rollback
diff --git a/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e9495128c..0000000000
--- a/adapters/mso-vnf-adapter/WebContent/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-vnf-adapter/WebContent/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index 1281d32948..0000000000
--- a/adapters/mso-vnf-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-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
deleted file mode 100644
index 56e2023f04..0000000000
--- a/adapters/mso-vnf-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-vnf-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml
deleted file mode 100644
index 6224f07fef..0000000000
--- a/adapters/mso-vnf-adapter/WebContent/WEB-INF/jboss-web.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<jboss-web>
- <context-root>vnfs</context-root>
-</jboss-web> \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vnf-adapter/WebContent/WEB-INF/web.xml
deleted file mode 100644
index a2e6c0c517..0000000000
--- a/adapters/mso-vnf-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-vnf-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.vnf.xml</param-value>
- </context-param>
- <context-param>
- <param-name>mso.configuration</param-name>
- <param-value>MSO_PROP_VNF_ADAPTER=mso.vnf.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.vnf.HealthCheckHandler,
- org.openecomp.mso.adapters.vnf.VnfAdapterRest,
- org.openecomp.mso.adapters.vnf.VnfAdapterRestV2,
- org.openecomp.mso.adapters.vnf.VolumeAdapterRest
- </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>RestRequests</web-resource-name>
- <description>Rest Ingress Requests</description>
- <url-pattern>/rest/v*/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- <http-method>PUT</http-method>
- <http-method>DELETE</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>SoapRequests</web-resource-name>
- <description>Soap Ingress Requests</description>
- <url-pattern>/VnfAdapter</url-pattern>
- <url-pattern>/VnfAdapterAsync</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>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>
-</web-app>
diff --git a/adapters/mso-vnf-adapter/WebContent/check.html b/adapters/mso-vnf-adapter/WebContent/check.html
deleted file mode 100644
index 00f37d60d1..0000000000
--- a/adapters/mso-vnf-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-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml
deleted file mode 100644
index 24ef5d4b9a..0000000000
--- a/adapters/mso-vnf-adapter/pom.xml
+++ /dev/null
@@ -1,169 +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-vnf-adapter</artifactId>
- <packaging>war</packaging>
- <name>mso-vnf-adapter</name>
- <description>Web Service and REST endpoint for VNF operations</description>
-
- <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>
- <id>Synch</id>
- <goals>
- <goal>wsgen</goal>
- </goals>
- <configuration>
- <verbose>true</verbose>
- <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl</sei>
- <genWsdl>true</genWsdl>
- <inlineSchemas>true</inlineSchemas>
- </configuration>
- </execution>
- <execution>
- <id>Asynch</id>
- <goals>
- <goal>wsgen</goal>
- </goals>
- <configuration>
- <verbose>true</verbose>
- <sei>org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl</sei>
- <genWsdl>true</genWsdl>
- <inlineSchemas>true</inlineSchemas>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-tools</artifactId>
- <version>2.2.7</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.codehaus.mojo
- </groupId>
- <artifactId>
- jaxws-maven-plugin
- </artifactId>
- <versionRange>
- [2.4.1,)
- </versionRange>
- <goals>
- <goal>wsgen</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
- <dependencies>
- <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-adapters-rest-interface</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.adapters</groupId>
- <artifactId>mso-vnf-adapter-async-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-web-api</artifactId>
- <version>6.0</version>
- <scope>provided</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>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>aria-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jmockit</groupId>
- <artifactId>jmockit</artifactId>
- <version>1.8</version>
- <scope>test</scope>
- </dependency>
- <!-- <dependency> -->
- <!-- <groupId>org.onap.so</groupId> -->
- <!-- <artifactId>mso-catalog-db</artifactId> -->
- <!-- <version>${project.version}</version> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>log4j</groupId> -->
- <!-- <artifactId>log4j</artifactId> -->
- <!-- <version>1.2.17</version> -->
- <!-- </dependency> -->
- </dependencies>
-</project>
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java
deleted file mode 100644
index d26d3f62f8..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java
+++ /dev/null
@@ -1,145 +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.vdu.mapper;
-
-import java.util.List;
-import java.util.Map;
-import org.openecomp.mso.adapters.vdu.VduArtifact;
-import org.openecomp.mso.adapters.vdu.VduArtifact.ArtifactType;
-import org.openecomp.mso.adapters.vdu.VduModelInfo;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.logger.MsoLogger;
-import org.springframework.stereotype.Component;
-
-@Component
-public class VfModuleCustomizationToVduMapper {
-
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
-
- public VduModelInfo mapVfModuleCustomizationToVdu(VfModuleCustomization vfModuleCustom) {
- VduModelInfo vduModel = new VduModelInfo();
- vduModel.setModelCustomizationUUID(vfModuleCustom.getModelCustomizationUuid());
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- // Map the cloud templates, attached files, and environment file
- mapCloudTemplates(
- db.getHeatTemplateByArtifactUuid(vfModuleCustom.getVfModule().getHeatTemplateArtifactUUId()),
- vduModel);
- mapCloudFiles(vfModuleCustom, vduModel);
- mapEnvironment(db.getHeatEnvironmentByArtifactUuid(vfModuleCustom.getHeatEnvironmentArtifactUuid()),
- vduModel);
- }
- return vduModel;
- }
-
- public VduModelInfo mapVfModuleCustVolumeToVdu(VfModuleCustomization vfModuleCustom) {
- VduModelInfo vduModel = new VduModelInfo();
- vduModel.setModelCustomizationUUID(vfModuleCustom.getModelCustomizationUuid());
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- // Map the cloud templates, attached files, and environment file
- mapCloudTemplates(
- db.getHeatTemplateByArtifactUuid(vfModuleCustom.getVfModule().getVolHeatTemplateArtifactUUId()),
- vduModel);
- mapCloudFiles(vfModuleCustom, vduModel);
- mapEnvironment(db.getHeatEnvironmentByArtifactUuid(vfModuleCustom.getVolEnvironmentArtifactUuid()),
- vduModel);
- }
- return vduModel;
- }
-
- private void mapCloudTemplates(HeatTemplate heatTemplate, VduModelInfo vduModel) {
- // TODO: These catalog objects will be refactored to be
- // non-Heat-specific
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- List<VduArtifact> vduArtifacts = vduModel.getArtifacts();
-
- // Main template. Also set the VDU timeout based on the main
- // template.
- vduArtifacts.add(mapHeatTemplateToVduArtifact(heatTemplate, ArtifactType.MAIN_TEMPLATE));
- vduModel.setTimeoutMinutes(heatTemplate.getTimeoutMinutes());
- // Nested templates
- Map<String,Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
- if (nestedTemplates != null) {
- for (String name : nestedTemplates.keySet()) {
- String body = (String) nestedTemplates.get(name);
- VduArtifact vduArtifact = new VduArtifact(name, body.getBytes(), ArtifactType.NESTED_TEMPLATE);
- vduArtifacts.add(vduArtifact);
- }
- }
- } catch (IllegalArgumentException e) {
- LOGGER.debug("unhandled exception in mapCloudTemplates", e);
- throw new IllegalArgumentException("Exception during mapCloudTemplates " + e.getMessage());
- }
- }
-
- private VduArtifact mapHeatTemplateToVduArtifact(HeatTemplate heatTemplate, ArtifactType artifactType) {
- VduArtifact vduArtifact = new VduArtifact();
- vduArtifact.setName(heatTemplate.getTemplateName());
- vduArtifact.setContent(heatTemplate.getHeatTemplate().getBytes());
- vduArtifact.setType(artifactType);
- return vduArtifact;
- }
-
- private void mapCloudFiles(VfModuleCustomization vfModuleCustom, VduModelInfo vduModel) {
- // TODO: These catalog objects will be refactored to be
- // non-Heat-specific
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- Map <String, HeatFiles> heatFiles = db.getHeatFilesForVfModule(vfModuleCustom.getVfModuleModelUuid());
- if (heatFiles != null) {
- for (HeatFiles heatFile: heatFiles.values()) {
- vduModel.getArtifacts().add(mapCloudFileToVduArtifact(heatFile, ArtifactType.TEXT_FILE));
- }
- }
- } catch (IllegalArgumentException e) {
- LOGGER.debug("unhandled exception in mapCloudFiles", e);
- throw new IllegalArgumentException("Exception during mapCloudFiles " + e.getMessage());
- }
- }
-
- private VduArtifact mapCloudFileToVduArtifact(HeatFiles heatFile, ArtifactType artifactType) {
- VduArtifact vduArtifact = new VduArtifact();
- vduArtifact.setName(heatFile.getFileName());
- vduArtifact.setContent(heatFile.getFileBody().getBytes());
- vduArtifact.setType(artifactType);
- return vduArtifact;
- }
-
- private void mapEnvironment(HeatEnvironment heatEnvironment, VduModelInfo vduModel) {
- // TODO: These catalog objects will be refactored to be
- // non-Heat-specific
- if (heatEnvironment != null) {
- List<VduArtifact> vduArtifacts = vduModel.getArtifacts();
- vduArtifacts.add(mapEnvironmentFileToVduArtifact(heatEnvironment));
- }
- }
-
- private VduArtifact mapEnvironmentFileToVduArtifact(HeatEnvironment heatEnv) {
- VduArtifact vduArtifact = new VduArtifact();
- vduArtifact.setName(heatEnv.getName());
- vduArtifact.setContent(heatEnv.getEnvironment().getBytes());
- vduArtifact.setType(ArtifactType.ENVIRONMENT);
- return vduArtifact;
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
deleted file mode 100644
index 749b9f9fc3..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/BpelRestClient.java
+++ /dev/null
@@ -1,281 +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.vnf;
-
-
-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_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
- private static final String PROPERTY_DOMAIN = "org.openecomp.mso.adapters.vnf";
- 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_VNF_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_VNF_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_VNF_ADAPTER;
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "MsoPropertiesException - 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 newRetryCount = retryCount;
- if (newRetryCount < 0)
- newRetryCount = DEFAULT_RETRY_COUNT;
- this.retryCount = newRetryCount;
- }
-
- 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) {
- // ignore
- }
- }
- 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.BusinessProcesssError, "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) {
- // ignore
- }
- }
- }
- 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.BusinessProcesssError, "Exception - Error 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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.java
deleted file mode 100644
index 840bd025fb..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/HealthCheckHandler.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.vnf;
-
-
-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.MediaType;
-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_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces(MediaType.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_VNF_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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java
deleted file mode 100644
index 0ff1a74064..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapter.java
+++ /dev/null
@@ -1,145 +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.vnf;
-
-
-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.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.entity.MsoRequest;
-
-import java.util.Map;
-
-@WebService (name="VnfAdapter", targetNamespace="http://org.openecomp.mso/vnf")
-public interface MsoVnfAdapter
-{
- /**
- * This is the "Create VNF" Web Service Endpoint definition.
- */
- @WebMethod
- public void createVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="inputs") Map<String,String> inputs,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId,
- @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback )
- throws VnfException, VnfAlreadyExists;
-
- @WebMethod
- public void updateVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="inputs") Map<String,String> inputs,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback )
- throws VnfException;
-
- @WebMethod
- public void queryVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="vnfExists", mode=Mode.OUT) Holder<Boolean> vnfExists,
- @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId,
- @WebParam(name="status", mode=Mode.OUT) Holder<VnfStatus> status,
- @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs )
- throws VnfException;
-
- @WebMethod
- public void deleteVnf (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="request") MsoRequest msoRequest)
- throws VnfException;
-
-
- @WebMethod
- public void rollbackVnf (@WebParam(name="rollback") @XmlElement(required=true) VnfRollback rollback)
- throws VnfException;
-
- @WebMethod
- public void createVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId,
- @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
- @WebParam(name="inputs") Map<String,String> inputs,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="vnfId", mode=Mode.OUT) Holder<String> vnfId,
- @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback )
- throws VnfException, VnfAlreadyExists;
-
- @WebMethod
- public void deleteVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vfName") @XmlElement(required=true) String vfName,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs)
- throws VnfException;
-
- @WebMethod
- public void updateVfModule (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="baseVfHeatStackId") @XmlElement(required=false) String baseVfHeatStackId,
- @WebParam(name="vfModuleStackId") @XmlElement(required=false) String vfModuleStackId,
- @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
- @WebParam(name="inputs") Map<String,String> inputs,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="outputs", mode=Mode.OUT) Holder<Map<String,String>> outputs,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<VnfRollback> rollback )
- throws VnfException;
-
- @WebMethod
- public void healthCheck ();
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java
deleted file mode 100644
index 5371b46665..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsync.java
+++ /dev/null
@@ -1,103 +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.vnf;
-
-
-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.VnfRollback;
-import java.util.Map;
-
-/**
- * This webservice defines the Asynchronous versions of VNF adapter calls.
- * The notification messages for final responses are documented elsewhere
- * (by the client service WSDL).
- *
- */
-@WebService (name="VnfAdapterAsync", targetNamespace="http://org.openecomp.mso/vnfA")
-public interface MsoVnfAdapterAsync
-{
- /**
- * This is the "Create VNF" Web Service Endpoint definition.
- */
- @WebMethod
- @Oneway
- public void createVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="inputs") Map<String,String> inputs,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @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 updateVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfType") @XmlElement(required=true) String vnfType,
- @WebParam(name="vnfVersion") @XmlElement(required=false) String vnfVersion,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @WebParam(name="requestType") @XmlElement(required=false) String requestType,
- @WebParam(name="volumeGroupHeatStackId") @XmlElement(required=false) String volumeGroupHeatStackId,
- @WebParam(name="inputs") Map<String,String> inputs,
- @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 queryVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @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 deleteVnfA (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="vnfName") @XmlElement(required=true) String vnfName,
- @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 rollbackVnfA (@WebParam(name="rollback") @XmlElement(required=true) VnfRollback 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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java
deleted file mode 100644
index df04d1d2ad..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java
+++ /dev/null
@@ -1,652 +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.vnf;
-
-
-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.vnf.async.client.CreateVnfNotification;
-import org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification;
-import org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification;
-import org.openecomp.mso.adapters.vnf.async.client.VnfAdapterNotify;
-import org.openecomp.mso.adapters.vnf.async.client.VnfAdapterNotify_Service;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-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.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-@WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://org.openecomp.mso/vnfA")
-public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
-
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
- CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();
-
- public static final String MSO_PROP_VNF_ADAPTER="MSO_PROP_VNF_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.vnf.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 VNF Adapter");
- }
-
- /**
- * This is the asynchronous "Create VNF" web service implementation.
- * It will create a new VNF of the requested type in the specified cloud
- * and tenant. The tenant must exist before this service is called.
- *
- * If a VNF with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- *
- * All VNF types will be defined in the MSO catalog. The caller must request
- * one of these pre-defined types or an error will be returned. Within the
- * catalog, each VNF type references (among other things) a Heat template
- * which is used to deploy the required VNF artifacts (VMs, networks, etc.)
- * to the cloud.
- *
- * Depending on the Heat template, a variable set of input parameters will
- * be defined, some of which are required. The caller is responsible to
- * pass the necessary input data for the VNF or an error will be thrown.
- *
- * The method sends an asynchronous response to the notification URL when
- * processing completes. The createAsyncResponse contains the vnfId (the
- * canonical name of the stack), a Map of VNF output attributes, and a
- * VnfRollback object. This last object can be passed as-is to the
- * rollbackVnf operation to undo everything that was created for the VNF.
- * This is useful if a VNF is successfully created but the orchestrator
- * fails on a subsequent operation.
- *
- * Note: this method is implemented by calling the synchronous web method
- * and translating the response to an asynchronous notification.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vnfType VNF type key, should match a VNF definition in catalog DB
- * @param vnfName Name to be assigned to the new VNF
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * a success or failure
- * @param msoRequest Request tracking information for logs
- * @param notificationURL the target URL for asynchronous response
- */
- @Override
- public void createVnfA (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
- String serviceName = "CreateVnfA";
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName (serviceName);
- LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "createVnfA");
- // Use the synchronous method to perform the actual Create
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <String> vnfId = new Holder <> ();
- Holder <Map <String, String>> outputs = new Holder <> ();
- Holder <VnfRollback> vnfRollback = new Holder <> ();
-
- try {
- vnfAdapter.createVnf (cloudSiteId,
- tenantId,
- vnfType,
- vnfVersion,
- vnfName,
- requestType,
- volumeGroupHeatStackId,
- inputs,
- failIfExists,
- backout,
- msoRequest,
- vnfId,
- outputs,
- vnfRollback);
- MsoLogger.setServiceName (serviceName);
- } catch (VnfException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException in createVnfA", e);
- org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
- .getCategory ()
- .name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.createVnfNotification (messageId, false, exCat, eMsg, null, null, null);
- } catch (Exception e1) {
- error = "Error sending createVnf notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA", "", "createVnfA");
- return;
- }
- LOGGER.debug ("Async Create VNF: " + vnfName + " VnfId:" + vnfId.value);
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.createVnfNotification (messageId,
- true,
- null,
- null,
- vnfId.value,
- copyCreateOutputs (outputs),
- copyVrb (vnfRollback));
- } catch (Exception e) {
- error = "Error sending createVnf notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA");
- return;
- }
-
- @Override
- public void updateVnfA (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
- String serviceName = "UpdateVnfA";
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext (msoRequest);
- LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "", "UpdateVnfA");
-
- // Use the synchronous method to perform the actual Create
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <String> vnfId = new Holder <> ();
- Holder <Map <String, String>> outputs = new Holder <> ();
- Holder <VnfRollback> vnfRollback = new Holder <> ();
-
- try {
- vnfAdapter.updateVnf (cloudSiteId, tenantId, vnfType,vnfVersion, vnfName, requestType, volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback);
- MsoLogger.setServiceName (serviceName);
- } catch (VnfException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e);
- org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
- .getCategory ()
- .name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.updateVnfNotification (messageId, false, exCat, eMsg, null, null);
- } catch (Exception e1) {
- error = "Error sending updateVnf notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "UpdateVnfA");
- return;
- }
- LOGGER.debug ("Async Update VNF: " + vnfName + " VnfId:" + vnfId.value);
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.updateVnfNotification (messageId,
- true,
- null,
- null,
- copyUpdateOutputs (outputs),
- copyVrb (vnfRollback));
- } catch (Exception e) {
- error = "Error sending updateVnf notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "UpdateVnfA");
- return;
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- * It will look up a VNF by name or ID in the specified cloud and tenant.
- *
- * The method returns an indicator that the VNF exists, its Openstack internal
- * ID, its status, and the set of outputs (from when the stack was created).
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param msoRequest Request tracking information for logs
- * @param notificationURL the target URL for asynchronous response
- */
- @Override
- public void queryVnfA (String cloudSiteId,
- String tenantId,
- String vnfName,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
- String serviceName = "QueryVnfA";
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext (msoRequest);
- LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF, vnfName, cloudSiteId, tenantId);
-
- // Use the synchronous method to perform the actual query
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <Boolean> vnfExists = new Holder <> ();
- Holder <String> vnfId = new Holder <> ();
- Holder <VnfStatus> status = new Holder <> ();
- Holder <Map <String, String>> outputs = new Holder <> ();
-
- try {
- vnfAdapter.queryVnf (cloudSiteId, tenantId, vnfName, msoRequest, vnfExists, vnfId, status, outputs);
- MsoLogger.setServiceName (serviceName);
- } catch (VnfException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnfA notification", e);
- org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
- .getCategory ()
- .name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.queryVnfNotification (messageId, false, exCat, eMsg, null, null, null, null);
- } catch (Exception e1) {
- error = "Error sending queryVnf notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "", "queryVnfA");
- return;
- }
-
- if (!vnfExists.value) {
- LOGGER.debug ("Async Query, VNF not found");
- } else {
- LOGGER.debug ("Async Query, VNF=" + vnfId.value + ", status=" + status.value);
- }
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- org.openecomp.mso.adapters.vnf.async.client.VnfStatus vnfS = org.openecomp.mso.adapters.vnf.async.client.VnfStatus.fromValue (status.value.name ());
- notifyPort.queryVnfNotification (messageId,
- true,
- null,
- null,
- vnfExists.value,
- vnfId.value,
- vnfS,
- copyQueryOutputs (outputs));
- } catch (Exception e) {
- error = "Error sending queryVnf notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
-
- LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "", "queryVnfA");
- return;
- }
-
- /**
- * This is the Asynchronous "Delete VNF" web service implementation.
- * It will delete a VNF by name or ID in the specified cloud and tenant.
- *
- * The method has no outputs.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to delete
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param messageId
- * @param msoRequest Request tracking information for logs
- * @param notificationUrl the target URL for asynchronous response
- */
- @Override
- public void deleteVnfA (String cloudSiteId,
- String tenantId,
- String vnfName,
- String messageId,
- MsoRequest msoRequest,
- String notificationUrl) {
- String error;
- String serviceName = "DeleteVnfA";
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext (msoRequest);
- LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF, vnfName, cloudSiteId, tenantId);
-
- // Use the synchronous method to perform the actual delete
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- try {
- vnfAdapter.deleteVnf (cloudSiteId, tenantId, vnfName, msoRequest);
- MsoLogger.setServiceName (serviceName);
- } catch (VnfException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e);
- org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
- .getCategory ()
- .name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.deleteVnfNotification (messageId, false, exCat, eMsg);
- } catch (Exception e1) {
- error = "Error sending deleteVnf notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "deleteVnfA");
- return;
- }
-
- LOGGER.debug ("Async Delete VNF: " + vnfName);
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.deleteVnfNotification (messageId, true, null, null);
-
- } catch (Exception e) {
- error = "Error sending deleteVnf notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
-
- LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "deleteVnfA");
- 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 rollbackVnf
- * operation to undo the creation.
- */
- @Override
- public void rollbackVnfA (VnfRollback rollback, String messageId, String notificationUrl) {
- String serviceName = "RollbackVnfA";
- MsoLogger.setServiceName (serviceName);
- String error;
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- error = "Empty Rollback: No action to perform";
- LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "", "rollbackVnfA");
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- return;
- }
-
- MsoLogger.setLogContext (rollback.getMsoRequest ());
- LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF, "", "rollbackVnfA");
-
- // Use the synchronous method to perform the actual rollback
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
-
- try {
- vnfAdapter.rollbackVnf (rollback);
- MsoLogger.setServiceName (serviceName);
- } catch (VnfException e) {
- MsoLogger.setServiceName (serviceName);
- LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e);
- org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
- String eMsg = null;
- try {
- eMsg = e.getFaultInfo ().getMessage ();
- exCat = org.openecomp.mso.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
- .getCategory ()
- .name ());
- } catch (Exception e1) {
- LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
- }
- // Build and send Asynchronous error response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.rollbackVnfNotification (messageId, false, exCat, eMsg);
- } catch (Exception e1) {
- error = "Error sending rollbackVnf notification " + e1.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e1);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
- LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "rollbackVnfA");
- return;
- }
-
- LOGGER.debug ("Async Rollback VNF:" + rollback.getVnfId ());
- // Build and send Asynchronous response
- try {
- VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
- notifyPort.rollbackVnfNotification (messageId, true, null, null);
- } catch (Exception e) {
- error = "Error sending rollbackVnf notification " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
- }
-
- LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "rollbackVnfA");
- return;
- }
-
- private org.openecomp.mso.adapters.vnf.async.client.VnfRollback copyVrb (Holder <VnfRollback> hVrb) {
- org.openecomp.mso.adapters.vnf.async.client.VnfRollback cvrb = new org.openecomp.mso.adapters.vnf.async.client.VnfRollback ();
-
- if (hVrb != null && hVrb.value != null) {
- org.openecomp.mso.adapters.vnf.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.vnf.async.client.MsoRequest ();
-
- cvrb.setCloudSiteId (hVrb.value.getCloudSiteId ());
- if (hVrb.value.getMsoRequest() != null) {
- cmr.setRequestId (hVrb.value.getMsoRequest ().getRequestId ());
- cmr.setServiceInstanceId (hVrb.value.getMsoRequest ().getServiceInstanceId ());
- } else {
- cmr.setRequestId (null);
- cmr.setServiceInstanceId (null);
- }
- cvrb.setMsoRequest (cmr);
- cvrb.setVnfId (hVrb.value.getVnfId ());
- cvrb.setTenantId (hVrb.value.getTenantId ());
- cvrb.setTenantCreated (hVrb.value.getTenantCreated ());
- cvrb.setVnfCreated (hVrb.value.getVnfCreated ());
- }
- return cvrb;
- }
-
- private CreateVnfNotification.Outputs copyCreateOutputs (Holder <Map <String, String>> hMap) {
-
- CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
- CreateVnfNotification.Outputs.Entry entry = new CreateVnfNotification.Outputs.Entry ();
-
- for (String key : sMap.keySet ()) {
- entry.setKey (key);
- entry.setValue (sMap.get (key));
- outputs.getEntry ().add (entry);
- }
- }
- return outputs;
- }
-
- private UpdateVnfNotification.Outputs copyUpdateOutputs (Holder <Map <String, String>> hMap) {
-
- UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
- UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry ();
-
- for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey (key);
- entry.setValue (value);
- outputs.getEntry ().add (entry);
- }
- }
- return outputs;
- }
-
- private QueryVnfNotification.Outputs copyQueryOutputs (Holder <Map <String, String>> hMap) {
-
- QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs ();
-
- if (hMap != null && hMap.value != null) {
- Map <String, String> sMap = new HashMap <> ();
- sMap = hMap.value;
-
- QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry ();
-
- for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
- String key = mapEntry.getKey();
- String value = mapEntry.getValue();
- entry.setKey (key);
- entry.setValue (value);
- outputs.getEntry ().add (entry);
- }
- }
- return outputs;
- }
-
- private VnfAdapterNotify getNotifyEP (String notificationUrl) {
-
- URL warWsdlLoc = null;
- try {
- warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("VnfAdapterNotify.wsdl");
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL not found", e);
- }
- if (warWsdlLoc == null) {
- LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "WSDL not found");
- } else {
- try {
- LOGGER.debug ("VnfAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL URL convention", e);
- }
- }
-
- VnfAdapterNotify_Service notifySvc = new VnfAdapterNotify_Service (warWsdlLoc,
- new QName ("http://org.openecomp.mso/vnfNotify",
- "vnfAdapterNotify"));
-
- VnfAdapterNotify notifyPort = notifySvc.getMsoVnfAdapterAsyncImplPort ();
-
- BindingProvider bp = (BindingProvider) notifyPort;
-
- URL epUrl = null;
- try {
- epUrl = new URL (notificationUrl);
- } catch (MalformedURLException e1) {
- LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "MalformedURLException", e1);
- }
-
- if(null != epUrl) {
- LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());
- bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());
- }
- else {
- LOGGER.debug ("epUrl is NULL:");
- }
-
- // authentication
- try {
- Map <String, Object> reqCtx = bp.getRequestContext ();
- Map <String, List <String>> headers = new HashMap <> ();
-
- String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_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) {
- LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e);
- alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, "Unable to set authorization in callback request");
- }
-
- return notifyPort;
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
deleted file mode 100644
index 48e0a56ef1..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java
+++ /dev/null
@@ -1,2176 +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.vnf;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
-
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfNotFound;
-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.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-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.StackInfo;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
-public class MsoVnfAdapterImpl implements MsoVnfAdapter {
-
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- protected CloudConfig cloudConfig = null;
-
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
- protected MsoHeatUtils heat;
-
- private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
- private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
- private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
- private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters";
- private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.openecomp.mso.adapters.vnf.addGetFilesOnVolumeReq";
- private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
-
- /**
- * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
- *
- * @see MsoVnfAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
- */
- public MsoVnfAdapterImpl() {
- // empty implementation
- }
-
- /**
- * This constructor MUST be used if this class is called with the new operator.
- *
- * @param msoPropFactory
- */
- public MsoVnfAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) {
- this.msoPropertiesFactory = msoPropFactory;
- this.cloudConfigFactory = cloudConfigFact;
- heat = new MsoHeatUtils(MSO_PROP_VNF_ADAPTER, this.msoPropertiesFactory, this.cloudConfigFactory);
- }
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck() {
- LOGGER.debug("Health check call in VNF Adapter");
- }
-
- /**
- * This is the "Create VNF" web service implementation.
- * It will create a new VNF of the requested type in the specified cloud
- * and tenant. The tenant must exist before this service is called.
- * <p>
- * If a VNF with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- * <p>
- * All VNF types will be defined in the MSO catalog. The caller must request
- * one of these pre-defined types or an error will be returned. Within the
- * catalog, each VNF type references (among other things) a Heat template
- * which is used to deploy the required VNF artifacts (VMs, networks, etc.)
- * to the cloud.
- * <p>
- * Depending on the Heat template, a variable set of input parameters will
- * be defined, some of which are required. The caller is responsible to
- * pass the necessary input data for the VNF or an error will be thrown.
- * <p>
- * The method returns the vnfId (the canonical name), a Map of VNF output
- * attributes, and a VnfRollback object. This last object can be passed
- * as-is to the rollbackVnf operation to undo everything that was created
- * for the VNF. This is useful if a VNF is successfully created but the
- * orchestrator fails on a subsequent operation.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vnfType VNF type key, should match a VNF definition in catalog DB
- * @param vnfVersion VNF version key, should match a VNF definition in catalog DB
- * @param vnfName Name to be assigned to the new VNF
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * a success or failure
- * @param msoRequest Request tracking information for logs
- * @param vnfId Holder for output VNF Openstack ID
- * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
- * @param rollback Holder for returning VnfRollback object
- */
- @Override
- public void createVnf(String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map<String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder<String> vnfId,
- Holder<Map<String, String>> outputs,
- Holder<VnfRollback> rollback) throws VnfException {
- // Create a hook here to catch shortcut createVf requests:
- if (requestType != null) {
- if (requestType.startsWith("VFMOD")) {
- LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType);
- String newRequestType = requestType.substring(5);
- String vfVolGroupHeatStackId = "";
- String vfBaseHeatStackId = "";
- try {
- if (volumeGroupHeatStackId != null) {
- vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|"));
- vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|") + 1);
- }
- } catch (Exception e) {
- // might be ok - both are just blank
- LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId, e);
- }
- this.createVfModule(cloudSiteId,
- tenantId,
- vnfType,
- vnfVersion,
- vnfName,
- newRequestType,
- vfVolGroupHeatStackId,
- vfBaseHeatStackId,
- null,
- inputs,
- failIfExists,
- backout,
- msoRequest,
- vnfId,
- outputs,
- rollback);
- return;
- }
- }
- // createVf will know if the requestType starts with "X" that it's the "old" way
- StringBuilder newRequestTypeSb = new StringBuilder("X");
- String vfVolGroupHeatStackId = "";
- String vfBaseHeatStackId = "";
- if (requestType != null) {
- newRequestTypeSb.append(requestType);
- }
- this.createVfModule(cloudSiteId,
- tenantId,
- vnfType,
- vnfVersion,
- vnfName,
- newRequestTypeSb.toString(),
- vfVolGroupHeatStackId,
- vfBaseHeatStackId,
- null,
- inputs,
- failIfExists,
- backout,
- msoRequest,
- vnfId,
- outputs,
- rollback);
- // End createVf shortcut
- }
-
- @Override
- public void updateVnf(String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map<String, String> inputs,
- MsoRequest msoRequest,
- Holder<Map<String, String>> outputs,
- Holder<VnfRollback> rollback) throws VnfException {
- // As of 1707 - this method should no longer be called
- MsoLogger.setLogContext(msoRequest.getRequestId(), msoRequest.getServiceInstanceId());
- MsoLogger.setServiceName("UpdateVnf");
- LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule");
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- * It will look up a VNF by name or ID in the specified cloud and tenant.
- * <p>
- * The method returns an indicator that the VNF exists, its Openstack internal
- * ID, its status, and the set of outputs (from when the stack was created).
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF Openstack ID
- * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
- */
- @Override
- public void queryVnf(String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest,
- Holder<Boolean> vnfExists,
- Holder<String> vnfId,
- Holder<VnfStatus> status,
- Holder<Map<String, String>> outputs) throws VnfException {
- MsoLogger.setLogContext(msoRequest);
- MsoLogger.setServiceName("QueryVnf");
- LOGGER.debug("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
-
- StackInfo heatStack = null;
- long subStartTime = System.currentTimeMillis();
- try {
- heatStack = heat.queryStack(cloudSiteId, tenantId, vnfName);
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vnfName);
- } catch (MsoException me) {
- me.addContext("QueryVNF");
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- String error = "Query VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vnfName);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
-
- // Populate the outputs based on the returned Stack information
- //
- if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) {
- // Not Found
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap<>(); // Return as an empty map
-
- LOGGER.debug("VNF " + vnfName + " not found");
- } else {
- vnfExists.value = Boolean.TRUE;
- status.value = stackStatusToVnfStatus(heatStack.getStatus());
- vnfId.value = heatStack.getCanonicalName();
- outputs.value = copyStringOutputs(heatStack.getOutputs());
-
- LOGGER.debug("VNF " + vnfName + " found, ID = " + vnfId.value);
- }
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF");
- }
-
- /**
- * This is the "Delete VNF" web service implementation.
- * It will delete a VNF by name or ID in the specified cloud and tenant.
- * <p>
- * The method has no outputs.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to delete
- * @param tenantId Openstack tenant identifier
- * @param vnfName VNF Name or Openstack ID
- * @param msoRequest Request tracking information for logs
- */
- @Override
- public void deleteVnf(String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest) throws VnfException {
- MsoLogger.setLogContext(msoRequest);
- MsoLogger.setServiceName("DeleteVnf");
- LOGGER.debug("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
-
- // Use the MsoHeatUtils to delete the stack. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- long subStartTime = System.currentTimeMillis();
- try {
- heat.deleteStack(tenantId, cloudSiteId, vnfName, true);
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", vnfName);
- } catch (MsoException me) {
- me.addContext("DeleteVNF");
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- String error = "Delete VNF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName);
- LOGGER.error(MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteVNF", MsoLogger.ErrorCode.DataError, "Exception - DeleteVNF", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
-
- // On success, nothing is returned.
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF");
- }
-
- /**
- * 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.
- */
- @Override
- public void rollbackVnf(VnfRollback rollback) throws VnfException {
- long startTime = System.currentTimeMillis();
- MsoLogger.setServiceName("RollbackVnf");
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- LOGGER.info(MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null");
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudSiteId();
- String tenantId = rollback.getTenantId();
- String vnfId = rollback.getVnfId();
-
- MsoLogger.setLogContext(rollback.getMsoRequest());
-
- LOGGER.debug("Rolling Back VNF " + vnfId + " in " + cloudSiteId + "/" + tenantId);
-
- // Use the MsoHeatUtils to delete the stack. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- long subStartTime = System.currentTimeMillis();
- try {
- heat.deleteStack(tenantId, cloudSiteId, vnfId, true);
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null);
- } catch (MsoException me) {
- // Failed to rollback the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("RollbackVNF");
- String error = "Rollback VNF: " + vnfId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error(MessageEnum.RA_DELETE_VNF_ERR, vnfId, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - DeleteStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF");
- }
-
- private VnfStatus stackStatusToVnfStatus(HeatStatus stackStatus) {
- switch (stackStatus) {
- case CREATED:
- return VnfStatus.ACTIVE;
- case UPDATED:
- return VnfStatus.ACTIVE;
- case FAILED:
- return VnfStatus.FAILED;
- default:
- return VnfStatus.UNKNOWN;
- }
- }
-
- private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) {
- Map<String, String> stringOutputs = new HashMap<>();
- for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof String) {
- stringOutputs.put(key, (String) value);
- } else if (value instanceof Integer) {
- try {
- String str = "" + value;
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs", e);
- }
- } else if (value instanceof JsonNode) {
- try {
- //String str = this.convertNode((JsonNode) value);
- String str = value.toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e);
- }
- } else if (value instanceof java.util.LinkedHashMap) {
- try {
- //String str = JSON_MAPPER.writeValueAsString(value);
- String str = value.toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e);
- }
- } else {
- try {
- String str = value.toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), e);
- }
- }
- }
- return stringOutputs;
- }
-
- private Map<String, Object> copyStringInputs(Map<String, String> stringInputs) {
- return new HashMap<>(stringInputs);
- }
-
- private boolean callHeatbridge(String heatStackId) {
- String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge";
- String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = "";
- long waitTimeMs = 10000L;
- try {
- String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId};
- String[] envp = null;
- File dir = new File(executionDir);
- LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray));
- Runtime r = Runtime.getRuntime();
- Process p = r.exec(cmdarray, envp, dir);
- boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS);
-
- LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue());
- return wait && p.exitValue() == 0;
- } catch (IOException e) {
- LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e);
- return false;
- } catch (InterruptedException e) {
- LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e);
- return false;
- } catch (RuntimeException e) {
- LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e);
- return false;
- }
- }
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (Map.Entry<String, Object> entry : inputs.entrySet()) {
- String outputString;
- String str = entry.getKey();
- Object value = entry.getValue();
- try {
- outputString = value.toString();
- } catch (Exception e) {
- LOGGER.debug("Exception :", e);
- outputString = "Unable to call toString() on the value for " + str;
- }
- sb.append("\t\nitem ").append(i++).append(": '").append(str).append("'='").append(outputString)
- .append("'");
- }
- }
- LOGGER.debug(sb.toString());
- }
-
- private void sendMapToDebug(Map<String, String> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- } else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- sb.append("\titem ").append(i++).append(": ").append(str).append("=").append(inputs.get(str));
- }
- }
- LOGGER.debug(sb.toString());
- }
-
- private String convertNode(final JsonNode node) {
- try {
- final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
- } catch (Exception e) {
- LOGGER.debug("Error converting json to string " + e.getMessage(), e);
- }
- return "[Error converting json to string]";
- }
-
- private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) {
- if (objectMap == null) {
- return null;
- }
- Map<String, String> stringMap = new HashMap<>();
- for (String key : objectMap.keySet()) {
- if (!stringMap.containsKey(key)) {
- Object obj = objectMap.get(key);
- if (obj instanceof String) {
- stringMap.put(key, (String) objectMap.get(key));
- } else if (obj instanceof JsonNode) {
- // This is a bit of mess - but I think it's the least impacting
- // let's convert it BACK to a string - then it will get converted back later
- try {
- String str = this.convertNode((JsonNode) obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode " + key, e);
- //okay in this instance - only string values (fqdn) are expected to be needed
- }
- } else if (obj instanceof java.util.LinkedHashMap) {
- LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode");
- try {
- String str = JSON_MAPPER.writeValueAsString(obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + key, e);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer " + key, e);
- }
- } else {
- try {
- String str = obj.toString();
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value " + key + " (" + e.getMessage() + ")", e);
- }
- }
- }
- }
-
- return stringMap;
- }
-
- @Override
- public void createVfModule(String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- String baseVfHeatStackId,
- String modelCustomizationUuid,
- Map<String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder<String> vnfId,
- Holder<Map<String, String>> outputs,
- Holder<VnfRollback> rollback) throws VnfException {
- String vfModuleName = vnfName;
- String vfModuleType = vnfType;
- String vfVersion = vnfVersion;
- String mcu = modelCustomizationUuid;
- boolean useMCUuid = false;
- if (mcu != null && !mcu.isEmpty()) {
- if ("null".equalsIgnoreCase(mcu)) {
- LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid);
- useMCUuid = false;
- mcu = "";
- } else {
- LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu);
- useMCUuid = true;
- }
- }
- MsoLogger.setLogContext(msoRequest);
- MsoLogger.setServiceName("CreateVfModule");
- String requestTypeString = "";
- if (requestType != null && !"".equals(requestType)) {
- requestTypeString = requestType;
- }
- String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
- if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
- nestedStackId = volumeGroupHeatStackId;
- }
- }
- String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
- if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
- nestedBaseStackId = baseVfHeatStackId;
- }
- }
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- LOGGER.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
- //This method will also handle doing things the "old" way - i.e., just orchestrate a VNF
- boolean oldWay = false;
- if (requestTypeString.startsWith("X")) {
- oldWay = true;
- LOGGER.debug("orchestrating a VNF - *NOT* a module!");
- requestTypeString = requestTypeString.substring(1);
- }
-
- // 1607 - let's parse out the request type we're being sent
- boolean isBaseRequest = false;
- boolean isVolumeRequest = false;
- if (requestTypeString.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
-
- LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestTypeString);
- vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId);
- vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId);
- vfRollback.setIsBase(isBaseRequest);
- vfRollback.setModelCustomizationUuid(mcu);
-
- // Put data into A&AI through Heatstack
- callHeatbridge(baseVfHeatStackId);
-
- // First, look up to see if the VF already exists.
- StackInfo heatStack = null;
- long subStartTime1 = System.currentTimeMillis();
- try {
- heatStack = heat.queryStack(cloudSiteId, tenantId, vfModuleName);
- LOGGER.recordMetricEvent(subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
- } catch (MsoException me) {
- String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - queryStack", me);
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("CreateVFModule");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- // New with 1607 - more precise handling/messaging if the stack already exists
- if (heatStack != null && !(heatStack.getStatus() == HeatStatus.NOTFOUND)) {
- // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED
- HeatStatus status = heatStack.getStatus();
- if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) {
- // fail - it's in progress - return meaningful error
- String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually.";
- LOGGER.error(MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName());
- }
- if (status == HeatStatus.FAILED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error(MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName());
- }
- if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error(MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName());
- }
- if (status == HeatStatus.CREATED) {
- // fail - it exists
- if (failIfExists != null && failIfExists) {
- String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
- LOGGER.error(MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists(vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName());
- } else {
- LOGGER.debug("Found Existing stack, status=" + heatStack.getStatus());
- // Populate the outputs from the existing stack.
- vnfId.value = heatStack.getCanonicalName();
- outputs.value = copyStringOutputs(heatStack.getOutputs());
- rollback.value = vfRollback; // Default rollback - no updates performed
- }
- }
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- return;
-
- }
-
- // handle a nestedStackId if sent- this one would be for the volume - so applies to both Vf and Vnf
- StackInfo nestedHeatStack = null;
- long subStartTime2 = System.currentTimeMillis();
- Map<String, Object> nestedVolumeOutputs = null;
- if (nestedStackId != null) {
- try {
- LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
- nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
- LOGGER.recordMetricEvent(subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("CreateVFModule");
- String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me);
- LOGGER.debug("ERROR trying to query nested stack= " + error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR";
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*");
- //this.sendMapToDebug(inputs);
- nestedVolumeOutputs = nestedHeatStack.getOutputs();
- this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
- //TODO
- //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
- }
-
- // handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests
- StackInfo nestedBaseHeatStack = null;
- long subStartTime3 = System.currentTimeMillis();
- Map<String, Object> baseStackOutputs = null;
- if (nestedBaseStackId != null) {
- try {
- LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
- nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
- LOGGER.recordMetricEvent(subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("CreateVFModule");
- String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me);
- LOGGER.debug("ERROR trying to query nested base stack= " + error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR";
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*");
- //this.sendMapToDebug(inputs);
- baseStackOutputs = nestedBaseHeatStack.getOutputs();
- this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
- //TODO
- //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
- }
-
- // Ready to deploy the new VNF
-
- try (CatalogDatabase db = getCatalogDatabase()) {
- // Retrieve the VF
- VfModule vf = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfmc = null;
- LOGGER.debug("version: " + vfVersion);
- if (useMCUuid) {
- // 1707 - db refactoring
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
- vf = vfmc != null ? vfmc.getVfModule() : null;
- // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same.
- //vf = db.getVfModuleByModelCustomizationUuid(mcu);
- if (vf == null) {
- LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu);
- String error =
- "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "",
- MsoLogger.ErrorCode.DataError,
- "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
- }
- if (vf.isBase()) {
- isBaseRequest = true;
- LOGGER.debug("This is a BASE VF request!");
- } else {
- LOGGER.debug("This is *not* a BASE VF request!");
- if (!isVolumeRequest && nestedBaseStackId == null) {
- LOGGER.debug(
- "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
- }
- }
- } else { // This is to support gamma only - get info from vnf_resource table
- if (vfVersion != null && !vfVersion.isEmpty()) {
- vnfResource = db.getVnfResource(vnfType, vnfVersion);
- } else {
- vnfResource = db.getVnfResource(vnfType);
- }
- if (vnfResource == null) {
- String error = "Create VNF: Unknown VNF Type: " + vnfType;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type",
- vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- LOGGER.debug("Got VNF module definition from Catalog: "
- + vnfResource.toString());
- }
- // By here - we have either a vf or vnfResource
-
- //1607 - Add version check
- // First - see if it's in the VnfResource record
- // if we have a vf Module - then we have to query to get the VnfResource record.
- if (!oldWay) {
- if (vf.getVnfResourceModelUUId() != null) {
- String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
- //vnfResource = db.getVnfResourceById(vnfResourceId);
- vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
- if (vnfResource == null) {
- LOGGER.debug(
- "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
- }
- }
- }
- String minVersionVnf = null;
- String maxVersionVnf = null;
- if (vnfResource != null) {
- try {
- minVersionVnf = vnfResource.getAicVersionMin();
- maxVersionVnf = vnfResource.getAicVersionMax();
- } catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
- minVersionVnf = null;
- maxVersionVnf = null;
- }
- if (minVersionVnf != null && "".equals(minVersionVnf)) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
- maxVersionVnf = null;
- }
- }
- if (minVersionVnf != null && maxVersionVnf != null) {
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- if (this.cloudConfig == null) {
- this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
- }
- // double check
- if (this.cloudConfig != null) {
- Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSiteOpt.isPresent()) {
- aicV.setVersion(cloudSiteOpt.get().getAic_version());
- // Add code to handle unexpected values in here
- boolean moreThanMin = true;
- boolean equalToMin = true;
- boolean moreThanMax = true;
- boolean equalToMax = true;
- boolean doNotTest = false;
- try {
- moreThanMin = aicV.isMoreRecentThan(minVersionVnf);
- equalToMin = aicV.isTheSameVersion(minVersionVnf);
- moreThanMax = aicV.isMoreRecentThan(maxVersionVnf);
- equalToMax = aicV.isTheSameVersion(maxVersionVnf);
- } catch (Exception e) {
- LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage()
- + " - will default to not check", e);
- doNotTest = true;
- }
- if (!doNotTest) {
- if ((moreThanMin || equalToMin) // aic >= min
- && (equalToMax || !(moreThanMax))) { //aic <= max
- LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource
- .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf
- + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:"
- + cloudSiteOpt.get().getAic_version());
- } else {
- // ERROR
- String error =
- "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource
- .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:"
- + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId()
- + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- } else {
- LOGGER.debug("bypassing testing AIC version...");
- }
- } // let this error out downstream to avoid introducing uncertainty at this stage
- } else {
- LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
- }
- } else {
- LOGGER.debug(
- "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
- }
- // End Version check 1607
-
- // with VF_MODULE - we have both the non-vol and vol template/envs in that object
- // with VNF_RESOURCE - we use the old methods.
- //Integer heatTemplateId = null;
- //Integer heatEnvtId = null;
-
- String heatTemplateArtifactUuid = null;
- String heatEnvironmentArtifactUuid = null;
-
- if (!oldWay) {
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
- }
- } else {
- if (isVolumeRequest) {
- LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
- } else {
- heatTemplateArtifactUuid = vnfResource.getTemplateId();
- heatEnvironmentArtifactUuid = null;
- }
- }
- // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null)
- HeatTemplate heatTemplate = null;
- if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) {
- String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
- }
- if (heatTemplate == null) {
- String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug("Got HEAT Template from DB");
-
- HeatEnvironment heatEnvironment = null;
- String heatEnvironmentString = null;
-
- if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
- LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
- heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
- if (heatEnvironment == null) {
- String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
- String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment",
- MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
- heatEnvironmentString = heatEnvironment
- .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
- LOGGER.debug("after parsing: " + heatEnvironmentString);
- }
- } else {
- LOGGER.debug("no environment parameter found for this Type " + vfModuleType);
- }
-
- // Replace flavors in environment with those returned by OOF
- Map<String, Object> returnMap = updateFlavorsFromOof(heatEnvironmentString, inputs);
- heatEnvironmentString = returnMap.get("heatEnvironmentString").toString();
- LOGGER.debug("After OOF Update Heat Env String is: " + heatEnvironmentString);
- if (returnMap.get("inputs") instanceof Map) {
- inputs = (Map<String, String>) returnMap.get("inputs");
- LOGGER.debug("After OOF Update inputs are: " + inputs.toString());
- } else {
- LOGGER.debug("inputs is not an instance of a Map: " + returnMap.get("inputs"));
- throw new VnfException("Updating inputs using OOF info failed.", MsoExceptionCategory.INTERNAL);
- }
-
- // 1510 - Add the files: for nested templates *if* there are any
- LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId="
- + heatTemplate.getArtifactUuid());
- Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
- Map<String, Object> nestedTemplatesChecked = new HashMap<>();
- if (nestedTemplates != null) {
- // for debugging print them out
- LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
- for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
- String providerResourceFile = entry.getKey();
- Object value = entry.getValue();
- String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) value;
- LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
- nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
- }
- } else {
- LOGGER.debug("No nested templates found - nothing to do here");
- nestedTemplatesChecked = null; // just to make sure
- }
-
- // 1510 - Also add the files: for any get_files associated with this vnf_resource_id
- // *if* there are any
- Map<String, HeatFiles> heatFiles = null;
- Map<String, Object> heatFilesObjects = new HashMap<>();
-
- // Add ability to turn on adding get_files with volume requests (by property).
- boolean addGetFilesOnVolumeReq = false;
- try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
- if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
- addGetFilesOnVolumeReq = true;
- LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
- }
- } catch (Exception e) {
- LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e);
- }
-
- if (!isVolumeRequest || addGetFilesOnVolumeReq) {
- if (oldWay) {
- LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!");
- //heatFiles = db.getHeatFiles(vnfResource.getId());
- } else {
- // 1607 - now use VF_MODULE_TO_HEAT_FILES table
- LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
- + vf.getModelUUID());
- heatFiles = db
- .getHeatFilesForVfModule(vf.getModelUUID());
- }
- if (heatFiles != null) {
- // add these to stack - to be done in createStack
- // here, we will map them to Map<String, Object> from
- // Map<String, HeatFiles>
- // this will match the nested templates format
- LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
-
- for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
- String heatFileName = entry.getKey();
- HeatFiles value = entry.getValue();
- if (heatFileName.startsWith("_ERROR|")) {
- // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
- String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1);
- String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId;
- LOGGER.debug(error);
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- String heatFileBody = value.getFileBody();
- String heatFileNameChecked = heatFileName;
- LOGGER.debug(heatFileNameChecked + " -> "
- + heatFileBody);
- heatFilesObjects.put(heatFileNameChecked, heatFileBody);
- }
- } else {
- LOGGER.debug("No heat files found -nothing to do here");
- heatFilesObjects = null;
- }
- } else {
- LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
- }
-
- // Check that required parameters have been supplied
- StringBuilder missingParams = null;
- List<String> paramList = new ArrayList<>();
-
- // New for 1510 - consult the PARAM_ALIAS field to see if we've been
- // supplied an alias. Only check if we don't find it initially.
- // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there.
- // And also new - add parameter to turn off checking all together if we find we're blocking orders we
- // shouldn't
- boolean checkRequiredParameters = true;
- try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
- .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
- if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
- checkRequiredParameters = false;
- LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
- }
- // 1604 - Add enhanced environment & parameter checking
- // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
- // Part 2: only submit to openstack the parameters in the envt that are in the heat template
- // Note this also removes any comments
- MsoHeatEnvironmentEntry mhee = null;
- if (heatEnvironmentString != null && heatEnvironmentString.contains("parameters:")) {
- //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases");
- LOGGER.debug("Enhanced environment checking enabled - 1604");
- StringBuilder sb = new StringBuilder(heatEnvironmentString);
- //LOGGER.debug("About to create MHEE with " + sb);
- mhee = new MsoHeatEnvironmentEntry(sb);
-
- StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
- }
- if (!mhee.isValid()) {
- sb2.append("Environment says it's not valid! " + mhee.getErrorString());
- } else {
- sb2.append("\nEnvironment:");
- sb2.append(mhee);
- }
- LOGGER.debug(sb2.toString());
- } else {
- LOGGER.debug("NO ENVIRONMENT for this entry");
- }
- // New with 1707 - all variables converted to their native object types
- HashMap<String, Object> goldenInputs = null;
-
- LOGGER.debug("Now handle the inputs....first convert");
- ArrayList<String> parameterNames = new ArrayList<>();
- HashMap<String, String> aliasToParam = new HashMap<>();
- StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n");
- int cntr = 0;
- try {
- for (HeatTemplateParam htp : heatTemplate.getParameters()) {
- sb.append("param[" + cntr++ + "]=" + htp.getParamName());
- parameterNames.add(htp.getParamName());
- if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
- aliasToParam.put(htp.getParamAlias(), htp.getParamName());
- sb.append(" ** (alias=" + htp.getParamAlias() + ")");
- }
- sb.append("\n");
- }
- LOGGER.debug(sb.toString());
- } catch (Exception e) {
- LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(), e);
- }
- // Step 1 - convert what we got as inputs (Map<String, String>) to a
- // Map<String, Object> - where the object matches the param type identified in the template
- // This will also not copy over params that aren't identified in the template
- goldenInputs = heat.convertInputMap(inputs, heatTemplate);
- // Step 2 - now simply add the outputs as we received them - no need to convert to string
- LOGGER.debug("Now add in the base stack outputs if applicable");
- heat.copyBaseOutputsToInputs(goldenInputs, baseStackOutputs, parameterNames, aliasToParam);
- // Step 3 - add the volume inputs if any
- LOGGER.debug("Now add in the volume stack outputs if applicable");
- heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam);
- this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack");
-
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- LOGGER.debug("Parameter:'" + parm.getParamName()
- + "', isRequired="
- + parm.isRequired()
- + ", alias="
- + parm.getParamAlias());
-
- if (parm.isRequired() && (goldenInputs == null || !goldenInputs.containsKey(parm.getParamName()))) {
- // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object>
- LOGGER.debug("**Parameter " + parm.getParamName()
- + " is required and not in the inputs...check environment");
- if (mhee != null && mhee.containsParameter(parm.getParamName())) {
- LOGGER.debug("Required parameter " + parm.getParamName()
- + " appears to be in environment - do not count as missing");
- } else {
- LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
- if (missingParams == null) {
- missingParams = new StringBuilder(parm.getParamName());
- } else {
- missingParams.append("," + parm.getParamName());
- }
- }
- }
- paramList.add(parm.getParamName());
- }
- if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
- error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
- }
- } else {
- LOGGER.debug("No missing parameters found - ok to proceed");
- }
- // We can now remove the recreating of the ENV with only legit params - that check is done for us,
- // and it causes problems with json that has arrays
- String newEnvironmentString = null;
- if (mhee != null) {
- newEnvironmentString = mhee.getRawEntry().toString();
- }
-
- // "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate();
- template = template.replaceAll("\r\n", "\n");
-
- // Have the tenant. Now deploy the stack itself
- // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
- // because we already checked for those.
- long createStackStarttime = System.currentTimeMillis();
- try {
- // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true,
- // heatTemplate.getTimeoutMinutes());
- if (backout == null) {
- backout = true;
- }
- if (heat != null) {
- LOGGER.debug("heat is not null!!");
- }
- heatStack = heat.createStack(cloudSiteId,
- tenantId,
- vfModuleName,
- template,
- goldenInputs,
- true,
- heatTemplate.getTimeoutMinutes(),
- newEnvironmentString,
- nestedTemplatesChecked,
- heatFilesObjects,
- backout.booleanValue());
- LOGGER
- .recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName);
- } catch (MsoException me) {
- me.addContext("CreateVFModule");
- String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
- LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "MsoException - createStack", me);
- LOGGER
- .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
- error);
- throw new VnfException(me);
- } catch (NullPointerException npe) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe;
- LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName);
- LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe);
- LOGGER
- .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
- error);
- LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack");
- //npe.addContext ("CreateVNF");
- throw new VnfException("NullPointerException during heat.createStack");
- } catch (Exception e) {
- LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack",
- "OpenStack", "CreateStack", vfModuleName);
- LOGGER.debug("unhandled exception at heat.createStack", e);
- LOGGER
- .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
- "Exception while creating stack with OpenStack");
- throw new VnfException("Exception during heat.createStack! " + e.getMessage());
- }
- } catch (Exception e) {
- LOGGER.debug("unhandled exception in create VF", e);
- throw new VnfException("Exception during create VF " + e.getMessage());
- }
-
- // Make sure DB session is closed
-
- // Reach this point if createStack is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfId(heatStack.getCanonicalName());
- vfRollback.setVnfCreated(true);
-
- vnfId.value = heatStack.getCanonicalName();
- outputs.value = copyStringOutputs(heatStack.getOutputs());
- rollback.value = vfRollback;
-
- LOGGER.debug("VF Module " + vfModuleName + " successfully created");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- }
-
- @Override
- public void deleteVfModule(String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest,
- Holder<Map<String, String>> outputs) throws VnfException {
- MsoLogger.setLogContext(msoRequest);
- MsoLogger.setServiceName("DeleteVf");
- LOGGER.debug("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
-
- // 1702 capture the output parameters on a delete
- // so we'll need to query first
- Map<String, Object> stackOutputs = null;
- try {
- stackOutputs = heat.queryStackForOutputs(cloudSiteId, tenantId, vnfName);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("DeleteVFModule");
- String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types
- outputs.value = this.convertMapStringObjectToStringString(stackOutputs);
-
- // Use the MsoHeatUtils to delete the stack. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- long subStartTime = System.currentTimeMillis();
- try {
- heat.deleteStack(tenantId, cloudSiteId, vnfName, true);
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", vnfName);
- } catch (MsoException me) {
- me.addContext("DeleteVNF");
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- String error = "Delete VF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", vnfName);
- LOGGER.error(MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "DeleteStack", MsoLogger.ErrorCode.DataError, "Exception - deleteStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
-
- // On success, nothing is returned.
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF");
- }
-
- @Override
- public void updateVfModule(String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- String baseVfHeatStackId,
- String vfModuleStackId,
- String modelCustomizationUuid,
- Map<String, String> inputs,
- MsoRequest msoRequest,
- Holder<Map<String, String>> outputs,
- Holder<VnfRollback> rollback) throws VnfException {
- String vfModuleName = vnfName;
- String vfModuleType = vnfType;
- String methodName = "updateVfModule";
- MsoLogger.setLogContext(msoRequest.getRequestId(), msoRequest.getServiceInstanceId());
- String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
- MsoLogger.setServiceName(serviceName);
-
- String strInit = "updateVfModule: cloudSiteId=" + cloudSiteId +
- ",tenantId=" + tenantId +
- ",vnfType=" + vnfType +
- ",vnfVersion=" + vnfVersion +
- ",vnfName=" + vnfName +
- ",requestType=" + requestType +
- ",volumeGroupHeatStackId=" + volumeGroupHeatStackId +
- ",baseVfHeatStackId=" + baseVfHeatStackId +
- ",vfModuleStackId=" + vfModuleStackId +
- ",modelCustomizationUuid=" + modelCustomizationUuid;
- LOGGER.debug(strInit);
-
- String mcu = modelCustomizationUuid;
- boolean useMCUuid = false;
- if (mcu != null && !mcu.isEmpty()) {
- if (mcu.equalsIgnoreCase("null")) {
- LOGGER.debug("modelCustomizationUuid: passed in as the string 'null' - will ignore: " + modelCustomizationUuid);
- useMCUuid = false;
- mcu = "";
- } else {
- LOGGER.debug("Found modelCustomizationUuid! Will use that: " + mcu);
- useMCUuid = true;
- }
- }
-
- String requestTypeString = "";
- if (requestType != null && !"".equals(requestType)) {
- requestTypeString = requestType;
- }
- String nestedStackId = null;
- if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) {
- if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) {
- nestedStackId = volumeGroupHeatStackId;
- }
- }
- String nestedBaseStackId = null;
- if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) {
- if (!"null".equalsIgnoreCase(baseVfHeatStackId)) {
- nestedBaseStackId = baseVfHeatStackId;
- }
- }
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- LOGGER.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
- boolean isBaseRequest = false;
- boolean isVolumeRequest = false;
- if (requestTypeString.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
- if (vfModuleName == null || "".equals(vfModuleName.trim())) {
- if (vfModuleStackId != null) {
- vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId);
- }
- }
-
- LOGGER.debug("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId);
- LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedVolumeStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis();
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestTypeString);
- vfRollback.setVolumeGroupHeatStackId(volumeGroupHeatStackId);
- vfRollback.setBaseGroupHeatStackId(baseVfHeatStackId);
- vfRollback.setIsBase(isBaseRequest);
- vfRollback.setVfModuleStackId(vfModuleStackId);
- vfRollback.setModelCustomizationUuid(mcu);
-
- // First, look up to see if the VNF already exists.
- MsoHeatUtilsWithUpdate heatU = new MsoHeatUtilsWithUpdate(MSO_PROP_VNF_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
-
- StackInfo heatStack = null;
- long queryStackStarttime = System.currentTimeMillis();
- LOGGER.debug("UpdateVfModule - querying for " + vfModuleName);
- try {
- heatStack = heat.queryStack(cloudSiteId, tenantId, vfModuleName);
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("UpdateVFModule");
- String error = "Update VFModule: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
-
- //TODO - do we need to check for the other status possibilities?
- if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) {
- // Not Found
- String error = "Update VF: Stack " + vfModuleName + " does not exist in " + cloudSiteId + "/" + tenantId;
- LOGGER.error(MessageEnum.RA_VNF_NOT_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfNotFound(cloudSiteId, tenantId, vfModuleName);
- } else {
- LOGGER.debug("Found Existing stack, status=" + heatStack.getStatus());
- // Populate the outputs from the existing stack.
- outputs.value = copyStringOutputs(heatStack.getOutputs());
- rollback.value = vfRollback; // Default rollback - no updates performed
- }
-
- // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId):
- StackInfo nestedHeatStack = null;
- long queryStackStarttime2 = System.currentTimeMillis();
- Map<String, Object> nestedVolumeOutputs = null;
- if (nestedStackId != null) {
- try {
- LOGGER.debug("Querying for nestedStackId = " + nestedStackId);
- nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId);
- LOGGER.recordMetricEvent(queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("UpdateVFModule");
- String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER.debug("ERROR trying to query nested stack= " + error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- MsoLogger.setServiceName(serviceName);
- String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR";
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
- LOGGER.debug(error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested heat stack - copying values to inputs *later*");
- nestedVolumeOutputs = nestedHeatStack.getOutputs();
- //this.sendMapToDebug(inputs);
- this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs");
- //TODO
- heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
- }
- // handle a nestedBaseStackId if sent - this is the stack ID of the base.
- StackInfo nestedBaseHeatStack = null;
- Map<String, Object> baseStackOutputs = null;
- if (nestedBaseStackId != null) {
- long queryStackStarttime3 = System.currentTimeMillis();
- try {
- LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId);
- nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId);
- LOGGER.recordMetricEvent(queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null);
- } catch (MsoException me) {
- // Failed to query the Stack due to an openstack exception.
- // Convert to a generic VnfException
- me.addContext("UpdateVfModule");
- String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER.debug("ERROR trying to query nested base stack= " + error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException(me);
- }
- if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) {
- MsoLogger.setServiceName(serviceName);
- String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR";
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested base heat stack - copying values to inputs *later*");
- baseStackOutputs = nestedBaseHeatStack.getOutputs();
- //this.sendMapToDebug(inputs);
- this.sendMapToDebug(baseStackOutputs, "baseStackOutputs");
- //TODO
- heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false);
- //this.sendMapToDebug(inputs);
- }
- }
-
- // Ready to deploy the new VNF
-
- // Get a handle to the Catalog Database
-
- // Make sure DB session is closed
- try (CatalogDatabase db = this.getCatalogDatabase()) {
- // Retrieve the VF definition
- VnfResource vnfResource = null;
- VfModule vf = null;
- VfModuleCustomization vfmc = null;
- if (useMCUuid) {
- //vf = db.getVfModuleByModelCustomizationUuid(mcu);
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu);
- vf = vfmc != null ? vfmc.getVfModule() : null;
- if (vf == null) {
- LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu);
- }
- } else {
- LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
- }
- if (vf == null) {
- String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- LOGGER.debug("Got VF module definition from Catalog: " + vf.toString());
- if (vf.isBase()) {
- isBaseRequest = true;
- LOGGER.debug("This a BASE update request");
- } else {
- LOGGER.debug("This is *not* a BASE VF update request");
- if (!isVolumeRequest && nestedBaseStackId == null) {
- LOGGER.debug("This is unexpected - no nestedBaseStackId with this non-base request");
- }
- }
-
- //1607 - Add version check
- // First - see if it's in the VnfResource record
- // if we have a vf Module - then we have to query to get the VnfResource record.
- if (vf.getVnfResourceModelUUId() != null) {
- String vnfResourceModelUuid = vf.getVnfResourceModelUUId();
- //vnfResource = db.getVnfResourceById(vnfResourceId);
- vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
- if (vnfResource == null) {
- LOGGER
- .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
- }
- }
- String minVersionVnf = null;
- String maxVersionVnf = null;
- if (vnfResource != null) {
- try {
- minVersionVnf = vnfResource.getAicVersionMin();
- maxVersionVnf = vnfResource.getAicVersionMax();
- } catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
- minVersionVnf = null;
- maxVersionVnf = null;
- }
- if (minVersionVnf != null && "".equals(minVersionVnf)) {
- minVersionVnf = null;
- }
- if (maxVersionVnf != null && "".equals(maxVersionVnf)) {
- maxVersionVnf = null;
- }
- }
- if (minVersionVnf != null && maxVersionVnf != null) {
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- //String aicVersion = "";
- if (this.cloudConfig == null) {
- this.cloudConfig = this.cloudConfigFactory.getCloudConfig();
- }
- // double check
- if (this.cloudConfig != null) {
- Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId);
- if (cloudSiteOpt.isPresent()) {
- aicV.setVersion(cloudSiteOpt.get().getAic_version());
- if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min
- && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV
- .isMoreRecentThan(maxVersionVnf)))) { //aic <= max
- LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf
- + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId()
- + " with AIC_Version:" + cloudSiteOpt.get().getAic_version());
- } else {
- // ERROR
- String error =
- "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf
- + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get()
- .getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- } // let this error out downstream to avoid introducing uncertainty at this stage
- } else {
- LOGGER.debug("cloudConfig is NULL - cannot check cloud site version");
- }
-
- } else {
- LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked.");
- }
- // End Version check 1607
-
- String heatTemplateArtifactUuid = null;
- String heatEnvironmentArtifactUuid = null;
-
- HeatTemplate heatTemplate = null;
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
- }
- if (heatTemplateArtifactUuid == null) {
- String error =
- "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType="
- + requestTypeString;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
- }
-
- if (heatTemplate == null) {
- String error = "Update VNF: undefined Heat Template. VF="
- + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR,
- MsoAlarmLogger.CRITICAL, error);
-
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
-
- LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
-
- // Add check for any Environment variable
- HeatEnvironment heatEnvironment = null;
- String heatEnvironmentString = null;
-
- if (heatEnvironmentArtifactUuid != null) {
- LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":");
- heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
- if (heatEnvironment == null) {
-
- String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID",
- String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError,
- error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
- error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- } else {
- LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString());
- heatEnvironmentString = heatEnvironment
- .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ());
- LOGGER.debug("After parsing: " + heatEnvironmentString);
- }
- } else {
- LOGGER.debug("no environment parameter for this VFModuleType " + vfModuleType);
- }
-
- LOGGER.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId="
- + heatTemplate.getArtifactUuid());
- Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid());
- Map<String, Object> nestedTemplatesChecked = new HashMap<>();
- if (nestedTemplates != null) {
- // for debugging print them out
- LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:");
- for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) {
- String providerResourceFile = entry.getKey();
- Object value = entry.getValue();
- String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile);
- String childTemplateBody = (String) value;
- nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
- LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
- }
- } else {
- LOGGER.debug("No nested templates found - nothing to do here");
- nestedTemplatesChecked = null;
- }
-
- // Also add the files: for any get_files associated with this VfModule
- // *if* there are any
- LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
- + vf.getModelUUID());
-
- Map<String, HeatFiles> heatFiles = null;
-// Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ());
- Map<String, Object> heatFilesObjects = new HashMap<>();
-
- // Add ability to turn on adding get_files with volume requests (by property).
- boolean addGetFilesOnVolumeReq = false;
- try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
- .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null);
- if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) {
- addGetFilesOnVolumeReq = true;
- LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString);
- }
- } catch (Exception e) {
- LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ
- + " - default to false", e);
- }
- if (!isVolumeRequest || addGetFilesOnVolumeReq) {
- LOGGER.debug(
- "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
- + vf.getModelUUID());
-
- heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
- if (heatFiles != null) {
- // add these to stack - to be done in createStack
- // here, we will map them to Map<String, Object> from Map<String, HeatFiles>
- // this will match the nested templates format
- LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
-
- for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) {
- String heatFileName = entry.getKey();
- HeatFiles value = entry.getValue();
- if (heatFileName.startsWith("_ERROR|")) {
- // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found.
- String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1);
- String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType
- + " at HEAT_FILES index=" + heatFileId;
- LOGGER.debug(error);
- LOGGER
- .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId,
- vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- String heatFileBody = value.getFileBody();
- LOGGER.debug(heatFileName + " -> " + heatFileBody);
- heatFilesObjects.put(heatFileName, heatFileBody);
- }
- } else {
- LOGGER.debug("No heat files found -nothing to do here");
- heatFilesObjects = null;
- }
- }
-
- // Check that required parameters have been supplied
- StringBuilder missingParams = null;
- List<String> paramList = new ArrayList<>();
-
- // New for 1510 - consult the PARAM_ALIAS field to see if we've been
- // supplied an alias. Only check if we don't find it initially.
- // Also new in 1510 - don't flag missing parameters if there's an environment - because they might be there.
- // And also new - add parameter to turn off checking all together if we find we're blocking orders we
- // shouldn't
-// boolean haveEnvironmentParameters = false;
- boolean checkRequiredParameters = true;
- try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
- .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null);
- if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) {
- checkRequiredParameters = false;
- LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e);
- }
- // 1604 - Add enhanced environment & parameter checking
- // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep
- // Part 2: only submit to openstack the parameters in the envt that are in the heat template
- // Note this also removes any comments
- MsoHeatEnvironmentEntry mhee = null;
- if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) {
- LOGGER.debug("Enhanced environment checking enabled - 1604");
- StringBuilder sb = new StringBuilder(heatEnvironmentString);
- //LOGGER.debug("About to create MHEE with " + sb);
- mhee = new MsoHeatEnvironmentEntry(sb);
- StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired());
- }
- if (!mhee.isValid()) {
- sb2.append("Environment says it's not valid! " + mhee.getErrorString());
- } else {
- sb2.append("\nEnvironment:");
- sb2.append(mhee);
- }
- LOGGER.debug(sb2.toString());
- } else {
- LOGGER.debug("NO ENVIRONMENT for this entry");
- }
-
- // New for 1607 - support params of json type
- HashMap<String, JsonNode> jsonParams = new HashMap<>();
- boolean hasJson = false;
-
- for (HeatTemplateParam parm : heatTemplate.getParameters()) {
- LOGGER.debug("Parameter:'" + parm.getParamName()
- + "', isRequired="
- + parm.isRequired()
- + ", alias="
- + parm.getParamAlias());
- // handle json
- String parameterType = parm.getParamType();
- if (parameterType == null || "".equals(parameterType.trim())) {
- parameterType = "String";
- }
- JsonNode jsonNode = null;
- if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
- if (inputs.containsKey(parm.getParamName())) {
- hasJson = true;
- String jsonString = null;
- try {
- jsonString = inputs.get(parm.getParamName());
- jsonNode = new ObjectMapper().readTree(jsonString);
- } catch (JsonParseException jpe) {
- //TODO - what to do here?
- //for now - send the error to debug, but just leave it as a String
- String errorMessage = jpe.getMessage();
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe);
- hasJson = false;
- jsonNode = null;
- } catch (Exception e) {
- // or here?
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
- hasJson = false;
- jsonNode = null;
- }
- if (jsonNode != null) {
- jsonParams.put(parm.getParamName(), jsonNode);
- }
- } else if (inputs.containsKey(parm.getParamAlias())) {
- hasJson = true;
- String jsonString = null;
- try {
- jsonString = inputs.get(parm.getParamAlias());
- jsonNode = new ObjectMapper().readTree(jsonString);
- } catch (JsonParseException jpe) {
- //TODO - what to do here?
- //for now - send the error to debug, but just leave it as a String
- String errorMessage = jpe.getMessage();
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe);
- hasJson = false;
- jsonNode = null;
- } catch (Exception e) {
- // or here?
- LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
- hasJson = false;
- jsonNode = null;
- }
- if (jsonNode != null) {
- // Notice here - we add it to the jsonParams hashMap with the actual name -
- // then manipulate the inputs so when we check for aliases below - it will not
- // get flagged.
- jsonParams.put(parm.getParamName(), jsonNode);
- inputs.remove(parm.getParamAlias());
- inputs.put(parm.getParamName(), jsonString);
- }
- } //TODO add a check for the parameter in the env file
- }
-
- if (parm.isRequired() && (inputs == null || !inputs.containsKey(parm.getParamName()))) {
- if (inputs.containsKey(parm.getParamAlias())) {
- // They've submitted using an alias name. Remove that from inputs, and add back using real name.
- String realParamName = parm.getParamName();
- String alias = parm.getParamAlias();
- String value = inputs.get(alias);
- LOGGER.debug("*Found an Alias: paramName=" + realParamName
- + ",alias="
- + alias
- + ",value="
- + value);
- inputs.remove(alias);
- inputs.put(realParamName, value);
- LOGGER.debug(alias + " entry removed from inputs, added back using " + realParamName);
- }
- // enhanced - check if it's in the Environment (note: that method
- else if (mhee != null && mhee.containsParameter(parm.getParamName())) {
-
- LOGGER.debug("Required parameter " + parm.getParamName()
- + " appears to be in environment - do not count as missing");
- } else {
- LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
- if (missingParams == null) {
- missingParams = new StringBuilder(parm.getParamName());
- } else {
- missingParams.append("," + parm.getParamName());
- }
- }
- }
- paramList.add(parm.getParamName());
- }
- if (missingParams != null) {
- // Problem - missing one or more required parameters
- if (checkRequiredParameters) {
- String error = "Update VNF: Missing Required inputs: " + missingParams;
- LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "",
- MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
- error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
- }
- } else {
- LOGGER.debug("No missing parameters found - ok to proceed");
- }
-
- // Just submit the envt entry as received from the database
- String newEnvironmentString = null;
- if (mhee != null) {
- newEnvironmentString = mhee.getRawEntry().toString();
- }
-
- // Remove any extraneous parameters (don't throw an error)
- if (inputs != null) {
- List<String> extraParams = new ArrayList<>();
- extraParams.addAll(inputs.keySet());
- // This is not a valid parameter for this template
- extraParams.removeAll(paramList);
- if (!extraParams.isEmpty()) {
- LOGGER.warn(MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Extra params");
- inputs.keySet().removeAll(extraParams);
- }
- }
- // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json
- Map<String, Object> inputsTwo = null;
- if (hasJson && jsonParams.size() > 0) {
- inputsTwo = new HashMap<>();
- for (Map.Entry<String, String> entry : inputs.entrySet()) {
- String keyParamName = entry.getKey();
- String value = entry.getValue();
- if (jsonParams.containsKey(keyParamName)) {
- inputsTwo.put(keyParamName, jsonParams.get(keyParamName));
- } else {
- inputsTwo.put(keyParamName, value);
- }
- }
- }
-
- // "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate();
- template = template.replaceAll("\r\n", "\n");
-
- // Have the tenant. Now deploy the stack itself
- // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
- // because we already checked for those.
- long updateStackStarttime = System.currentTimeMillis();
- try {
- if (!hasJson) {
- heatStack = heatU.updateStack(cloudSiteId,
- tenantId,
- vfModuleName,
- template,
- copyStringInputs(inputs),
- true,
- heatTemplate.getTimeoutMinutes(),
- newEnvironmentString,
- //heatEnvironmentString,
- nestedTemplatesChecked,
- heatFilesObjects);
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack",
- "UpdateStack", null);
- } else {
- heatStack = heatU.updateStack(cloudSiteId,
- tenantId,
- vfModuleName,
- template,
- inputsTwo,
- true,
- heatTemplate.getTimeoutMinutes(),
- newEnvironmentString,
- //heatEnvironmentString,
- nestedTemplatesChecked,
- heatFilesObjects);
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
- MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack",
- "UpdateStack", null);
- }
- } catch (MsoException me) {
- me.addContext("UpdateVFModule");
- String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
- LOGGER.error(MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "",
- MsoLogger.ErrorCode.DataError, "Exception - " + error, me);
- LOGGER
- .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
- error);
- throw new VnfException(me);
- }
- }
- // Make sure DB session is closed
-
- // Reach this point if updateStack is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfId(heatStack.getCanonicalName());
- vfRollback.setVnfCreated(true);
-
- outputs.value = copyStringOutputs(heatStack.getOutputs());
- rollback.value = vfRollback;
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VF Module");
- }
-
- private String getVfModuleNameFromModuleStackId(String vfModuleStackId) {
- // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24"
- // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack
- if (vfModuleStackId == null)
- return null;
- int index = vfModuleStackId.lastIndexOf('/');
- if (index <= 0)
- return null;
- String vfModuleName = null;
- try {
- vfModuleName = vfModuleStackId.substring(0, index);
- } catch (Exception e) {
- LOGGER.debug("Exception", e);
- vfModuleName = null;
- }
- return vfModuleName;
- }
-
- private CatalogDatabase getCatalogDatabase(){
- return CatalogDatabase.getInstance();
- }
-
- private Map<String, Object> updateFlavorsFromOof(String heatEnvironmentString, Map<String, String> inputs) {
- Map<String, Object> returnMap = new HashMap<>();
- for (Map.Entry<String, String> input : inputs.entrySet()){
- if (heatEnvironmentString.contains("label_" + input.getKey())){
- heatEnvironmentString = heatEnvironmentString.replace("label_" + input.getKey(),
- input.getValue());
- inputs.remove("label_" + input.getKey());
- }
- }
- returnMap.put("heatEnvironmentString", heatEnvironmentString);
- returnMap.put("inputs", inputs);
- return returnMap;
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
deleted file mode 100644
index 43021d2bfb..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
+++ /dev/null
@@ -1,1254 +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.vnf;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.cloudify.beans.DeploymentInfo;
-import org.openecomp.mso.cloudify.beans.DeploymentStatus;
-import org.openecomp.mso.cloudify.exceptions.MsoCloudifyManagerNotFound;
-import org.openecomp.mso.cloudify.utils.MsoCloudifyUtils;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-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.MsoTenant;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry;
-import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentParameter;
-import org.openecomp.mso.openstack.utils.MsoKeystoneUtils;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
-public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
-
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
-
- MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
-
- private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
- private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
- private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter.";
- private static final String LOG_REPLY_NAME = "MSO-VnfAdapter:MSO-BPMN.";
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters";
- private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.openecomp.mso.adapters.vnf.addGetFilesOnVolumeReq";
- private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck () {
- LOGGER.debug ("Health check call in VNF Cloudify Adapter");
- }
-
- /**
- * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
- * @see MsoVnfCloudifyAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
- */
- public MsoVnfCloudifyAdapterImpl() {
-
- }
-
- /**
- * This constructor MUST be used if this class is called with the new operator.
- * @param msoPropFactory
- */
- public MsoVnfCloudifyAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) {
- this.msoPropertiesFactory = msoPropFactory;
- this.cloudConfigFactory = cloudConfigFact;
- }
-
- /**
- * This is the "Create VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void createVnf (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder <String> vnfId,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("CreateVNF command attempted but not supported");
- throw new VnfException ("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Update VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void updateVnf (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("UpdateVNF command attempted but not supported");
- throw new VnfException ("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- *
- * This really should be QueryVfModule, but nobody ever changed it.
- *
- * For Cloudify, this will look up a deployment by its deployment ID, which is really the same
- * as deployment name, since it assigned by the client when a deployment is created.
- * Also, the input cloudSiteId is used only to identify which Cloudify instance to query,
- * and the tenantId is ignored (since that really only applies for Openstack/Heat).
- *
- * The method returns an indicator that the VNF exists, along with its status and outputs.
- * The input "vnfName" will also be reflected back as its ID.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier - ignored for Cloudify
- * @param vnfName VNF Name (should match a deployment ID)
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF ID
- * @param outputs Holder for Map of VNF outputs from Cloudify deployment (assigned IPs, etc)
- */
- @Override
- public void queryVnf (String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest,
- Holder <Boolean> vnfExists,
- Holder <String> vnfId,
- Holder <VnfStatus> status,
- Holder <Map <String, String>> outputs)
- throws VnfException
- {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("QueryVnfCloudify");
- LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
- long subStartTime = System.currentTimeMillis ();
-
- MsoCloudifyUtils cloudifyUtils = new MsoCloudifyUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- DeploymentInfo deployment = null;
-
- try {
- deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName);
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Cloudify", "Cloudify", "QueryDeployment", vnfName);
- }
- catch (MsoCloudifyManagerNotFound e) {
- // This site does not have a Cloudify Manager.
- // This isn't an error, just means we won't find the VNF here.
- deployment = null;
- }
- catch (MsoException me) {
- // Failed to query the Deployment due to a cloudify exception.
- // Convert to a generic VnfException
- me.addContext ("QueryVNF");
- String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "QueryDeployment", vnfName);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "Cloudify", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
-
- if (deployment != null && deployment.getStatus() != DeploymentStatus.NOTFOUND) {
- vnfExists.value = Boolean.TRUE;
- status.value = deploymentStatusToVnfStatus(deployment);
- vnfId.value = deployment.getId();
- outputs.value = copyStringOutputs (deployment.getOutputs ());
-
- LOGGER.debug ("VNF " + vnfName + " found in Cloudify, ID = " + vnfId.value);
- }
- else {
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap <String, String> (); // Return as an empty map
-
- LOGGER.debug ("VNF " + vnfName + " not found");
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF");
- return;
- }
-
-
- /**
- * This is the "Delete VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void deleteVnf (String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest) throws VnfException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVnf");
-
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("DeleteVNF command attempted but not supported");
- throw new VnfException ("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * 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.
- *
- * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup,
- * but APIs were apparently never updated.
- */
- @Override
- public void rollbackVnf (VnfRollback rollback) throws VnfException {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("RollbackVnf");
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null");
- return;
- }
-
- // Don't rollback if nothing was done originally
- if (!rollback.getVnfCreated()) {
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Rollback VF Module - nothing to roll back");
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudSiteId ();
- String tenantId = rollback.getTenantId ();
- String vfModuleId = rollback.getVfModuleStackId ();
-
- MsoLogger.setLogContext (rollback.getMsoRequest());
-
- LOGGER.debug ("Rolling Back VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId);
-
- MsoCloudifyUtils cloudifyUtils = new MsoCloudifyUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- DeploymentInfo deployment = null;
-
- // Use the MsoCloudifyUtils to delete the deployment. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- long subStartTime = System.currentTimeMillis ();
- try {
- // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID.
- // Go directly to Keystone until APIs could be updated to supply the name.
- MsoKeystoneUtils keystone = new MsoKeystoneUtils(MSO_PROP_VNF_ADAPTER, cloudConfigFactory);
- MsoTenant msoTenant = keystone.queryTenant(tenantId, cloudSiteId);
- String tenantName = (msoTenant != null? msoTenant.getTenantName() : tenantId);
-
- // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object and use that.
- deployment = cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantName, vfModuleId, 5);
- LOGGER.debug("Rolled back deployment: " + deployment.getId());
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Cloudify", "Cloudify", "DeleteDeployment", null);
- } catch (MsoException me) {
- // Failed to rollback the VNF due to a cloudify exception.
- // Convert to a generic VnfException
- me.addContext ("RollbackVNF");
- String error = "Rollback VF Module: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "DeleteDeployment", null);
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "Cloudify", "DeleteDeployment", MsoLogger.ErrorCode.DataError, "Exception - DeleteDeployment", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VF Module");
- return;
- }
-
-
- private VnfStatus deploymentStatusToVnfStatus (DeploymentInfo deployment) {
- // Determine the status based on last action & status
- // DeploymentInfo object should be enhanced to report a better status internally.
- DeploymentStatus status = deployment.getStatus();
- String lastAction = deployment.getLastAction();
-
- if (status == null || lastAction == null) {
- return VnfStatus.UNKNOWN;
- }
- else if (status == DeploymentStatus.NOTFOUND) {
- return VnfStatus.NOTFOUND;
- }
- else if (status == DeploymentStatus.INSTALLED) {
- return VnfStatus.ACTIVE;
- }
- else if (status == DeploymentStatus.CREATED) {
- // Should have an INACTIVE status for this case. Shouldn't really happen, but
- // Install was never run, or Uninstall was done but deployment didn't get deleted.
- return VnfStatus.UNKNOWN;
- }
- else if (status == DeploymentStatus.FAILED) {
- return VnfStatus.FAILED;
- }
-
- return VnfStatus.UNKNOWN;
- }
-
- private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) {
- Map <String, String> stringOutputs = new HashMap <String, String> ();
- for (String key : stackOutputs.keySet ()) {
- if (stackOutputs.get (key) instanceof String) {
- stringOutputs.put (key, (String) stackOutputs.get (key));
- } else if (stackOutputs.get(key) instanceof Integer) {
- try {
- String str = "" + stackOutputs.get(key);
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs");
- }
- } else if (stackOutputs.get(key) instanceof JsonNode) {
- try {
- String str = this.convertNode((JsonNode) stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode");
- }
- } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
- try {
- String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap");
- }
- } else {
- try {
- String str = stackOutputs.get(key).toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage());
- }
- }
- }
- return stringOutputs;
- }
-
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- String outputString;
- try {
- outputString = inputs.get(str).toString();
- } catch (Exception e) {
- outputString = "Unable to call toString() on the value for " + str;
- }
- sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
- }
- }
- LOGGER.debug(sb.toString());
- return;
- }
-
- private void sendMapToDebug(Map<String, String> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
- }
- }
- LOGGER.debug(sb.toString());
- return;
- }
-
- private String convertNode(final JsonNode node) {
- try {
- final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
- } catch (JsonParseException jpe) {
- LOGGER.debug("Error converting json to string " + jpe.getMessage());
- } catch (Exception e) {
- LOGGER.debug("Error converting json to string " + e.getMessage());
- }
- return "[Error converting json to string]";
- }
-
- private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) {
- if (objectMap == null) {
- return null;
- }
- Map<String, String> stringMap = new HashMap<String, String>();
- for (String key : objectMap.keySet()) {
- if (!stringMap.containsKey(key)) {
- Object obj = objectMap.get(key);
- if (obj instanceof String) {
- stringMap.put(key, (String) objectMap.get(key));
- } else if (obj instanceof JsonNode ){
- // This is a bit of mess - but I think it's the least impacting
- // let's convert it BACK to a string - then it will get converted back later
- try {
- String str = this.convertNode((JsonNode) obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key);
- //okay in this instance - only string values (fqdn) are expected to be needed
- }
- } else if (obj instanceof java.util.LinkedHashMap) {
- LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode");
- try {
- String str = JSON_MAPPER.writeValueAsString(obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key);
- }
- } else {
- try {
- String str = obj.toString();
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")");
- }
- }
- }
- }
-
- return stringMap;
- }
-
- /**
- * This is the "Create VF Module" web service implementation.
- * It will instantiate a new VF Module of the requested type in the specified cloud
- * and tenant. The tenant must exist before this service is called.
- *
- * If a VF Module with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- *
- * All VF Modules are defined in the MSO catalog. The caller must request
- * one of the pre-defined module types or an error will be returned. Within the
- * catalog, each VF Module references (among other things) a cloud template
- * which is used to deploy the required artifacts (VMs, networks, etc.)
- * to the cloud. In this adapter implementation, that artifact is expected
- * to be a Cloudify blueprint.
- *
- * Depending on the blueprint, a variable set of input parameters will
- * be defined, some of which are required. The caller is responsible to
- * pass the necessary input data for the module or an error will be thrown.
- *
- * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback
- * object. This last object can be passed as-is to the rollbackVnf operation to
- * undo everything that was created for the Module. This is useful if a VF module
- * is successfully created but the orchestration fails on a subsequent step.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB.
- * Deprecated - should use modelCustomizationUuid
- * @param vnfVersion VNF version key, should match a VNF definition in catalog DB
- * Deprecated - VF Module versions also captured by modelCustomizationUuid
- * @param vfModuleName Name to be assigned to the new VF Module
- * @param requestType Indicates if this is a Volume Group or Module request
- * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group
- * to attach to a VF Module
- * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if
- * this is an Add-on module
- * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces
- * the use of vfModuleType.
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * @param backout Flag whether to suppress automatic backout (for testing)
- * @param msoRequest Request tracking information for logs
- * @param vnfId Holder for output VNF Cloudify Deployment ID
- * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc)
- * @param rollback Holder for returning VnfRollback object
- */
- public void createVfModule(String cloudSiteId,
- String tenantId,
- String vfModuleType,
- String vnfVersion,
- String vfModuleName,
- String requestType,
- String volumeGroupId,
- String baseVfModuleId,
- String modelCustomizationUuid,
- Map <String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder <String> vnfId,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("CreateVfModule");
-
- // Require a model customization ID. Every VF Module definition must have one.
- if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
- LOGGER.debug("Missing required input: modelCustomizationUuid");
- String error = "Create vfModule error: Missing required input: modelCustomizationUuid";
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module ModelCustomizationUuid", "null", "Cloudify", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Missing required input: modelCustomizationUuid");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Clean up some inputs to make comparisons easier
- if (requestType == null)
- requestType = "";
-
- if ("".equals(volumeGroupId) || "null".equals(volumeGroupId))
- volumeGroupId = null;
-
- if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId))
- baseVfModuleId = null;
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<String,String>();
- LOGGER.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
-
- // Check if this is for a "Volume" module
- boolean isVolumeRequest = false;
- if (requestType.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
-
- LOGGER.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + baseVfModuleId);
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestType);
- vfRollback.setIsBase(false); // Until we know better
- vfRollback.setVolumeGroupHeatStackId(volumeGroupId);
- vfRollback.setBaseGroupHeatStackId(baseVfModuleId);
- vfRollback.setModelCustomizationUuid(modelCustomizationUuid);
- vfRollback.setMode("CFY");
-
- rollback.value = vfRollback; // Default rollback - no updates performed
-
- // Get the VNF/VF Module definition from the Catalog DB first.
- // There are three relevant records: VfModule, VfModuleCustomization, VnfResource
-
- CatalogDatabase db = CatalogDatabase.getInstance();
- VfModule vf = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfmc = null;
-
- try {
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(modelCustomizationUuid);
-
- if (vfmc == null) {
- String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + modelCustomizationUuid;
- LOGGER.debug(error);
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found vfModuleCust entry " + vfmc.toString());
- }
-
- // Get the vfModule and vnfResource records
- vf = vfmc.getVfModule();
- vnfResource = db.getVnfResourceByModelUuid(vf.getVnfResourceModelUUId());
- }
- catch (Exception e) {
- db.close ();
- LOGGER.debug("unhandled exception in create VF - [Query]" + e.getMessage());
- throw new VnfException("Exception during create VF " + e.getMessage());
- }
-
- // Perform a version check against cloudSite
- // Obtain the cloud site information where we will create the VF Module
- Optional<CloudSite> cloudSite = cloudConfigFactory.getCloudConfig().getCloudSite(cloudSiteId);
- if (!cloudSite.isPresent()) {
- throw new VnfException (new MsoCloudSiteNotFound (cloudSiteId));
- }
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.get().getAic_version());
-
- String vnfMin = vnfResource.getAicVersionMin();
- String vnfMax = vnfResource.getAicVersionMax();
-
- if ( (vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) ||
- (vnfMax != null && aicV.isMoreRecentThan(vnfMax)))
- {
- // ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSite.get().getId() + " with AIC_Version:" + cloudSite.get().getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- // End Version check
-
-
- // Get Utilities for Cloudify.
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- DeploymentInfo cloudifyDeployment = null;
-
- // First, look up to see if the VF already exists.
-
- long subStartTime1 = System.currentTimeMillis ();
- try {
- cloudifyDeployment = cloudify.queryDeployment (cloudSiteId, tenantId, vfModuleName);
- LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Cloudify", "Cloudify", "QueryDeployment", vfModuleName);
- }
- catch (MsoException me) {
- // Failed to query the Deployment due to a cloudify exception.
- String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment", me);
- LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "QueryDeployment", vfModuleName);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule");
- throw new VnfException (me);
- }
-
- // More precise handling/messaging if the Module already exists
- if (cloudifyDeployment != null && !(cloudifyDeployment.getStatus () == DeploymentStatus.NOTFOUND)) {
- // CREATED, INSTALLED, INSTALLING, FAILED, UNINSTALLING, UNKNOWN
- DeploymentStatus status = cloudifyDeployment.getStatus();
- LOGGER.debug ("Found Existing Deployment, status=" + status);
-
- if (status == DeploymentStatus.INSTALLED) {
- // fail - it exists
- if (failIfExists != null && failIfExists) {
- String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId());
- } else {
- // Found existing deployment and client has not requested "failIfExists".
- // Populate the outputs from the existing deployment.
-
- vnfId.value = cloudifyDeployment.getId();
- outputs.value = copyStringOutputs (cloudifyDeployment.getOutputs ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module (found existing)");
- return;
- }
- }
- // Check through various detailed error cases
- if (status == DeploymentStatus.INSTALLING || status == DeploymentStatus.UNINSTALLING) {
- // fail - it's in progress - return meaningful error
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId());
- }
- else if (status == DeploymentStatus.FAILED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in FAILED state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId());
- }
- else if (status == DeploymentStatus.UNKNOWN || status == DeploymentStatus.CREATED) {
- // fail - it exists and is in a UNKNOWN state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in " + status.toString() + " state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId());
- }
- else {
- // Unexpected, since all known status values have been tested for
- String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "Cloudify", "queryDeployment", MsoLogger.ErrorCode.DataError, "Deployment " + vfModuleName + " already exists and is in an unknown state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, cloudifyDeployment.getId());
- }
- }
-
-
- // Collect outputs from Base Modules and Volume Modules
- Map<String, Object> baseModuleOutputs = null;
- Map<String, Object> volumeGroupOutputs = null;
-
- // If a Volume Group was provided, query its outputs for inclusion in Module input parameters
- if (volumeGroupId != null) {
- long subStartTime2 = System.currentTimeMillis ();
- DeploymentInfo volumeDeployment = null;
- try {
- volumeDeployment = cloudify.queryDeployment (cloudSiteId, tenantId, volumeGroupId);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from Cloudify", "Cloudify", "QueryDeployment", volumeGroupId);
- }
- catch (MsoException me) {
- // Failed to query the Volume GroupDeployment due to a cloudify exception.
- String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, "Cloudify", "queryDeployment(volume)", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment(volume)", me);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "QueryDeployment(volume)", volumeGroupId);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule(QueryVolume)");
- throw new VnfException (me);
- }
-
- if (volumeDeployment == null || volumeDeployment.getStatus() == DeploymentStatus.NOTFOUND) {
- String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, error, "Cloudify", "queryDeployment(volume)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached Volume Group DOES NOT EXIST");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested volume group");
- volumeGroupOutputs = volumeDeployment.getOutputs();
- this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs");
- }
- }
-
- // If this is an Add-On Module, query the Base Module outputs
- // Note: This will be performed whether or not the current request is for an
- // Add-On Volume Group or Add-On VF Module
-
- if (vf.isBase()) {
- LOGGER.debug("This is a BASE Module request");
- vfRollback.setIsBase(true);
- } else {
- LOGGER.debug("This is an Add-On Module request");
-
- // Add-On Modules should always have a Base, but just treat as a warning if not provided.
- // Add-on Volume requests may or may not specify a base.
- if (!isVolumeRequest && baseVfModuleId == null) {
- LOGGER.debug ("WARNING: Add-on Module request - no Base Module ID provided");
- }
-
- if (baseVfModuleId != null) {
- long subStartTime2 = System.currentTimeMillis ();
- DeploymentInfo baseDeployment = null;
- try {
- baseDeployment = cloudify.queryDeployment (cloudSiteId, tenantId, baseVfModuleId);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from Cloudify", "Cloudify", "QueryDeployment(Base)", baseVfModuleId);
- }
- catch (MsoException me) {
- // Failed to query the Volume GroupDeployment due to a cloudify exception.
- String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, "Cloudify", "queryDeployment(Base)", MsoLogger.ErrorCode.DataError, "Exception - queryDeployment(Base)", me);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "QueryDeployment(Base)", baseVfModuleId);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule(QueryBase)");
- throw new VnfException (me);
- }
-
- if (baseDeployment == null || baseDeployment.getStatus() == DeploymentStatus.NOTFOUND) {
- String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, error, "Cloudify", "queryDeployment(Base)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Base Module DOES NOT EXIST");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found base module");
- baseModuleOutputs = baseDeployment.getOutputs();
- this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs");
- }
- }
- }
-
-
- // Ready to deploy the new VNF
-
- // NOTE: For this section, heatTemplate is used for both HEAT templates and Cloudify blueprints.
- // In final implementation (post-POC), the template object would either be generic or there would
- // be a separate DB Table/Object for Blueprints.
-
- try {
- // NOTE: The template is fixed for the VF Module. The environment is part of the customization.
- String heatTemplateArtifactUuid = null;
- String heatEnvironmentArtifactUuid = null;
-
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid();
- }
-
- if (heatTemplateArtifactUuid == null || heatTemplateArtifactUuid.equals("")) {
- String error = "Create: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestType;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "Cloudify", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
-
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
-
- if (heatTemplate == null) {
- String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "Cloudify", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug("Got HEAT Template record from DB");
-
- // Next get the Environment record. This is optional.
- HeatEnvironment heatEnvironment = null;
- if (heatEnvironmentArtifactUuid != null && !heatEnvironmentArtifactUuid.equals(""))
- {
- heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
- if (heatEnvironment == null) {
- String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "Cloudify", "getEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug ("Got Heat Environment from DB");
- } else {
- LOGGER.debug ("no environment parameter found for this Type " + vfModuleType);
- }
-
-
- // NOTE: Logic to support nested templates and "get_file" attachments was removed from
- // Cloudify-based adapter. Assumption is that the actual blueprints and associated
- // artifacts have been pre-loaded to Cloudify. If that changes, logic will need
- // to be added in to dynamically build and deploy the blueprint (with all associated
- // artifacts required for the CSAR/ZIP) before starting the actual orchestration.
-
-
- // All variables converted to their native object types
- HashMap<String, Object> goldenInputs = new HashMap<String,Object>();
- List<String> extraInputs = new ArrayList<String>();
-
- // NOTE: SKIP THIS FOR CLOUDIFY for now. Just use what was passed in.
- // This whole section needs to be rewritten.
- Boolean skipInputChecks = false;
-
- if (skipInputChecks) {
- goldenInputs = new HashMap<String,Object>();
- for (String key : inputs.keySet()) {
- goldenInputs.put(key, inputs.get(key));
- }
- }
- else {
- // Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>();
-
- Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
- LOGGER.debug("paramSet has " + paramSet.size() + " entries");
-
- for (HeatTemplateParam htp : paramSet) {
- params.put(htp.getParamName(), htp);
-
- // Include aliases.
- String alias = htp.getParamAlias();
- if (alias != null && !alias.equals("") && !params.containsKey(alias)) {
- params.put(alias, htp);
- }
- }
-
- // First, convert all inputs to their "template" type
- for (String key : inputs.keySet()) {
- if (params.containsKey(key)) {
- Object value = cloudify.convertInputValue(inputs.get(key), params.get(key));
- if (value != null) {
- goldenInputs.put(key, value);
- }
- else {
- LOGGER.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key).getParamType());
- }
- } else {
- extraInputs.add(key);
- }
- }
-
- if (!extraInputs.isEmpty()) {
- LOGGER.debug("Ignoring extra inputs: " + extraInputs);
- }
-
- // Next add in Volume Group Outputs if there are any. Copy directly without conversions.
- if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) {
- for (String key : volumeGroupOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, volumeGroupOutputs.get(key));
- }
- }
- }
-
- // Next add in Base Module Outputs if there are any. Copy directly without conversions.
- if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) {
- for (String key : baseModuleOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, baseModuleOutputs.get(key));
- }
- }
- }
-
- // Last, add in values from the "environment" file.
- // These are added to the inputs, since Cloudify doesn't pass an environment file like Heat.
- if (heatEnvironment != null)
- {
- // TODO: This may take a different form for Cloudify, but for now process it
- // with Heat environment file syntax
- StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment());
- MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry (sb);
-
- if (mhee.getParameters() != null) {
- for (MsoHeatEnvironmentParameter envParam : mhee.getParameters()) {
- // If this is a template input, copy to golden inputs
- String envKey = envParam.getName();
- if (params.containsKey(envKey) && !goldenInputs.containsKey(envKey)) {
- Object value = cloudify.convertInputValue(envParam.getValue(), params.get(envKey));
- if (value != null) {
- goldenInputs.put(envKey, value);
- }
- else {
- LOGGER.debug("Failed to convert environment parameter " + envKey + "='" + envParam.getValue() + "' to " + params.get(envKey).getParamType());
- }
- }
- }
- }
- }
- else {
- LOGGER.debug("NO ENVIRONMENT for this entry");
- }
-
- this.sendMapToDebug(goldenInputs, "Final inputs sent to Cloudify");
-
-
- // Check that required parameters have been supplied from any of the sources
- String missingParams = null;
- boolean checkRequiredParameters = true;
- try {
- String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER)
- .getProperty (MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS,null);
- if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
- checkRequiredParameters = false;
- LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- LOGGER.debug ("An exception occured trying to get property " + MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e);
- }
-
-
- for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
- if (parm.isRequired () && (!goldenInputs.containsKey (parm.getParamName ()))) {
- LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
- if (missingParams == null) {
- missingParams = parm.getParamName ();
- } else {
- missingParams += "," + parm.getParamName ();
- }
- }
- }
-
- if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "Cloudify", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug ("found missing parameters [" + missingParams + "] - but checkRequiredParameters is false - will not block");
- }
- } else {
- LOGGER.debug ("No missing parameters found - ok to proceed");
- }
-
- } // NOTE: END PARAMETER CHECKING
-
- // Ready to deploy the VF Module.
- // First step - make sure the blueprint is loaded into Cloudify.
-
- String blueprintName = heatTemplate.getTemplateName();
- String blueprint = heatTemplate.getTemplateBody();
-
- // Use the main blueprint name as the blueprint ID (strip yaml extensions).
- String blueprintId = blueprintName;
- if (blueprintId.endsWith(".yaml"))
- blueprintId = blueprintId.substring(0,blueprintId.lastIndexOf(".yaml"));
-
- try {
- if (! cloudify.isBlueprintLoaded (cloudSiteId, blueprintId)) {
- LOGGER.debug ("Blueprint " + blueprintId + " is not loaded. Will upload it now.");
-
- Map<String,byte[]> blueprintFiles = new HashMap<String,byte[]>();
-
- blueprintFiles.put(blueprintName, blueprint.getBytes());
-
- // TODO: Implement nested blueprint logic based on Cloudify structures.
- // For now, just use the Heat structures.
- // The query returns a map of String->Object, where the map keys provide one layer of
- // indirection from the Heat template names. For this case, assume the map key matches
- // the nested blueprint name.
- Map <String, Object> nestedBlueprints = db.getNestedTemplates (heatTemplate.getArtifactUuid());
- if (nestedBlueprints != null) {
- for (String nestedBlueprintName: nestedBlueprints.keySet()) {
- String nestedBlueprint = (String) nestedBlueprints.get(nestedBlueprintName);
- blueprintFiles.put(nestedBlueprintName, nestedBlueprint.getBytes());
- }
- }
-
- // TODO: Implement file artifact logic based on Cloudify structures.
- // For now, just use the Heat structures.
- Map<String, HeatFiles> heatFiles = db.getHeatFilesForVfModule (vf.getModelUUID());
- if (heatFiles != null) {
- for (String heatFileName: heatFiles.keySet()) {
- String heatFile = heatFiles.get(heatFileName).getFileBody();
- blueprintFiles.put(heatFileName, heatFile.getBytes());
- }
- }
-
- // Upload the blueprint package
- cloudify.uploadBlueprint(cloudSiteId, blueprintId, blueprintName, blueprintFiles, false);
-
- }
- }
- catch (MsoException me) {
- me.addContext ("CreateVFModule");
- String error = "Create VF Module: Upload blueprint failed. Blueprint=" + blueprintName + ": " + me;
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "Cloudify", "", MsoLogger.ErrorCode.DataError, "MsoException - uploadBlueprint", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
-
- }
-
- // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions
- // because we already checked for those.
- long createDeploymentStarttime = System.currentTimeMillis ();
- try {
- // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID.
- // Go directly to Keystone until APIs could be updated to supply the name.
- MsoKeystoneUtils keystone = new MsoKeystoneUtils(MSO_PROP_VNF_ADAPTER, cloudConfigFactory);
- MsoTenant msoTenant = keystone.queryTenant(tenantId, cloudSiteId);
- String tenantName = (msoTenant != null? msoTenant.getTenantName() : tenantId);
-
- if (backout == null) {
- backout = true;
- }
- cloudifyDeployment = cloudify.createAndInstallDeployment (cloudSiteId,
- tenantName,
- vfModuleName,
- blueprintId,
- goldenInputs,
- true,
- heatTemplate.getTimeoutMinutes (),
- backout.booleanValue());
-
- LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Cloudify", "Cloudify", "CreateDeployment", vfModuleName);
- } catch (MsoException me) {
- me.addContext ("CreateVFModule");
- String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "CreateDeployment", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "Cloudify", "", MsoLogger.ErrorCode.DataError, "MsoException - createDeployment", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- } catch (NullPointerException npe) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe;
- LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "CreateDeployment", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "Cloudify", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createDeployment", npe);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- LOGGER.debug("NULL POINTER EXCEPTION at cloudify.createAndInstallDeployment");
- //npe.addContext ("CreateVNF");
- throw new VnfException ("NullPointerException during cloudify.createAndInstallDeployment");
- } catch (Exception e) {
- LOGGER.recordMetricEvent (createDeploymentStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating deployment with Cloudify", "Cloudify", "CreateDeployment", vfModuleName);
- LOGGER.debug("unhandled exception at cloudify.createAndInstallDeployment");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating deployment with Cloudify");
- throw new VnfException("Exception during cloudify.createAndInstallDeployment! " + e.getMessage());
- }
- } catch (Exception e) {
- LOGGER.debug("unhandled exception in create VF");
- throw new VnfException("Exception during create VF " + e.getMessage());
-
- } finally {
- // Make sure DB session is closed
- db.close ();
- }
-
- // Reach this point if create is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfCreated (true);
- vfRollback.setVnfId (cloudifyDeployment.getId());
- vnfId.value = cloudifyDeployment.getId();
- outputs.value = copyStringOutputs (cloudifyDeployment.getOutputs ());
-
- rollback.value = vfRollback;
-
- LOGGER.debug ("VF Module " + vfModuleName + " successfully created");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- return;
- }
-
- public void deleteVfModule (String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs) throws VnfException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVf");
- LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- MsoCloudifyUtils cloudify = new MsoCloudifyUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
-
- // 1702 capture the output parameters on a delete
- // so we'll need to query first
- DeploymentInfo deployment = null;
- try {
- deployment = cloudify.queryDeployment(cloudSiteId, tenantId, vnfName);
- } catch (MsoException me) {
- // Failed to query the deployment. Convert to a generic VnfException
- me.addContext ("DeleteVFModule");
- String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "Cloudify", "QueryDeployment", null);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "Cloudify", "QueryDeployment", MsoLogger.ErrorCode.DataError, "Exception - QueryDeployment", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
- // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types
- outputs.value = convertMapStringObjectToStringString(deployment.getOutputs());
-
- // Use the MsoHeatUtils to delete the stack. Set the polling flag to true.
- // The possible outcomes of deleteStack are a StackInfo object with status
- // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException
- // could be thrown.
- long subStartTime = System.currentTimeMillis ();
- try {
- cloudify.uninstallAndDeleteDeployment(cloudSiteId, tenantId, vnfName, 5);
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from DeleteDeployment", "Cloudify", "DeleteDeployment", vnfName);
- } catch (MsoException me) {
- me.addContext ("DeleteVfModule");
- // Convert to a generic VnfException
- String error = "Delete VF: " + vnfName + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "DeleteDeployment", "DeleteDeployment", vnfName);
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "DeleteDeployment", "DeleteDeployment", MsoLogger.ErrorCode.DataError, "Exception - DeleteDeployment: " + me.getMessage());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
-
- // On success, nothing is returned.
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF");
- return;
- }
-
- // TODO: Should Update be supported for Cloudify? What would this look like?
- @Override
- public void updateVfModule (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- String baseVfHeatStackId,
- String vfModuleStackId,
- String modelCustomizationUuid,
- Map <String, String> inputs,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback) throws VnfException
- {
- // This operation is not currently supported for Cloudify-orchestrated VF Modules.
- LOGGER.debug ("Update VF Module command attempted but not supported");
- throw new VnfException ("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java
deleted file mode 100644
index a6d0a00c42..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ /dev/null
@@ -1,1243 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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=========================================================
- */
-
-/**
- * This VNF Adapter implementation is based on the VDU Plugin model. It assumes that each
- * VF Module definition in the MSO catalog is expressed via a set of template and/or file
- * artifacts that are appropriate for some specific sub-orchestrator that provides an
- * implementation of the VduPlugin interface. This adapter handles all of the common
- * VF Module logic, including:
- * - catalog lookups for artifact retrieval
- * - parameter filtering and validation
- * - base and volume module queries
- * - rollback logic
- * - logging and error handling
- *
- * Then based on the orchestration mode of the VNF, it will invoke different VDU plug-ins
- * to perform the low level instantiations, deletions, and queries. At this time, the
- * set of available plug-ins is hard-coded, though in the future a dynamic selection
- * is expected (e.g. via a service-provider interface).
- */
-package org.openecomp.mso.adapters.vnf;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.vdu.CloudInfo;
-import org.openecomp.mso.adapters.vdu.VduException;
-import org.openecomp.mso.adapters.vdu.VduInstance;
-import org.openecomp.mso.adapters.vdu.VduModelInfo;
-import org.openecomp.mso.adapters.vdu.VduPlugin;
-import org.openecomp.mso.adapters.vdu.VduStateType;
-import org.openecomp.mso.adapters.vdu.VduStatus;
-import org.openecomp.mso.adapters.vdu.mapper.VfModuleCustomizationToVduMapper;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.cloudify.utils.MsoCloudifyUtils;
-import org.openecomp.mso.aria.AriaVduPlugin;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-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.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf")
-public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
-
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- protected MsoHeatUtils heatUtils;
- protected VfModuleCustomizationToVduMapper vduMapper;
- protected MsoCloudifyUtils cloudifyUtils;
- protected AriaVduPlugin ariaVduPlugin;
-
- MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
-
- private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER";
- private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError";
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private static final String CHECK_REQD_PARAMS = "org.openecomp.mso.adapters.vnf.checkRequiredParameters";
- private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck () {
- LOGGER.debug ("Health check call in VNF Plugin Adapter");
- }
-
- /**
- * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL.
- * @see MsoVnfPluginAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory)
- */
- public MsoVnfPluginAdapterImpl() {
-
- }
-
- /**
- * This constructor MUST be used if this class is called with the new operator.
- * @param msoPropFactory
- */
- public MsoVnfPluginAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) {
- this.msoPropertiesFactory = msoPropFactory;
- this.cloudConfigFactory = cloudConfigFact;
- heatUtils = new MsoHeatUtils(MSO_PROP_VNF_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
- vduMapper = new VfModuleCustomizationToVduMapper();
- cloudifyUtils = new MsoCloudifyUtils (MSO_PROP_VNF_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- ariaVduPlugin = new AriaVduPlugin("localhost", 5000);
- }
-
- /**
- * This is the "Create VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void createVnf (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder <String> vnfId,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("CreateVNF command attempted but not supported");
- throw new VnfException ("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Update VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void updateVnf (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- Map <String, String> inputs,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("UpdateVNF command attempted but not supported");
- throw new VnfException ("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * This is the "Query VNF" web service implementation.
- *
- * This really should be QueryVfModule, but nobody ever changed it.
- *
- * The method returns an indicator that the VNF exists, along with its status and outputs.
- * The input "vnfName" will also be reflected back as its ID.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to query
- * @param tenantId Openstack tenant identifier
- * @param vnfNameOrId VNF Name or ID to query
- * @param msoRequest Request tracking information for logs
- * @param vnfExists Flag reporting the result of the query
- * @param vnfId Holder for output VNF ID
- * @param outputs Holder for Map of outputs from the deployed VF Module (assigned IPs, etc)
- */
- @Override
- public void queryVnf (String cloudSiteId,
- String tenantId,
- String vnfNameOrId,
- MsoRequest msoRequest,
- Holder <Boolean> vnfExists,
- Holder <String> vnfId,
- Holder <VnfStatus> status,
- Holder <Map <String, String>> outputs)
- throws VnfException
- {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("QueryVnf");
- LOGGER.debug ("Querying VNF " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
- long subStartTime = System.currentTimeMillis ();
-
- VduInstance vduInstance = null;
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, tenantId, null);
-
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId);
-
- try {
- vduInstance = vduPlugin.queryVdu(cloudInfo, vnfNameOrId);
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received VDU Query response", "VDU", "QueryVDU", vnfNameOrId);
- }
- catch (VduException e) {
- // Failed to query the VDU due to a plugin exception.
- e.addContext ("QueryVNF");
- String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudSiteId + "/" + tenantId + ": " + e;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVNF", vnfNameOrId);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfNameOrId, cloudSiteId, tenantId, "VDU", "QueryVNF", MsoLogger.ErrorCode.DataError, "Exception - queryVDU", e);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (e);
- }
-
- if (vduInstance != null && vduInstance.getStatus().getState() != VduStateType.NOTFOUND) {
- vnfExists.value = Boolean.TRUE;
- status.value = vduStatusToVnfStatus(vduInstance);
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs (vduInstance.getOutputs ());
-
- LOGGER.debug ("VNF " + vnfNameOrId + " found, ID = " + vnfId.value);
- }
- else {
- vnfExists.value = Boolean.FALSE;
- status.value = VnfStatus.NOTFOUND;
- vnfId.value = null;
- outputs.value = new HashMap <String, String> (); // Return as an empty map
-
- LOGGER.debug ("VNF " + vnfNameOrId + " not found");
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF");
- return;
- }
-
-
- /**
- * This is the "Delete VNF" web service implementation.
- * This function is now unsupported and will return an error.
- *
- */
- @Override
- public void deleteVnf (String cloudSiteId,
- String tenantId,
- String vnfName,
- MsoRequest msoRequest) throws VnfException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVnf");
-
- // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules.
- LOGGER.debug ("DeleteVNF command attempted but not supported");
- throw new VnfException ("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /**
- * 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.
- *
- * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup,
- * but APIs were apparently never updated.
- */
- @Override
- public void rollbackVnf (VnfRollback rollback) throws VnfException {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("RollbackVnf");
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null");
- return;
- }
-
- // Don't rollback if nothing was done originally
- if (!rollback.getVnfCreated()) {
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Rollback VF Module - nothing to roll back");
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudSiteId ();
- String tenantId = rollback.getTenantId ();
- CloudInfo cloudInfo = new CloudInfo (cloudSiteId, tenantId, null);
-
- String vfModuleId = rollback.getVfModuleStackId ();
-
- MsoLogger.setLogContext (rollback.getMsoRequest());
-
- LOGGER.debug ("Rolling Back VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId);
-
- VduInstance vduInstance = null;
-
- // Use the VduPlugin to delete the VF Module.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId);
-
- long subStartTime = System.currentTimeMillis ();
- try {
- // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object and use that.
- vduInstance = vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
-
- LOGGER.debug("Rolled back VDU instantiation: " + vduInstance.getVduInstanceId());
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VDU Plugin", "VDU", "DeleteVdu", null);
- }
- catch (VduException ve) {
- // Failed to rollback the VF Module due to a plugin exception.
- // Convert to a generic VnfException
- ve.addContext ("RollbackVFModule");
- String error = "Rollback VF Module: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + ve;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "DeleteVdu", null);
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError, "Exception - DeleteVdu", ve);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (ve);
- }
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VF Module");
- return;
- }
-
-
- private VnfStatus vduStatusToVnfStatus (VduInstance vdu) {
- // Determine the status based on last action & status
- // DeploymentInfo object should be enhanced to report a better status internally.
- VduStatus vduStatus = vdu.getStatus();
- VduStateType status = vduStatus.getState();
-
- if (status == null) {
- return VnfStatus.UNKNOWN;
- }
- else if (status == VduStateType.NOTFOUND) {
- return VnfStatus.NOTFOUND;
- }
- else if (status == VduStateType.INSTANTIATED) {
- return VnfStatus.ACTIVE;
- }
- else if (status == VduStateType.FAILED) {
- return VnfStatus.FAILED;
- }
-
- return VnfStatus.UNKNOWN;
- }
-
- /*
- * Normalize an input value to an Object, based on the target parameter type.
- * If the type is not recognized, it will just be returned unchanged (as a string).
- */
- private Object convertInputValue (String inputValue, HeatTemplateParam templateParam)
- {
- String type = templateParam.getParamType();
- LOGGER.debug("Parameter: " + templateParam.getParamName() + " is of type " + type);
-
- if (type.equalsIgnoreCase("number")) {
- try {
- return Integer.valueOf(inputValue);
- }
- catch (Exception e) {
- LOGGER.debug("Unable to convert " + inputValue + " to an integer!" , e);
- return null;
- }
- } else if (type.equalsIgnoreCase("json")) {
- try {
- JsonNode jsonNode = new ObjectMapper().readTree(inputValue);
- return jsonNode;
- }
- catch (Exception e) {
- LOGGER.debug("Unable to convert " + inputValue + " to a JsonNode!", e);
- return null;
- }
- } else if (type.equalsIgnoreCase("boolean")) {
- return new Boolean(inputValue);
- }
-
- // Nothing else matched. Return the original string
- return inputValue;
- }
-
- private Map <String, String> copyStringOutputs (Map <String, Object> stackOutputs) {
- Map <String, String> stringOutputs = new HashMap <> ();
- for (String key : stackOutputs.keySet ()) {
- if (stackOutputs.get (key) instanceof String) {
- stringOutputs.put (key, (String) stackOutputs.get (key));
- } else if (stackOutputs.get(key) instanceof Integer) {
- try {
- String str = "" + stackOutputs.get(key);
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs", e);
- }
- } else if (stackOutputs.get(key) instanceof JsonNode) {
- try {
- String str = this.convertNode((JsonNode) stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode", e);
- }
- } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) {
- try {
- String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key));
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap", e);
- }
- } else {
- try {
- String str = stackOutputs.get(key).toString();
- stringOutputs.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), e);
- }
- }
- }
- return stringOutputs;
- }
-
-
- private void sendMapToDebug(Map<String, Object> inputs, String optionalName) {
- int i = 0;
- StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName);
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- String outputString;
- try {
- outputString = inputs.get(str).toString();
- } catch (Exception e) {
- outputString = "Unable to call toString() on the value for " + str;
- }
- sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
- }
- }
- LOGGER.debug(sb.toString());
- return;
- }
-
- private void sendMapToDebug(Map<String, String> inputs) {
- int i = 0;
- StringBuilder sb = new StringBuilder("inputs:");
- if (inputs == null) {
- sb.append("\tNULL");
- }
- else if (inputs.size() < 1) {
- sb.append("\tEMPTY");
- } else {
- for (String str : inputs.keySet()) {
- sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
- }
- }
- LOGGER.debug(sb.toString());
- return;
- }
-
- private String convertNode(final JsonNode node) {
- try {
- final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
- } catch (JsonParseException jpe) {
- LOGGER.debug("Error converting json to string " + jpe.getMessage());
- } catch (Exception e) {
- LOGGER.debug("Error converting json to string " + e.getMessage());
- }
- return "[Error converting json to string]";
- }
-
- private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) {
- if (objectMap == null) {
- return null;
- }
- Map<String, String> stringMap = new HashMap<>();
- for (String key : objectMap.keySet()) {
- if (!stringMap.containsKey(key)) {
- Object obj = objectMap.get(key);
- if (obj instanceof String) {
- stringMap.put(key, (String) objectMap.get(key));
- } else if (obj instanceof JsonNode ){
- // This is a bit of mess - but I think it's the least impacting
- // let's convert it BACK to a string - then it will get converted back later
- try {
- String str = this.convertNode((JsonNode) obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key, e);
- //okay in this instance - only string values (fqdn) are expected to be needed
- }
- } else if (obj instanceof java.util.LinkedHashMap) {
- LOGGER.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode");
- try {
- String str = JSON_MAPPER.writeValueAsString(obj);
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key, e);
- }
- } else if (obj instanceof Integer) {
- try {
- String str = "" + obj;
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key, e);
- }
- } else {
- try {
- String str = obj.toString();
- stringMap.put(key, str);
- } catch (Exception e) {
- LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")", e);
- }
- }
- }
- }
-
- return stringMap;
- }
-
- /**
- * This is the "Create VF Module" web service implementation.
- * It will instantiate a new VF Module of the requested type in the specified cloud
- * and tenant. The tenant must exist before this service is called.
- *
- * If a VF Module with the same name already exists, this can be considered a
- * success or failure, depending on the value of the 'failIfExists' parameter.
- *
- * All VF Modules are defined in the MSO catalog. The caller must request one of
- * the pre-defined module types or an error will be returned. Within the catalog,
- * each VF Module references (among other things) a collection of artifacts that
- * are used to deploy the required cloud resources (VMs, networks, etc.).
- *
- * Depending on the module templates, a variable set of input parameters will
- * be defined, some of which are required. The caller is responsible to
- * pass the necessary input data for the module or an error will be thrown.
- *
- * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback
- * object. This last object can be passed as-is to the rollbackVnf operation to
- * undo everything that was created for the Module. This is useful if a VF module
- * is successfully created but the orchestration fails on a subsequent step.
- *
- * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
- * @param tenantId Openstack tenant identifier
- * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB.
- * Deprecated - should use modelCustomizationUuid
- * @param vnfVersion VNF version key, should match a VNF definition in catalog DB
- * Deprecated - VF Module versions also captured by modelCustomizationUuid
- * @param vfModuleName Name to be assigned to the new VF Module
- * @param requestType Indicates if this is a Volume Group or Module request
- * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group
- * to attach to a VF Module
- * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if
- * this is an Add-on module
- * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces
- * the use of vfModuleType.
- * @param inputs Map of key=value inputs for VNF stack creation
- * @param failIfExists Flag whether already existing VNF should be considered
- * @param backout Flag whether to suppress automatic backout (for testing)
- * @param msoRequest Request tracking information for logs
- * @param vnfId Holder for output VF Module instance ID in the cloud
- * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc)
- * @param rollback Holder for returning VnfRollback object
- */
- public void createVfModule(String cloudSiteId,
- String tenantId,
- String vfModuleType,
- String vnfVersion,
- String vfModuleName,
- String requestType,
- String volumeGroupId,
- String baseVfModuleId,
- String modelCustomizationUuid,
- Map <String, String> inputs,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder <String> vnfId,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback)
- throws VnfException
- {
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("CreateVfModule");
-
- // Require a model customization ID. Every VF Module definition must have one.
- if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
- LOGGER.debug("Missing required input: modelCustomizationUuid");
- String error = "Create vfModule error: Missing required input: modelCustomizationUuid";
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module ModelCustomizationUuid", "null", "VDU", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Missing required input: modelCustomizationUuid");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
-
- // Clean up some inputs to make comparisons easier
- if (requestType == null)
- requestType = "";
-
- if ("".equals(volumeGroupId) || "null".equals(volumeGroupId))
- volumeGroupId = null;
-
- if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId))
- baseVfModuleId = null;
-
- if (inputs == null) {
- // Create an empty set of inputs
- inputs = new HashMap<>();
- LOGGER.debug("inputs == null - setting to empty");
- } else {
- this.sendMapToDebug(inputs);
- }
-
- // Check if this is for a "Volume" module
- boolean isVolumeRequest = false;
- if (requestType.startsWith("VOLUME")) {
- isVolumeRequest = true;
- }
-
- LOGGER.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " + baseVfModuleId);
-
- // Build a default rollback object (no actions performed)
- VnfRollback vfRollback = new VnfRollback();
- vfRollback.setCloudSiteId(cloudSiteId);
- vfRollback.setTenantId(tenantId);
- vfRollback.setMsoRequest(msoRequest);
- vfRollback.setRequestType(requestType);
- vfRollback.setIsBase(false); // Until we know better
- vfRollback.setVolumeGroupHeatStackId(volumeGroupId);
- vfRollback.setBaseGroupHeatStackId(baseVfModuleId);
- vfRollback.setModelCustomizationUuid(modelCustomizationUuid);
- vfRollback.setMode("CFY");
-
- rollback.value = vfRollback; // Default rollback - no updates performed
-
- // Get the VNF/VF Module definition from the Catalog DB first.
- // There are three relevant records: VfModule, VfModuleCustomization, VnfResource
-
- CatalogDatabase db = CatalogDatabase.getInstance();
- VfModule vfModule = null;
- VnfResource vnfResource = null;
- VfModuleCustomization vfModuleCust = null;
-
- try {
- vfModuleCust = db.getVfModuleCustomizationByModelCustomizationId(modelCustomizationUuid);
-
- if (vfModuleCust == null) {
- String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + modelCustomizationUuid;
- LOGGER.debug(error);
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found vfModuleCust entry " + vfModuleCust.toString());
- }
-
- // Get the vfModule and vnfResource records
- vfModule = vfModuleCust.getVfModule();
- vnfResource = db.getVnfResourceByModelUuid(vfModule.getVnfResourceModelUUId());
- }
- catch (Exception e) {
- db.close ();
- LOGGER.debug("unhandled exception in create VF - [Query]" + e.getMessage());
- throw new VnfException("Exception during create VF " + e.getMessage());
- }
-
- // Perform a version check against cloudSite
- // Obtain the cloud site information where we will create the VF Module
- Optional<CloudSite> cloudSite = cloudConfigFactory.getCloudConfig().getCloudSite (cloudSiteId);
- if (!cloudSite.isPresent()) {
- throw new VnfException (new MsoCloudSiteNotFound (cloudSiteId));
- }
- MavenLikeVersioning aicV = new MavenLikeVersioning();
- aicV.setVersion(cloudSite.get().getAic_version());
-
- String vnfMin = vnfResource.getAicVersionMin();
- String vnfMax = vnfResource.getAicVersionMax();
-
- if ( (vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) ||
- (vnfMax != null && aicV.isMoreRecentThan(vnfMax)))
- {
- // ERROR
- String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSite.get().getId() + " with AIC_Version:" + cloudSite.get().getAic_version();
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion");
- LOGGER.debug(error);
- throw new VnfException(error, MsoExceptionCategory.USERDATA);
- }
- // End Version check
-
-
- VduInstance vduInstance = null;
- CloudInfo cloudInfo = new CloudInfo (cloudSiteId, tenantId, null);
-
- // Use the VduPlugin.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId);
-
- // First, look up to see if the VF already exists.
-
- long subStartTime1 = System.currentTimeMillis ();
- try {
- vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleName);
- LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "QueryVDU", vfModuleName);
- }
- catch (VduException me) {
- // Failed to query the VDU due to a plugin exception.
- String error = "Create VF Module: Query " + vfModuleName + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "Exception - queryVdu", me);
- LOGGER.recordMetricEvent (subStartTime1, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu", vfModuleName);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule");
- throw new VnfException (me);
- }
-
- // More precise handling/messaging if the Module already exists
- if (vduInstance != null && !(vduInstance.getStatus().getState() == VduStateType.NOTFOUND)) {
- VduStateType status = vduInstance.getStatus().getState();
- LOGGER.debug ("Found Existing VDU, status=" + status);
-
- if (status == VduStateType.INSTANTIATED) {
- if (failIfExists != null && failIfExists) {
- // fail - it exists
- String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId;
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId());
- } else {
- // Found existing deployment and client has not requested "failIfExists".
- // Populate the outputs from the existing deployment.
-
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs (vduInstance.getOutputs ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module (found existing)");
- return;
- }
- }
- // Check through various detailed error cases
- else if (status == VduStateType.INSTANTIATING || status == VduStateType.DELETING || status == VduStateType.UPDATING) {
- // fail - it's in progress - return meaningful error
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId());
- }
- else if (status == VduStateType.FAILED) {
- // fail - it exists and is in a FAILED state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in FAILED state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId());
- }
- else if (status == VduStateType.UNKNOWN) {
- // fail - it exists and is in a UNKNOWN state
- String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in " + status.toString() + " state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId());
- }
- else {
- // Unexpected, since all known status values have been tested for
- String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention.";
- LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "VDU", "queryVdu", MsoLogger.ErrorCode.DataError, "VF Module " + vfModuleName + " already exists and is in an unknown state");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, vduInstance.getVduInstanceId());
- }
- }
-
-
- // Collect outputs from Base Modules and Volume Modules
- Map<String, Object> baseModuleOutputs = null;
- Map<String, Object> volumeGroupOutputs = null;
-
- // If a Volume Group was provided, query its outputs for inclusion in Module input parameters
- if (volumeGroupId != null) {
- long subStartTime2 = System.currentTimeMillis ();
- VduInstance volumeVdu = null;
- try {
- volumeVdu = vduPlugin.queryVdu (cloudInfo, volumeGroupId);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from VduPlugin", "VDU", "QueryVdu", volumeGroupId);
- }
- catch (VduException me) {
- // Failed to query the Volume Group VDU due to a plugin exception.
- String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, "VDU", "queryVdu(volume)", MsoLogger.ErrorCode.DataError, "Exception - queryVdu(volume)", me);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu(volume)", volumeGroupId);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule(QueryVolume)");
- throw new VnfException (me);
- }
-
- if (volumeVdu == null || volumeVdu.getStatus().getState() == VduStateType.NOTFOUND) {
- String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, volumeGroupId, cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached Volume Group DOES NOT EXIST");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found nested volume group");
- volumeGroupOutputs = volumeVdu.getOutputs();
- this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs");
- }
- }
-
- // If this is an Add-On Module, query the Base Module outputs
- // Note: This will be performed whether or not the current request is for an
- // Add-On Volume Group or Add-On VF Module
-
- if (vfModule.isBase()) {
- LOGGER.debug("This is a BASE Module request");
- vfRollback.setIsBase(true);
- } else {
- LOGGER.debug("This is an Add-On Module request");
-
- // Add-On Modules should always have a Base, but just treat as a warning if not provided.
- // Add-on Volume requests may or may not specify a base.
- if (!isVolumeRequest && baseVfModuleId == null) {
- LOGGER.debug ("WARNING: Add-on Module request - no Base Module ID provided");
- }
-
- if (baseVfModuleId != null) {
- long subStartTime2 = System.currentTimeMillis ();
- VduInstance baseVdu = null;
- try {
- baseVdu = vduPlugin.queryVdu (cloudInfo, baseVfModuleId);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Success response from VduPlugin", "VDU", "QueryVdu(Base)", baseVfModuleId);
- }
- catch (MsoException me) {
- // Failed to query the Base VF Module due to a Vdu Plugin exception.
- String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, "VDU", "queryVdu(Base)", MsoLogger.ErrorCode.DataError, "Exception - queryVdu(Base)", me);
- LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVdu(Base)", baseVfModuleId);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- // Convert to a generic VnfException
- me.addContext ("CreateVFModule(QueryBase)");
- throw new VnfException (me);
- }
-
- if (baseVdu == null || baseVdu.getStatus().getState() == VduStateType.NOTFOUND) {
- String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ;
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, baseVfModuleId, cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Base Module DOES NOT EXIST");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
- LOGGER.debug(error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug("Found base module");
- baseModuleOutputs = baseVdu.getOutputs();
- this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs");
- }
- }
- }
-
- // NOTE: For this section, heatTemplate is used for all template artifacts.
- // In final implementation (post-POC), the template object would either be generic or there would
- // be a separate DB Table/Object for different sub-orchestrators.
-
- // NOTE: The template is fixed for the VF Module. The environment is part of the customization.
-
- // NOTE: The template is fixed for the VF Module. The environment is part of the customization.
- String heatTemplateArtifactUuid = null;
- String heatEnvironmentArtifactUuid = null;
-
- if (isVolumeRequest) {
- heatTemplateArtifactUuid = vfModule.getVolHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfModuleCust.getVolEnvironmentArtifactUuid();
- } else {
- heatTemplateArtifactUuid = vfModule.getHeatTemplateArtifactUUId();
- heatEnvironmentArtifactUuid = vfModuleCust.getHeatEnvironmentArtifactUuid();
- }
-
- if (heatTemplateArtifactUuid == null || heatTemplateArtifactUuid.equals("")) {
- String error = "Create: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestType;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "Cloudify", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
-
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
-
- if (heatTemplate == null) {
- String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid;
- LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM,
- "Heat Template ID",
- String.valueOf(heatTemplateArtifactUuid), "Cloudify", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException(error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug("Got HEAT Template record from DB");
-
- // Next get the Environment record. This is optional.
- HeatEnvironment heatEnvironment = null;
- if (heatEnvironmentArtifactUuid != null && !heatEnvironmentArtifactUuid.equals(""))
- {
- heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid);
- if (heatEnvironment == null) {
- String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType
- + ", Environment ID="
- + heatEnvironmentArtifactUuid;
- LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "Cloudify", "getEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- // Alarm on this error, configuration must be fixed
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
-
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
- }
- LOGGER.debug ("Got Heat Environment from DB");
- } else {
- LOGGER.debug ("no environment parameter found for this Type " + vfModuleType);
- }
-
-
- // Create the combined set of parameters from the incoming request, base-module outputs,
- // volume-module outputs. Also, convert all variables to their native object types.
-
- HashMap<String, Object> goldenInputs = new HashMap<>();
- List<String> extraInputs = new ArrayList<>();
-
- Boolean skipInputChecks = false;
-
- if (skipInputChecks) {
- goldenInputs = new HashMap<String,Object>();
- for (String key : inputs.keySet()) {
- goldenInputs.put(key, inputs.get(key));
- }
- }
- else {
- // Build maps for the parameters (including aliases) to simplify checks
- HashMap<String, HeatTemplateParam> params = new HashMap<>();
-
- Set<HeatTemplateParam> paramSet = heatTemplate.getParameters();
- LOGGER.debug("paramSet has " + paramSet.size() + " entries");
-
- for (HeatTemplateParam htp : paramSet) {
- params.put(htp.getParamName(), htp);
-
- // Include aliases.
- String alias = htp.getParamAlias();
- if (alias != null && !alias.equals("") && !params.containsKey(alias)) {
- params.put(alias, htp);
- }
- }
-
- // First, convert all inputs to their "template" type
- for (String key : inputs.keySet()) {
- if (params.containsKey(key)) {
- Object value = convertInputValue(inputs.get(key), params.get(key));
- if (value != null) {
- goldenInputs.put(key, value);
- }
- else {
- LOGGER.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " + params.get(key).getParamType());
- }
- } else {
- extraInputs.add(key);
- }
- }
-
- if (!extraInputs.isEmpty()) {
- LOGGER.debug("Ignoring extra inputs: " + extraInputs);
- }
-
- // Next add in Volume Group Outputs if there are any. Copy directly without conversions.
- if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) {
- for (String key : volumeGroupOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, volumeGroupOutputs.get(key));
- }
- }
- }
-
- // Next add in Base Module Outputs if there are any. Copy directly without conversions.
- if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) {
- for (String key : baseModuleOutputs.keySet()) {
- if (params.containsKey(key) && !goldenInputs.containsKey(key)) {
- goldenInputs.put(key, baseModuleOutputs.get(key));
- }
- }
- }
-
- // TODO: The model should support a mechanism to pre-assign default parameter values
- // per "customization" (i.e. usage) of a given module. In HEAT, this is specified by
- // an Environment file. There is not a general mechanism in the model to handle this.
- // For the general case, any such parameter/values can be added dynamically to the
- // inputs (only if not already specified).
-
-
- // Check that required parameters have been supplied from any of the sources
- String missingParams = null;
- boolean checkRequiredParameters = true;
- try {
- String propertyString = this.msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER)
- .getProperty(MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS,null);
- if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) {
- checkRequiredParameters = false;
- LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..."
- + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS);
- }
- } catch (Exception e) {
- // No problem - default is true
- LOGGER.debug ("An exception occured trying to get property " + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS, e);
- }
-
- // Do the actual parameter checking.
- // Include looking at the ENV file as a valid definition of a parameter value.
- // TODO: This handling of ENV applies only to Heat. A general mechanism to
- // support pre-set parameter/values does not yet exist in the model.
- //
- StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment());
- MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry (sb);
- for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
- if (parm.isRequired () && (!goldenInputs.containsKey (parm.getParamName ()))) {
- if (mhee != null && mhee.containsParameter(parm.getParamName())) {
- LOGGER.debug ("Required parameter " + parm.getParamName ()
- + " appears to be in environment - do not count as missing");
- } else {
- LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ());
- if (missingParams == null) {
- missingParams = parm.getParamName ();
- } else {
- missingParams += "," + parm.getParamName ();
- }
- }
- }
- }
-
- if (missingParams != null) {
- if (checkRequiredParameters) {
- // Problem - missing one or more required parameters
- String error = "Create VFModule: Missing Required inputs: " + missingParams;
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "VDU", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
- } else {
- LOGGER.debug ("found missing parameters [" + missingParams + "] - but checkRequiredParameters is false - will not block");
- }
- } else {
- LOGGER.debug ("No missing parameters found - ok to proceed");
- }
-
- } // NOTE: END PARAMETER CHECKING
-
- // Here we go... ready to deploy the VF Module.
- long instantiateVduStartTime = System.currentTimeMillis ();
- if (backout == null) backout = true;
-
- try {
- // Construct the VDU Model structure to pass to the targeted VduPlugin
- VduModelInfo vduModel = null;
- if (! isVolumeRequest) {
- vduModel = vduMapper.mapVfModuleCustomizationToVdu(vfModuleCust);
- } else {
- vduModel = vduMapper.mapVfModuleCustVolumeToVdu(vfModuleCust);
- }
-
- // Invoke the VduPlugin to instantiate the VF Module
- vduInstance = vduPlugin.instantiateVdu(cloudInfo, vfModuleName, goldenInputs, vduModel, backout);
-
- LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from VduPlugin", "VDU", "instantiateVdu", vfModuleName);
- }
- catch (VduException me) {
- // Failed to instantiate the VDU.
- me.addContext ("CreateVFModule");
- String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "instantiateVdu", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "VDU", "", MsoLogger.ErrorCode.DataError, "MsoException - instantiateVdu", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- // Convert to a generic VnfException
- throw new VnfException (me);
- }
- catch (NullPointerException npe) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe;
- LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error, "VDU", "instantiateVdu", vfModuleName);
- LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "VDU", "", MsoLogger.ErrorCode.DataError, "NullPointerException - instantiateVdu", npe);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- LOGGER.debug("NULL POINTER EXCEPTION at vduPlugin.instantiateVdu", npe);
- throw new VnfException ("NullPointerException during instantiateVdu");
- }
- catch (Exception e) {
- String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + e;
- LOGGER.recordMetricEvent (instantiateVduStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, error, "VDU", "instantiateVdu", vfModuleName);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, error);
- LOGGER.debug("Unhandled exception at vduPlugin.instantiateVdu", e);
- } finally {
- db.close();
- }
-
- // Reach this point if create is successful.
- // Populate remaining rollback info and response parameters.
- vfRollback.setVnfCreated (true);
- vfRollback.setVnfId (vduInstance.getVduInstanceId());
- vnfId.value = vduInstance.getVduInstanceId();
- outputs.value = copyStringOutputs (vduInstance.getOutputs ());
-
- rollback.value = vfRollback;
-
- LOGGER.debug ("VF Module " + vfModuleName + " successfully created");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module");
- return;
- }
-
- public void deleteVfModule (String cloudSiteId,
- String tenantId,
- String vfModuleId,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs) throws VnfException
- {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName ("DeleteVfModule");
-
- LOGGER.debug ("Deleting VF Module " + vfModuleId + " in " + cloudSiteId + "/" + tenantId);
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Capture the output parameters on a delete, so need to query first
- VduInstance vduInstance = null;
- CloudInfo cloudInfo = new CloudInfo(cloudSiteId, tenantId, null);
-
- // Use the VduPlugin.
- VduPlugin vduPlugin = getVduPlugin(cloudSiteId);
-
- try {
- vduInstance = vduPlugin.queryVdu (cloudInfo, vfModuleId);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received VDU Query response", "VDU", "QueryVDU", vfModuleId);
- }
- catch (VduException e) {
- // Failed to query the VDU due to a plugin exception.
- // Convert to a generic VnfException
- e.addContext ("QueryVFModule");
- String error = "Query VfModule (VDU): " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + e;
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "VDU", "QueryVNF", vfModuleId);
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "QueryVFModule", MsoLogger.ErrorCode.DataError, "Exception - queryVDU", e);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (e);
- }
-
- // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected Object types
- outputs.value = convertMapStringObjectToStringString(vduInstance.getOutputs());
-
- // Use the VduPlugin to delete the VDU.
- // The possible outcomes of deleteVdu are
- // - a vnfInstance object with status of DELETED (success)
- // - a vnfInstance object with status of NOTFOUND (VDU did not exist, treat as success)
- // - a vnfInstance object with status of FAILED (error)
- // Also, VduException could be thrown.
- long subStartTime = System.currentTimeMillis ();
- try {
- // TODO: Get an appropriate timeout value - require access to the model
- vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5);
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from deleteVdu", "VDU", "DeleteVdu", vfModuleId);
- } catch (VduException me) {
- me.addContext ("DeleteVfModule");
- // Convert to a generic VnfException
- String error = "Delete VF: " + vfModuleId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "DeleteVdu", "DeleteVdu", vfModuleId);
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vfModuleId, cloudSiteId, tenantId, "VDU", "DeleteVdu", MsoLogger.ErrorCode.DataError, "Exception - DeleteVdu: " + me.getMessage());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new VnfException (me);
- }
-
- // On success, nothing is returned.
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF");
- return;
- }
-
- // Update VF Module not yet implemented for generic VDU plug-in model.
- @Override
- public void updateVfModule (String cloudSiteId,
- String tenantId,
- String vnfType,
- String vnfVersion,
- String vnfName,
- String requestType,
- String volumeGroupHeatStackId,
- String baseVfHeatStackId,
- String vfModuleStackId,
- String modelCustomizationUuid,
- Map <String, String> inputs,
- MsoRequest msoRequest,
- Holder <Map <String, String>> outputs,
- Holder <VnfRollback> rollback) throws VnfException
- {
- // This operation is not currently supported for VduPlugin-orchestrated VF Modules.
- LOGGER.debug ("Update VF Module command attempted but not supported");
- throw new VnfException ("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA);
- }
-
- /*
- * Dynamic selection of a VduPlugin version. For initial tests, base on the "orchestrator"
- * defined for the target cloud. Should really be looking at the VNF Model (ochestration_mode)
- * but we don't currently have access to that in Query and Delete cases.
- */
- private VduPlugin getVduPlugin (String cloudSiteId) {
- Optional<CloudSite> cloudSite = cloudConfigFactory.getCloudConfig().getCloudSite(cloudSiteId);
- if (cloudSite.isPresent()) {
- String orchestrator = cloudSite.get().getOrchestrator();
-
- if (orchestrator.equalsIgnoreCase("CLOUDIFY")) {
- return cloudifyUtils;
- }
- else if (orchestrator.equalsIgnoreCase("ARIA")) {
- return ariaVduPlugin;
- }
- else if (orchestrator.equalsIgnoreCase("HEAT")) {
- return heatUtils;
- }
- }
-
- // Default - return HEAT plugin, though will fail later
- return heatUtils;
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java
deleted file mode 100644
index a25327b333..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VfRollback.java
+++ /dev/null
@@ -1,137 +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.vnf;
-
-
-
-import org.openecomp.mso.entity.MsoRequest;
-
-public class VfRollback {
- private String vnfId;
- private String tenantId;
- private String cloudSiteId;
- private boolean tenantCreated = false;
- private boolean vnfCreated = false;
- private MsoRequest msoRequest;
- private String volumeGroupName;
- private String volumeGroupId;
- private String requestType;
- private String volumeGroupHeatStackId;
- private String baseGroupHeatStackId;
- private boolean isBase = false;
- private String vfModuleStackId;
-
-
- public String getVnfId() {
- return vnfId;
- }
- public void setVnfId(String vnfId) {
- this.vnfId = vnfId;
- }
- public String getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(String tenantId) {
- this.tenantId = tenantId;
- }
- public String getCloudSiteId() {
- return cloudSiteId;
- }
- public void setCloudSiteId(String cloudId) {
- this.cloudSiteId = cloudId;
- }
- public boolean getTenantCreated() {
- return tenantCreated;
- }
- public void setTenantCreated(boolean tenantCreated) {
- this.tenantCreated = tenantCreated;
- }
- public boolean getVnfCreated() {
- return vnfCreated;
- }
- public void setVnfCreated(boolean vnfCreated) {
- this.vnfCreated = vnfCreated;
- }
- public MsoRequest getMsoRequest() {
- return msoRequest;
- }
- public void setMsoRequest (MsoRequest msoRequest) {
- this.msoRequest = msoRequest;
- }
- public String getVolumeGroupName() {
- return this.volumeGroupName;
- }
- public void setVolumeGroupName(String volumeGroupName) {
- this.volumeGroupName = volumeGroupName;
- }
- public String getVolumeGroupId() {
- return this.volumeGroupId;
- }
- public void setVolumeGroupId(String volumeGroupId) {
- this.volumeGroupId = volumeGroupId;
- }
- public String getRequestType() {
- return this.requestType;
- }
- public void setRequestType(String requestType) {
- this.requestType = requestType;
- }
- /*
- private String volumeGroupHeatStackId;
- private String baseGroupHeatStackId;
- private boolean isBase = false;
- */
- public String getVolumeGroupHeatStackId() {
- return this.volumeGroupHeatStackId;
- }
- public void setVolumeGroupHeatStackId(String volumeGroupHeatStackId) {
- this.volumeGroupHeatStackId = volumeGroupHeatStackId;
- }
-
- public String getBaseGroupHeatStackId() {
- return this.baseGroupHeatStackId;
- }
- public void setBaseGroupHeatStackId(String baseGroupHeatStackId) {
- this.baseGroupHeatStackId = baseGroupHeatStackId;
- }
-
- public boolean isBase() {
- return this.isBase;
- }
- public void setIsBase(boolean isBase) {
- this.isBase = isBase;
- }
- public String getVfModuleStackId() {
- return this.vfModuleStackId;
- }
- public void setVfModuleStackId(String vfModuleStackId) {
- this.vfModuleStackId = vfModuleStackId;
- }
-
- @Override
- public String toString() {
- return "VfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId +
- ", vnf=" + vnfId + ", tenantCreated=" + tenantCreated +
- ", vnfCreated=" + vnfCreated + ", requestType = " + requestType +
- ", volumeGroupHeatStackId = " + this.volumeGroupHeatStackId;
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java
deleted file mode 100644
index d393bea713..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRest.java
+++ /dev/null
@@ -1,621 +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.vnf;
-
-
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-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.Response;
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.xml.ws.Holder;
-
-import org.apache.http.HttpStatus;
-
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-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.VnfStatus;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.adapters.vnfrest.*;
-
-/**
- * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v1/vnfs)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- * For testing, call with cloudSiteId = ___TESTING___
- * To test exceptions, also set tenantId = ___TESTING___
- */
-@Path("/v1/vnfs")
-public class VnfAdapterRest {
- private static 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 MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
- //TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth,
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces(MediaType.TEXT_HTML)
- public Response healthcheck () {
- String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- return Response.ok().entity(CHECK_HTML).build();
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>
- * REQUEST:
- * {"deleteVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteVfModule (
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- final DeleteVfModuleRequest req)
- {
- LOGGER.debug("Delete VfModule enter: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content")
- .build();
- }
- if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) {
- LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vfModuleId in URL does not match content")
- .build();
- }
- DeleteVfModuleTask task = new DeleteVfModuleTask(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 delete, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVfModuleTask implements Runnable {
- private final DeleteVfModuleRequest req;
- private DeleteVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public DeleteVfModuleTask(DeleteVfModuleRequest 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<DeleteVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- String cloudsite = req.getCloudSiteId();
- Holder<Map<String, String>> outputs = new Holder <> ();
- if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
- //vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest());
- vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest(), outputs);
- }
- response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value);
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1
- * RESP:
- * {"queryVfModuleResponse": {
- "vfModuleId": "AvfmodId",
- "vfModuleOutputs": {"entry": {
- "key": "server_private_ip_1",
- "value": "10.100.1.25"
- }},
- "vfModuleStackId": "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b",
- "vnfId": "AvnfID",
- "vnfStatus": "ACTIVE"
- }}
- */
- @GET
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("tenantId") String tenantId,
- @QueryParam("vfModuleName") String vfModuleName, //RAA? Id in doc
- @QueryParam("skipAAI") Boolean skipAAI,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId)
- {
- //This request responds synchronously only
- LOGGER.debug ("Query vfModule enter:" + vfModuleName);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder <> ();
- vnfAdapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs);
- if (!vnfExists.value) {
- LOGGER.debug ("vfModule not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value);
- qryResp.setVfModuleId(vfModuleId.value);
- qryResp.setVnfStatus(status.value);
- qryResp.setVfModuleOutputs(outputs.value);
- }
- LOGGER.debug ("Query vfModule exit");
- return Response
- .status(respStatus)
- .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {})
- .build();
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e);
- VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {})
- .build();
- }
- }
-
- /*URL: http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules
- *REQUEST:
- * {"createVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleName": "RaaVnf1",
- "vnfType": "ApacheVnf",
- "vfModuleParams": {"entry": [
- {"key": "network_id",
- "value": "59ed7b41-2983-413f-ba93-e7d437433916"},
- {"key": "subnet_id",
- "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"},
- {"key": "server_name_0",
- "value": "RaaVnf1"}
- ]},
- "failIfExists": true,
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @POST
- @Path("{aaiVnfId}/vf-modules")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- final CreateVfModuleRequest req)
- {
- LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content")
- .build();
- }
- CreateVfModuleTask task = new CreateVfModuleTask(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_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("createVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVfModuleTask implements Runnable {
- private final CreateVfModuleRequest req;
- private CreateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public CreateVfModuleTask(CreateVfModuleRequest 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<CreateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(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 ("CreateVfModuleTask start");
- try {
- // Synchronous Web Service Outputs
- Holder <String> vfModuleStackId = new Holder <> ();
- Holder <Map <String, String>> outputs = new Holder <> ();
- Holder <VnfRollback> vnfRollback = new Holder <> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType);
- String cloudsite = req.getCloudSiteId();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsite,
- true, false, new MsoRequest("reqid", "svcid"),
- req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType(), req.getModelCustomizationUuid());
- vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = VolumeAdapterRest.testMap();
- } else {
-// vnfAdapter.createVnf (createReq.getCloudSiteId(),
-// createReq.getTenantId(),
-// createReq.getVnfType(),
-// createReq.getVnfVersion(),
-// createReq.getVfModuleName(),
-// createReq.getRequestType(),
-// createReq.getVolumeGroupStackId(),
-// createReq.getVfModuleParams(),
-// createReq.getFailIfExists(),
-// createReq.getBackout(),
-// createReq.getMsoRequest(),
-// vfModuleStackId,
-// outputs,
-// vnfRollback);
- vnfAdapter.createVfModule(req.getCloudSiteId(),
- req.getTenantId(),
- //req.getVnfType(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVfModuleName(),
- req.getRequestType(),
- req.getVolumeGroupStackId(),
- req.getBaseVfModuleStackId(),
- req.getModelCustomizationUuid(),
- req.getVfModuleParams(),
- req.getFailIfExists(),
- req.getBackout(),
- req.getMsoRequest(),
- vfModuleStackId,
- outputs,
- vnfRollback);
- }
- VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), vfModuleStackId.value, req.getMessageId());
- response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
- vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @PUT
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response updateVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- final UpdateVfModuleRequest req)
- {
- LOGGER.debug("Update VfModule enter: " + req.toJsonString());
- UpdateVfModulesTask task = new UpdateVfModulesTask(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_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("updateVfModules exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVfModulesTask implements Runnable {
- private final UpdateVfModuleRequest req;
- private UpdateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public UpdateVfModulesTask(UpdateVfModuleRequest 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<UpdateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- try {
- //MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <String> vfModuleStackId = new Holder <> ();
- Holder <Map <String, String>> outputs = new Holder <> ();
- Holder <VnfRollback> vnfRollback = new Holder <> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- vnfAdapter.updateVfModule (req.getCloudSiteId(),
- req.getTenantId(),
- //req.getVnfType(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVfModuleName(),
- req.getRequestType(),
- req.getVolumeGroupStackId(),
- req.getBaseVfModuleStackId(),
- req.getVfModuleStackId(),
- req.getModelCustomizationUuid(),
- req.getVfModuleParams(),
- req.getMsoRequest(),
- outputs,
- vnfRollback);
-
- response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
- vfModuleStackId.value, outputs.value, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.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 ("Update VfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback
- * REQUEST:
- * {"deleteVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackVfModule (
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- //@QueryParam("rollback") String rollback,
- final RollbackVfModuleRequest req)
- {
- LOGGER.debug("Rollback VfModule enter: " + req.toJsonString());
- RollbackVfModulesTask task = new RollbackVfModulesTask(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_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("rollbackVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVfModulesTask implements Runnable {
- private final RollbackVfModuleRequest req;
- private RollbackVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVfModulesTask(RollbackVfModuleRequest 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<RollbackVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- try {
- VfModuleRollback vmr = req.getVfModuleRollback();
- VnfRollback vrb = new VnfRollback(
- vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, true,
- vmr.getMsoRequest(), null, null, null, null);
- vnfAdapter.rollbackVnf (vrb);
- response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, 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 ("RollbackVfModulesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-} \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestUtils.java
deleted file mode 100644
index 487e9c2b60..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.vnf;
-
-import java.util.Optional;
-
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class VnfAdapterRestUtils
-{
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
- /*
- * Choose which implementation of VNF Adapter to use, based on the orchestration mode.
- * Currently, the two supported orchestrators are HEAT and CLOUDIFY.
- */
- public static MsoVnfAdapter getVnfAdapterImpl (String mode, String cloudSiteId)
- {
- // First, determine the orchestration mode to use.
- // If was explicitly provided as a parameter, use that. Else if specified for the
- // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl.
-
- LOGGER.debug ("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId);
-
- if (mode == null) {
- // Didn't get an explicit mode type requested.
- // Use the CloudSite to determine which Impl to use, based on whether the target cloutSite
- // has a CloudifyManager assigned to it
- Optional<CloudSite> cloudSite = cloudConfigFactory.getCloudConfig().getCloudSite(cloudSiteId);
- if (cloudSite.isPresent()) {
- LOGGER.debug("Got CloudSite: " + cloudSite.toString());
- if (cloudSite.get().getCloudifyManager() != null) {
- mode = "CLOUDIFY";
- } else {
- mode = "HEAT";
- }
- }
- }
-
- LOGGER.debug ("GetVnfAdapterImpl: mode=" + mode);
-
- MsoVnfAdapter vnfAdapter = null;
-
- // TODO: Make this more dynamic (e.g. Service Loader)
- if ("CLOUDIFY".equalsIgnoreCase(mode)) {
- LOGGER.debug ("GetVnfAdapterImpl: Return Cloudify Adapter");
- vnfAdapter = new MsoVnfCloudifyAdapterImpl (msoPropertiesFactory, cloudConfigFactory);;
- }
- else if ("HEAT".equalsIgnoreCase(mode)) {
- LOGGER.debug ("GetVnfAdapterImpl: Return Heat Adapter");
- vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
- }
- else {
- // Default is the PLUGIN adapter
- LOGGER.debug ("GetVnfAdapterImpl: Return Default (Plugin) Adapter");
- vnfAdapter = new MsoVnfPluginAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
- }
-
- return vnfAdapter;
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2.java
deleted file mode 100644
index 5e17e9c015..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2.java
+++ /dev/null
@@ -1,629 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.vnf;
-
-
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-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.Response;
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.MediaType;
-import javax.xml.ws.Holder;
-
-import org.apache.http.HttpStatus;
-
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.adapters.vnfrest.*;
-
-/**
- * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v2/vnfs)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- * For testing, call with cloudSiteId = ___TESTING___
- * To test exceptions, also set tenantId = ___TESTING___
- *
- * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify)
- * based on the target cloud.
- */
-@Path("/v2/vnfs")
-public class VnfAdapterRestV2 {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static final String TESTING_KEYWORD = "___TESTING___";
- //TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth,
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces(MediaType.TEXT_HTML)
- public Response healthcheck () {
- String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- return Response.ok().entity(CHECK_HTML).build();
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid>
- * REQUEST:
- * {"deleteVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteVfModule (
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @QueryParam("mode") String mode,
- final DeleteVfModuleRequest req)
- {
- LOGGER.debug("Delete VfModule enter: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content")
- .build();
- }
- if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) {
- LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vfModuleId in URL does not match content")
- .build();
- }
-
- DeleteVfModuleTask task = new DeleteVfModuleTask(req, mode);
- 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 delete, send generic failure as sync resp to caller
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVfModuleTask implements Runnable {
- private final DeleteVfModuleRequest req;
- private DeleteVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public DeleteVfModuleTask(DeleteVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<DeleteVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
-
- @Override
- public void run() {
- try {
- String cloudsite = req.getCloudSiteId();
- Holder<Map<String, String>> outputs = new Holder <Map <String, String>> ();
- if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
- //vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest());
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite);
- adapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest(), outputs);
- }
- response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value);
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1
- * RESP:
- * {"queryVfModuleResponse": {
- "vfModuleId": "AvfmodId",
- "vfModuleOutputs": {"entry": {
- "key": "server_private_ip_1",
- "value": "10.100.1.25"
- }},
- "vfModuleStackId": "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b",
- "vnfId": "AvnfID",
- "vnfStatus": "ACTIVE"
- }}
- */
- @GET
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("tenantId") String tenantId,
- @QueryParam("vfModuleName") String vfModuleName, //RAA? Id in doc
- @QueryParam("skipAAI") Boolean skipAAI,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @QueryParam("mode") String mode)
- {
- //This request responds synchronously only
- LOGGER.debug ("Query vfModule enter:" + vfModuleName);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null);
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vfModuleId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String, String>> outputs = new Holder <Map <String, String>> ();
-
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- adapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs);
-
- if (!vnfExists.value) {
- LOGGER.debug ("vfModule not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value);
- qryResp.setVfModuleId(vfModuleId.value);
- qryResp.setVnfStatus(status.value);
- qryResp.setVfModuleOutputs(outputs.value);
- }
- LOGGER.debug ("Query vfModule exit");
- return Response
- .status(respStatus)
- .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {})
- .build();
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e);
- VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {})
- .build();
- }
- }
-
- /*URL: http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules
- *REQUEST:
- * {"createVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleName": "RaaVnf1",
- "vnfType": "ApacheVnf",
- "vfModuleParams": {"entry": [
- {"key": "network_id",
- "value": "59ed7b41-2983-413f-ba93-e7d437433916"},
- {"key": "subnet_id",
- "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"},
- {"key": "server_name_0",
- "value": "RaaVnf1"}
- ]},
- "failIfExists": true,
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @POST
- @Path("{aaiVnfId}/vf-modules")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- @QueryParam("mode") String mode,
- final CreateVfModuleRequest req)
- {
- LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString());
- if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
- LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("vnfid in URL does not match content")
- .build();
- }
-
- CreateVfModuleTask task = new CreateVfModuleTask(req, mode);
- 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_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("createVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVfModuleTask implements Runnable {
- private final CreateVfModuleRequest req;
- private CreateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public CreateVfModuleTask(CreateVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<CreateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(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 ("CreateVfModuleTask start");
- try {
- // Synchronous Web Service Outputs
- Holder <String> vfModuleStackId = new Holder <String> ();
- Holder <Map <String, String>> outputs = new Holder <Map <String, String>> ();
- Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
- if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsiteId,
- true, false, new MsoRequest("reqid", "svcid"),
- req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType(), req.getModelCustomizationUuid());
- vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = VolumeAdapterRest.testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- adapter.createVfModule(req.getCloudSiteId(),
- req.getTenantId(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVfModuleName(),
- req.getRequestType(),
- req.getVolumeGroupStackId(),
- req.getBaseVfModuleStackId(),
- req.getModelCustomizationUuid(),
- req.getVfModuleParams(),
- req.getFailIfExists(),
- req.getBackout(),
- req.getMsoRequest(),
- vfModuleStackId,
- outputs,
- vnfRollback);
- }
- VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), vfModuleStackId.value, req.getMessageId());
- response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
- vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
- } catch (VnfException e) {
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
- }
- if (!req.isSynchronous()) {
- BpelRestClient bpelClient = new BpelRestClient();
- bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
- }
- LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @PUT
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response updateVfModule(
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- @QueryParam("mode") String mode,
- final UpdateVfModuleRequest req)
- {
- LOGGER.debug("Update VfModule enter: " + req.toJsonString());
- UpdateVfModulesTask task = new UpdateVfModulesTask(req, mode);
- 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_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("updateVfModules exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVfModulesTask implements Runnable {
- private final UpdateVfModuleRequest req;
- private UpdateVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public UpdateVfModulesTask(UpdateVfModuleRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<UpdateVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- try {
- //MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
-
- // Synchronous Web Service Outputs
- Holder <String> vfModuleStackId = new Holder <String> ();
- Holder <Map <String, String>> outputs = new Holder <Map <String, String>> ();
- Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
-
- // Support different Adapter Implementations
- MsoVnfAdapter adapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- adapter.updateVfModule (req.getCloudSiteId(),
- req.getTenantId(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVfModuleName(),
- req.getRequestType(),
- req.getVolumeGroupStackId(),
- req.getBaseVfModuleId(),
- req.getVfModuleStackId(),
- req.getModelCustomizationUuid(),
- req.getVfModuleParams(),
- req.getMsoRequest(),
- outputs,
- vnfRollback);
-
- response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
- vfModuleStackId.value, outputs.value, req.getMessageId());
- } catch (VnfException e) {
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.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 ("Update VfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
- /*
- * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback
- * REQUEST:
- * {"deleteVfModuleRequest":
- {"cloudSiteId": "DAN",
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "vnfId": "somevnfid",
- "vfModuleId": "somemodid",
- "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
- "messageId": "ra.1",
- "notificationUrl": "http://localhost:8089/vnfmock",
- "skipAAI": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- }
- */
- @DELETE
- @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackVfModule (
- @PathParam("aaiVnfId") String aaiVnfId,
- @PathParam("aaiVfModuleId") String aaiVfModuleId,
- //@QueryParam("rollback") String rollback,
- final RollbackVfModuleRequest req)
- {
- LOGGER.debug("Rollback VfModule enter: " + req.toJsonString());
- RollbackVfModulesTask task = new RollbackVfModulesTask(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_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("rollbackVfModule exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVfModulesTask implements Runnable {
- private final RollbackVfModuleRequest req;
- private RollbackVfModuleResponse response = null;
- private VfModuleExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVfModulesTask(RollbackVfModuleRequest 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<RollbackVfModuleResponse>(response) {}
- : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
- }
- private String getResponse() {
- if (response != null) {
- return sendxml ? response.toXmlString() : response.toJsonString();
- } else {
- return sendxml ? eresp.toXmlString() : eresp.toJsonString();
- }
- }
- @Override
- public void run() {
- try {
- VfModuleRollback vmr = req.getVfModuleRollback();
- VnfRollback vrb = new VnfRollback(
- vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, vmr.isVfModuleCreated(),
- vmr.getMsoRequest(), null, null, null, null);
-
- // Support multiple adapter implementations
- MsoVnfAdapter adapter = VnfAdapterRestUtils.getVnfAdapterImpl (vmr.getMode(), vmr.getCloudSiteId());
- adapter.rollbackVnf (vrb);
-
- response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
- eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, 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 ("RollbackVfModulesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java
deleted file mode 100644
index a8250fc35b..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRest.java
+++ /dev/null
@@ -1,583 +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.vnf;
-
-
-import java.util.HashMap;
-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.vnf.exceptions.VnfException;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
-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.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-/**
- * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- * For testing, call with cloudSiteId = ___TESTING___
- * To test exceptions, also set tenantId = ___TESTING___
- */
-@Path("/v1/volume-groups")
-public class VolumeAdapterRest {
- 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 MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropertiesFactory, cloudConfigFactory);
-
- @POST
- @Path("")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createVNFVolumes(final CreateVolumeGroupRequest req) {
- LOGGER.debug("createVNFVolumes enter: " + req.toJsonString());
- CreateVNFVolumesTask task = new CreateVNFVolumesTask(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_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("createVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVNFVolumesTask implements Runnable {
- private final CreateVolumeGroupRequest req;
- private CreateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public CreateVNFVolumesTask(CreateVolumeGroupRequest 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<CreateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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 ("CreateVFModule VolumesTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> stackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsite = req.getCloudSiteId();
- if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = testMap();
- } else {
-// vnfAdapter.createVnf(
-// req.getCloudSiteId(),
-// req.getTenantId(),
-// req.getVnfType(),
-// req.getVnfVersion(),
-// req.getVolumeGroupName(),
-// "VOLUME", // request type is VOLUME
-// null, // not sure about this
-// req.getVolumeGroupParams(),
-// req.getFailIfExists(),
-// req.getSuppressBackout(),
-// req.getMsoRequest(),
-// stackId,
-// outputs,
-// vnfRollback);
- vnfAdapter.createVfModule(
- req.getCloudSiteId(), //cloudSiteId,
- req.getTenantId(), //tenantId,
- //req.getVnfType(), //vnfType,
- completeVnfVfModuleType,
- req.getVnfVersion(), //vnfVersion,
- req.getVolumeGroupName(), //vnfName,
- "VOLUME", //requestType,
- null, //volumeGroupHeatStackId,
- null, //baseVfHeatStackId,
- req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(), //inputs,
- req.getFailIfExists(), //failIfExists,
- req.getSuppressBackout(), //backout,
- req.getMsoRequest(), // msoRequest,
- stackId,
- outputs,
- vnfRollback);
- }
- VolumeGroupRollback rb = new VolumeGroupRollback(
- req.getVolumeGroupId(),
- stackId.value,
- true, // TODO boolean volumeGroupCreated, when would it be false?
- req.getTenantId(),
- req.getCloudSiteId(),
- req.getMsoRequest(),
- req.getMessageId());
- response = new CreateVolumeGroupResponse(
- req.getVolumeGroupId(),
- stackId.value,
- true, // TODO boolean volumeGroupCreated, when would it be false?
- outputs.value,
- rb,
- req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(
- 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 ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- final DeleteVolumeGroupRequest req
- )
- {
- LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(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_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVNFVolumesTask implements Runnable {
- private final DeleteVolumeGroupRequest req;
- private DeleteVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public DeleteVNFVolumesTask(DeleteVolumeGroupRequest 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<DeleteVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("DeleteVNFVolumesTask start");
- try {
- if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest());
- }
- response = new DeleteVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}/rollback")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- final RollbackVolumeGroupRequest req
- )
- {
- LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(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_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug("rollbackVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVNFVolumesTask implements Runnable {
- private final RollbackVolumeGroupRequest req;
- private RollbackVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVNFVolumesTask(RollbackVolumeGroupRequest 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<RollbackVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("DeleteVNFVolumesTask start");
- try {
- VolumeGroupRollback vgr = req.getVolumeGroupRollback();
- VnfRollback vrb = new VnfRollback(
- vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true,
- vgr.getMsoRequest(), null, null, null, null);
- vnfAdapter.rollbackVnf(vrb);
- response = new RollbackVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
-
- }
-
- @PUT
- @Path("{aaiVolumeGroupId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response updateVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- final UpdateVolumeGroupRequest req
- )
- {
- LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(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_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("updateVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVNFVolumesTask implements Runnable {
- private final UpdateVolumeGroupRequest req;
- private UpdateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public UpdateVNFVolumesTask(UpdateVolumeGroupRequest 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<UpdateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("UpdateVNFVolumesTask start");
- try {
- @SuppressWarnings("unused")
- Holder<Map<String, String>> outputs = new Holder<> ();
- Holder<VnfRollback> vnfRollback = new Holder<> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- outputs.value = testMap();
- } else {
- //vnfAdapter.updateVnf(
- // req.getCloudSiteId(),
- // req.getTenantId(),
- // req.getVnfType(),
- // req.getVnfVersion(),
- // req.getVfModuleType(),
- // "VOLUME", // request type is VOLUME
- // req.getVolumeGroupStackId(),
- // req.getVolumeGroupParams(),
- // req.getMsoRequest(),
- // outputs,
- // vnfRollback);
- vnfAdapter.updateVfModule (req.getCloudSiteId(),
- req.getTenantId(),
- //req.getVnfType(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVolumeGroupStackId(),
- "VOLUME",
- null,
- null,
- req.getVolumeGroupStackId(),
- req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(),
- req.getMsoRequest(),
- outputs,
- vnfRollback);
- }
- response = new UpdateVolumeGroupResponse(
- req.getVolumeGroupId(), req.getVolumeGroupStackId(),
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("UpdateVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @GET
- @Path("{aaiVolumeGroupId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("tenantId") String tenantId,
- @QueryParam("volumeGroupStackId") String volumeGroupStackId,
- @QueryParam("skipAAI") Boolean skipAAI,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId
- )
- {
- //This request responds synchronously only
- LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVolumeGroupResponse qryResp = new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
- if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfExists.value = true;
- vfModuleId.value = TESTING_KEYWORD;
- status.value = VnfStatus.ACTIVE;
- outputs.value = testMap();
- } else {
- vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs);
- }
- if (!vnfExists.value) {
- LOGGER.debug ("VNFVolumes not found");
- qryResp.setVolumeGroupStatus(status.value);
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value);
- qryResp.setVolumeGroupStatus(status.value);
- qryResp.setVolumeGroupOutputs(outputs.value);
- }
- LOGGER.debug("Query queryVNFVolumes exit");
- return Response
- .status(respStatus)
- .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {})
- .build();
- } catch (VnfException e) {
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e);
- VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- LOGGER.debug("Query queryVNFVolumes exit");
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {})
- .build();
- }
- }
- 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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2.java
deleted file mode 100644
index 423065c021..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.vnf;
-
-
-import java.util.HashMap;
-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.vnf.exceptions.VnfException;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- * For testing, call with cloudSiteId = ___TESTING___
- * To test exceptions, also set tenantId = ___TESTING___
- *
- * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify)
- * based on the target cloud.
- */
-@Path("/v2/volume-groups")
-public class VolumeAdapterRestV2 {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
- private static final String TESTING_KEYWORD = "___TESTING___";
-
- @POST
- @Path("")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createVNFVolumes(
- @QueryParam("mode") String mode,
- final CreateVolumeGroupRequest req)
- {
- LOGGER.debug("createVNFVolumes enter: " + req.toJsonString());
- CreateVNFVolumesTask task = new CreateVNFVolumesTask(req, mode);
- 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_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("createVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class CreateVNFVolumesTask implements Runnable {
- private final CreateVolumeGroupRequest req;
- private CreateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public CreateVNFVolumesTask(CreateVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<CreateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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 ("CreateVFModule VolumesTask start");
- try {
- // Synchronous Web Service Outputs
- Holder<String> stackId = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- String cloudsiteId = req.getCloudSiteId();
- if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) {
- String tenant = req.getTenantId();
- if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
- outputs.value = testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId);
- vnfAdapter.createVfModule(
- req.getCloudSiteId(), //cloudSiteId,
- req.getTenantId(), //tenantId,
- completeVnfVfModuleType, //vnfType,
- req.getVnfVersion(), //vnfVersion,
- req.getVolumeGroupName(), //vnfName,
- "VOLUME", //requestType,
- null, //volumeGroupHeatStackId,
- null, //baseVfHeatStackId,
- req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(), //inputs,
- req.getFailIfExists(), //failIfExists,
- req.getSuppressBackout(), //backout,
- req.getMsoRequest(), // msoRequest,
- stackId,
- outputs,
- vnfRollback);
- }
-
- VolumeGroupRollback rb = new VolumeGroupRollback(
- req.getVolumeGroupId(),
- stackId.value,
- vnfRollback.value.getVnfCreated(),
- req.getTenantId(),
- req.getCloudSiteId(),
- req.getMsoRequest(),
- req.getMessageId());
-
- response = new CreateVolumeGroupResponse(
- req.getVolumeGroupId(),
- stackId.value,
- vnfRollback.value.getVnfCreated(),
- outputs.value,
- rb,
- req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(
- 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 ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @QueryParam("mode") String mode,
- final DeleteVolumeGroupRequest req
- )
- {
- LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req, mode);
- 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_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("deleteVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class DeleteVNFVolumesTask implements Runnable {
- private final DeleteVolumeGroupRequest req;
- private DeleteVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<DeleteVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("DeleteVNFVolumesTask start");
- String cloudSiteId = req.getCloudSiteId();
- try {
- if (! cloudSiteId.equals(TESTING_KEYWORD)) {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest());
- }
- response = new DeleteVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @DELETE
- @Path("{aaiVolumeGroupId}/rollback")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- final RollbackVolumeGroupRequest req
- )
- {
- LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(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_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug("rollbackVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class RollbackVNFVolumesTask implements Runnable {
- private final RollbackVolumeGroupRequest req;
- private RollbackVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
-
- public RollbackVNFVolumesTask(RollbackVolumeGroupRequest 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<RollbackVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("RollbackVNFVolumesTask start");
- try {
- VolumeGroupRollback vgr = req.getVolumeGroupRollback();
- VnfRollback vrb = new VnfRollback(
- vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true,
- vgr.getMsoRequest(), null, null, null, null);
-
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = VnfAdapterRestUtils.getVnfAdapterImpl(vrb.getMode(), vrb.getCloudSiteId());
- vnfAdapter.rollbackVnf(vrb);
- response = new RollbackVolumeGroupResponse(true, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("RollbackVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
-
- }
-
- @PUT
- @Path("{aaiVolumeGroupId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response updateVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @QueryParam("mode") String mode,
- final UpdateVolumeGroupRequest req
- )
- {
- LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString());
- if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
- return Response
- .status(HttpStatus.SC_BAD_REQUEST)
- .type(MediaType.TEXT_PLAIN)
- .entity("VolumeGroupId in URL does not match content")
- .build();
- }
- UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req, mode);
- 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_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e);
- return Response.serverError().build();
- }
- // send sync response (ACK) to caller
- LOGGER.debug ("updateVNFVolumes exit");
- return Response.status(HttpStatus.SC_ACCEPTED).build();
- }
- }
-
- public class UpdateVNFVolumesTask implements Runnable {
- private final UpdateVolumeGroupRequest req;
- private UpdateVolumeGroupResponse response = null;
- private VolumeGroupExceptionResponse eresp = null;
- private boolean sendxml;
- private String mode;
-
- public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req, String mode) {
- this.req = req;
- this.sendxml = true; // can be set with a field or header later
- this.mode = mode;
- }
- public int getStatusCode() {
- return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
- }
- public Object getGenericEntityResponse() {
- return (response != null)
- ? new GenericEntity<UpdateVolumeGroupResponse>(response) {}
- : new GenericEntity<VolumeGroupExceptionResponse>(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("UpdateVNFVolumesTask start");
- try {
- @SuppressWarnings("unused")
- Holder<Map<String, String>> outputs = new Holder<> ();
- Holder<VnfRollback> vnfRollback = new Holder<> ();
- String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
- LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType);
-
- if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
- outputs.value = testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, req.getCloudSiteId());
- vnfAdapter.updateVfModule (req.getCloudSiteId(),
- req.getTenantId(),
- //req.getVnfType(),
- completeVnfVfModuleType,
- req.getVnfVersion(),
- req.getVolumeGroupStackId(),
- "VOLUME",
- null,
- null,
- req.getVolumeGroupStackId(),
- req.getModelCustomizationUuid(),
- req.getVolumeGroupParams(),
- req.getMsoRequest(),
- outputs,
- vnfRollback);
- }
- response = new UpdateVolumeGroupResponse(
- req.getVolumeGroupId(), req.getVolumeGroupStackId(),
- outputs.value, req.getMessageId());
- } catch (VnfException e) {
- LOGGER.debug("Exception :",e);
- eresp = new VolumeGroupExceptionResponse(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("UpdateVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
- }
- }
-
- @GET
- @Path("{aaiVolumeGroupId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryVNFVolumes(
- @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("tenantId") String tenantId,
- @QueryParam("volumeGroupStackId") String volumeGroupStackId,
- @QueryParam("skipAAI") Boolean skipAAI,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId,
- @QueryParam("mode") String mode
- )
- {
- //This request responds synchronously only
- LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId);
- MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
-
- try {
- int respStatus = HttpStatus.SC_OK;
- QueryVolumeGroupResponse qryResp = new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vfModuleId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
- if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
- if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
- throw new VnfException("testing.");
- }
- vnfExists.value = true;
- vfModuleId.value = TESTING_KEYWORD;
- status.value = VnfStatus.ACTIVE;
- outputs.value = testMap();
- } else {
- // Support different Adapter Implementations
- MsoVnfAdapter vnfAdapter = VnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId);
- vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs);
- }
- if (!vnfExists.value) {
- LOGGER.debug ("VNFVolumes not found");
- qryResp.setVolumeGroupStatus(status.value);
- respStatus = HttpStatus.SC_NOT_FOUND;
- } else {
- LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value);
- qryResp.setVolumeGroupStatus(status.value);
- qryResp.setVolumeGroupOutputs(outputs.value);
- }
- LOGGER.debug("Query queryVNFVolumes exit");
- return Response
- .status(respStatus)
- .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {})
- .build();
- } catch (VnfException e) {
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e);
- VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
- LOGGER.debug("Query queryVNFVolumes exit");
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {})
- .build();
- }
- }
- 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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java
deleted file mode 100644
index 79ea5bd9a7..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfAlreadyExists.java
+++ /dev/null
@@ -1,42 +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.vnf.exceptions;
-
-
-
-import javax.xml.ws.WebFault;
-
-/**
- * This class reports an exception when trying to create a VNF when another
- * VNF of the same name already exists in the target cloud/tenant. Note that
- * the createVnf method suppresses this exception by default.
- *
- *
- */
-@WebFault (name="VnfAlreadyExists", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf")
-public class VnfAlreadyExists extends VnfException {
-
- private static final long serialVersionUID = 1L;
-
- public VnfAlreadyExists (String name, String cloudId, String tenantId, String vnfId) {
- super("Resource " + name + " already exists in cloud/tenant " + cloudId + "/" + tenantId + " with ID " + vnfId);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java
deleted file mode 100644
index d265f526c3..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfException.java
+++ /dev/null
@@ -1,80 +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.vnf.exceptions;
-
-
-
-import javax.xml.ws.WebFault;
-
-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 VNF related exceptions on create, delete, query.
- *
- *
- */
-@WebFault (name="VnfException", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf")
-public class VnfException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- private VnfExceptionBean faultInfo;
-
- public VnfException (String msg) {
- super(msg);
- faultInfo = new VnfExceptionBean (msg);
- }
-
- public VnfException (Throwable e) {
- super(e);
- faultInfo = new VnfExceptionBean (e.getMessage());
- }
-
- public VnfException (String msg, Throwable e) {
- super (msg, e);
- faultInfo = new VnfExceptionBean (msg);
- }
-
- public VnfException (String msg, MsoExceptionCategory category) {
- super(msg);
- faultInfo = new VnfExceptionBean (msg, category);
- }
-
- public VnfException (String msg, MsoExceptionCategory category, Throwable e) {
- super (msg, e);
- faultInfo = new VnfExceptionBean (msg, category);
- }
-
- public VnfException (MsoException e) {
- super (e);
- faultInfo = new VnfExceptionBean (e.getContextMessage(), e.getCategory());
- }
-
- public VnfExceptionBean getFaultInfo() {
- return faultInfo;
- }
-
- public void setFaultInfo(VnfExceptionBean faultInfo) {
- this.faultInfo = faultInfo;
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java
deleted file mode 100644
index 0a8c08cfd1..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfExceptionBean.java
+++ /dev/null
@@ -1,74 +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.vnf.exceptions;
-
-
-import java.io.Serializable;
-
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * Jax-WS Fault Bean for Vnf Exception
- */
-public class VnfExceptionBean implements Serializable {
-
- private static final long serialVersionUID = -5699310749783790095L;
-
- private String message;
- private MsoExceptionCategory category;
- private Boolean rolledBack;
-
- public VnfExceptionBean () {}
-
- public VnfExceptionBean (String message) {
- // Create a default category to prevent null pointer exceptions
- this(message, MsoExceptionCategory.INTERNAL);
- }
-
- public VnfExceptionBean (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-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java
deleted file mode 100644
index 962b55f4f9..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/exceptions/VnfNotFound.java
+++ /dev/null
@@ -1,43 +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.vnf.exceptions;
-
-
-import javax.xml.ws.WebFault;
-
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-
-/**
- * This class reports an exception when trying to update a Network that does
- * not exist in the target cloud/tenant. Note that deleteNetwork suppresses
- * this exception (deletion of non-existent network is considered a success).
- *
- *
- */
-@WebFault (name="VnfNotFound", faultBean="org.openecomp.mso.adapters.vnf.exceptions.VnfExceptionBean", targetNamespace="http://org.openecomp.mso/vnf")
-public class VnfNotFound extends VnfException {
-
- private static final long serialVersionUID = 1L;
-
- public VnfNotFound (String cloudId, String tenantId, String vnfName) {
- super("Resource " + vnfName + " not found in cloud/tenant " + cloudId + "/" + tenantId);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java
deleted file mode 100755
index 367028c68b..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java
+++ /dev/null
@@ -1,90 +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.vdu.utils;
-
-import java.util.Map;
-
-/*
- * This Java bean class describes the template model of a VDU as distributed
- * by SDC to SO. It is composed of one or more templates, one of which must be
- * the main template,
- *
- * The structure of this class corresponds to the format in which the templates
- * and associated artifacts are represented in the SO Catalog.
- *
- * The map keys will be the "path" that is used to reference these artifacts within
- * the other templates. This may be relevant to how different VDU plugins package
- * the files for delivery to the sub-orchestrator.
- *
- * In the future, it is possible that pre-packaged blueprints (e.g. complete TOSCA CSARs)
- * could be stored in the catalog (and added to this structure).
- *
- * This bean is passed as an input to instantiateVdu and updateVdu.
- */
-
-public class VduBlueprint {
- String vduModelId;
- String mainTemplateName;
- Map<String,byte[]> templateFiles;
- Map<String,byte[]> attachedFiles;
-
- public String getVduModelId() {
- return vduModelId;
- }
-
- public void setVduModelId(String vduModelId) {
- this.vduModelId = vduModelId;
- }
-
- public String getMainTemplateName() {
- return mainTemplateName;
- }
-
- public void setMainTemplateName(String mainTemplateName) {
- this.mainTemplateName = mainTemplateName;
- }
-
- public Map<String, byte[]> getTemplateFiles() {
- return templateFiles;
- }
-
- public void setTemplateFiles(Map<String, byte[]> templateFiles) {
- this.templateFiles = templateFiles;
- }
-
- public Map<String, byte[]> getAttachedFiles() {
- return attachedFiles;
- }
-
- public void setAttachedFiles(Map<String, byte[]> attachedFiles) {
- this.attachedFiles = attachedFiles;
- }
-
- @Override
- public String toString() {
- return "VduInfo {" +
- "id='" + vduModelId + '\'' +
- "mainTemplateName='" + mainTemplateName + '\'' +
- '}';
- }
-
-}
-
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java
deleted file mode 100755
index 7ff7df62ad..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java
+++ /dev/null
@@ -1,130 +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.vdu.utils;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/*
- * This Java bean class relays VDU status information in a cloud-agnostic format.
- *
- * This bean is returned by all implementors of the MsoVduUtils interface operations
- * (instantiate, query, delete).
- */
-
-public class VduInfo {
- // Set defaults for everything
- private String vduInstanceId = "";
- private String vduInstanceName = "";
- private VduStatus status = VduStatus.NOTFOUND;
- private Map<String,Object> outputs = new HashMap<>();
- private Map<String,Object> inputs = new HashMap<>();
- private String lastAction;
- private String actionStatus;
- private String errorMessage;
-
- public VduInfo () {
- }
-
- // Add more constructors as appropriate
- //
-
- public VduInfo (String id, Map<String,Object> outputs) {
- this.vduInstanceId = id;
- if (outputs != null) this.outputs = outputs;
- }
-
- public VduInfo (String id) {
- this.vduInstanceId = id;
- }
-
- public VduInfo (String id, VduStatus status) {
- this.vduInstanceId = id;
- this.status = status;
- }
-
- public String getVnfInstanceId() {
- return vduInstanceId;
- }
-
- public void setVnfInstanceId (String id) {
- this.vduInstanceId = id;
- }
-
- public String getVnfInstanceName() {
- return vduInstanceName;
- }
-
- public void setVnfInstanceName (String name) {
- this.vduInstanceName = name;
- }
-
- public VduStatus getStatus() {
- return status;
- }
-
- public void setStatus (VduStatus status) {
- this.status = status;
- }
-
- public Map<String,Object> getOutputs () {
- return outputs;
- }
-
- public void setOutputs (Map<String,Object> outputs) {
- this.outputs = outputs;
- }
-
- public Map<String,Object> getInputs () {
- return inputs;
- }
-
- public void setInputs (Map<String,Object> inputs) {
- this.inputs = inputs;
- }
-
- public String getLastAction() {
- return lastAction;
- }
-
- public String getActionStatus() {
- return actionStatus;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- @Override
- public String toString() {
- return "VduInfo {" +
- "id='" + vduInstanceId + '\'' +
- "name='" + vduInstanceName + '\'' +
- ", inputs='" + inputs + '\'' +
- ", outputs='" + outputs + '\'' +
- ", lastAction='" + lastAction + '\'' +
- ", status='" + status + '\'' +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
- }
-
-}
-
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java
deleted file mode 100755
index 0b8b768bda..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java
+++ /dev/null
@@ -1,248 +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.vdu.utils;
-
-/**
- * This interface defines a common API for template-based cloud deployments.
- * The methods here should be adaptable for Openstack (Heat), Cloudify (TOSCA),
- * Aria (TOSCA), Multi-VIM (TBD), and others (e.g. Azure Resource Manager).
- *
- * The deployed instances are referred to here as Virtual Deployment Units (VDUs).
- * The package of templates that define a give VDU is referred to as its blueprint.
- *
- * Template-based orchestrators all follow a similar template/blueprint model.
- * - One main template that is the top level definition
- * - Optional nested templates referenced/included by the main template
- * - Optional files attached to the template package, typically containing
- * configuration files, install scripts, orchestration scripts, etc.
- *
- * The main template also defines the required inputs for creating a new instance,
- * and output values exposed by successfully deployed instances. Inputs and outputs
- * may include simple or complex (JSON) data types.
- *
- * Each implementation of this interface is expected to understand the MSO CloudConfig
- * to obtain the credentials for its sub-orchestrator and the targeted cloud.
- * The sub-orchestrator may have different credentials from the cloud (e.g. an Aria
- * instance in front of an Openstack cloud) or they may be the same (e.g. Heat)
- */
-import java.util.Map;
-
-import org.openecomp.mso.openstack.exceptions.MsoException;
-
-public interface VduPlugin {
-
- /**
- * The instantiateVdu interface deploys a new VDU instance from a blueprint package.
- * The templates and files in the blueprint may be pre-installed where supported
- * (e.g. in Cloudify or Aria), or may be passed in directly (e.g. for Heat). These
- * files are expressed as byte arrays, though only text files are expected from ASDC.
- *
- * For some VIMs, this may be a single command (e.g. Heat -> create stack) or may
- * require a series of API calls (e.g. Cloudify -> upload blueprint, create deployment,
- * execute install workflow). These details are hidden within the implementation.
- * The instantiation should be fully completed before returning. On failures, this
- * method is expected to back out the attempt, leaving the cloud in its previous state.
- *
- * It is expected that parameters have been validated and contain at minimum the
- * required parameters for the given template with no extra parameters.
- *
- * The VDU name supplied by the caller will be globally unique, and identify the artifact
- * in A&AI. Inventory is managed by the higher levels invoking this function.
- *
- * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry.
- * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by
- * cloud provider, but every cloud supports some sort of tenant partitioning.
- * @param vduInstanceName A unique name for the VDU instance to create
- * @param vduBlueprint Object containing the collection of templates and files that comprise
- * the blueprint for this VDU.
- * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects.
- * @param environmentFile A file containing default parameter name/value pairs. This is
- * primarily for Heat, though ASDC may create a similar file for other orchestrators.
- * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled
- * @param suppressBackout Flag to preserve the deployment on install Failure. Should normally
- * be False except in troubleshooting/debug cases
- *
- * @return A VduInfo object
- * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs.
- * Various subclasses of MsoException may be thrown.
- */
- public VduInfo instantiateVdu (
- String cloudSiteId,
- String tenantId,
- String vduInstanceName,
- VduBlueprint vduBlueprint,
- Map <String, ?> inputs,
- String environmentFile,
- int timeoutMinutes,
- boolean suppressBackout)
- throws MsoException;
-
-
- /**
- * Query a deployed VDU instance. This call will return a VduInfo object, or null
- * if the deployment does not exist.
- *
- * Some VIM orchestrators identify deployment instances by string UUIDs, and others
- * by integers. In the latter case, the ID will be passed in as a numeric string.
- *
- * The returned VduInfo object contains the input and output parameter maps,
- * as well as other properties of the deployment (name, status, last action, etc.).
- *
- * @param cloudSiteId The target cloud to query for the VDU.
- * @param tenantId The cloud tenant in which to query
- * @param vduInstanceId The ID of the deployment to query
- *
- * @return A VduInfo object
- * @throws MsoException Thrown if the VIM/sub-orchestrator API calls fail.
- * Various subclasses of MsoException may be thrown.
- */
- public VduInfo queryVdu (
- String cloudSiteId,
- String tenantId,
- String vduInstanceId)
- throws MsoException;
-
-
- /**
- * Delete a VDU instance by ID. If the VIM sub-orchestrator supports pre-installation
- * of blueprints, the blueprint itself may remain installed. This is recommended, since
- * other VDU instances may be using it.
- *
- * Some VIM orchestrators identify deployment instances by string UUIDs, and others
- * by integers. In the latter case, the ID will be passed in as a numeric string.
- *
- * For some VIMs, deletion may be a single command (e.g. Heat -> delete stack) or a
- * series of API calls (e.g. Cloudify -> execute uninstall workflow, delete deployment).
- * These details are hidden within the implementation. The deletion should be fully
- * completed before returning.
- *
- * The successful return is a VduInfo object which contains the state of the object just prior
- * to deletion, with a status of DELETED. If the deployment was not found, the VduInfo object
- * should be empty (with a status of NOTFOUND). There is no rollback from a successful deletion.
- *
- * A deletion failure will result in an undefined deployment state - the components may
- * or may not have been all or partially uninstalled, so the resulting deployment must
- * be considered invalid.
- *
- * @param cloudSiteId The target cloud from which to delete the VDU.
- * @param tenantId The cloud tenant in which to delete the VDU.
- * @param vduInstanceId The unique id of the deployment to delete.
- * @param timeoutMinutes Timeout after which the delete action will be cancelled
- * @param keepBlueprintLoaded Flag to also delete the blueprint
- *
- * @return A VduInfo object, representing the state of the instance just prior to deletion.
- *
- * @throws MsoException Thrown if the API calls fail or if a timeout occurs.
- * Various subclasses of MsoException may be thrown.
- */
- public VduInfo deleteVdu (
- String cloudSiteId,
- String tenantId,
- String vduInstanceId,
- int timeoutMinutes,
- boolean keepBlueprintLoaded)
- throws MsoException;
-
-
- /**
- * The updateVdu interface attempts to update a VDU in-place, using either new inputs or
- * a new model definition (i.e. updated templates/blueprints). This depends on the
- * capabilities of the targeted sub-orchestrator, as not all implementations are expected
- * to support this ability. It is primary included initially only for Heat.
- *
- * It is expected that parameters have been validated and contain at minimum the required
- * parameters for the given template with no extra parameters. The VDU instance name cannot
- * be updated.
- *
- * The update should be fully completed before returning. The successful return is a
- * VduInfo object containing the updated VDU state.
- *
- * An update failure will result in an undefined deployment state - the components may
- * or may not have been all or partially modified, deleted, recreated, etc. So the resulting
- * VDU must be considered invalid.
- *
- * @param cloudSiteId The target cloud for the VDU. Maps to a CloudConfig entry.
- * @param tenantId The cloud tenant in which to deploy the VDU. The meaning may differ by
- * cloud provider, but every cloud supports some sort of tenant partitioning.
- * @param vduInstanceId The unique ID for the VDU instance to update.
- * @param vduBlueprint Object containing the collection of templates and files that comprise
- * the blueprint for this VDU.
- * @param inputs A map of key/value inputs. Values may be strings, numbers, or JSON objects.
- * @param environmentFile A file containing default parameter name/value pairs. This is
- * primarily for Heat, though ASDC may create a similar file for other orchestrators.
- * @param timeoutMinutes Timeout after which the instantiation attempt will be cancelled
- *
- * @return A VduInfo object
- * @throws MsoException Thrown if the sub-orchestrator API calls fail or if a timeout occurs.
- * Various subclasses of MsoException may be thrown.
- */
- public VduInfo updateVdu (
- String cloudSiteId,
- String tenantId,
- String vduInstanceId,
- VduBlueprint vduBlueprint,
- Map <String, ?> inputs,
- String environmentFile,
- int timeoutMinutes)
- throws MsoException;
-
-
- /**
- * Check if a blueprint package has been installed in the sub-orchestrator and available
- * for use at a targeted cloud site. If the specific sub-orchestrator does not support
- * pre-installation, then those implementations should always return False.
- *
- * @param cloudSiteId The cloud site where the blueprint is needed
- * @param vduModelId Unique ID of the VDU model to query
- *
- * @throws MsoException Thrown if the API call fails.
- */
- public boolean isBlueprintLoaded (String cloudSiteId, String vduModelId)
- throws MsoException;
-
-
- /**
- * Install a blueprint package to the target sub-orchestrator for a cloud site.
- * The blueprints currently must be structured as a single directory with all of the
- * required files. One of those files is designated the "main file" for the blueprint.
- * Files are provided as byte arrays, though expect only text files will be distributed
- * from ASDC and stored by MSO.
- *
- * @param cloudSiteId The cloud site where the blueprint is needed
- * @param vduBlueprint Object containing the collection of templates and files that comprise
- * the blueprint for this VDU.
- * @param failIfExists Flag to return an error if blueprint already exists
- *
- * @throws MsoException Thrown if the API call fails.
- */
- public void uploadBlueprint (String cloudSiteId,
- VduBlueprint vduBlueprint,
- boolean failIfExists)
- throws MsoException;
-
- /**
- * Indicator that this VIM sub-orchestrator implementation supports independent upload
- * of blueprint packages. Each implementation should return a constant value.
- *
- * @returns True if the sub-orchestrator supports blueprint pre-installation (upload).
- */
- public boolean blueprintUploadSupported ();
-
-}
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java
deleted file mode 100755
index eaf7c4f14f..0000000000
--- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java
+++ /dev/null
@@ -1,37 +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.vdu.utils;
-
-
-/*
- * Enum status values to capture the state of a generic (cloud-agnostic) VDU.
- */
-public enum VduStatus {
- NOTFOUND,
- INSTANTIATING,
- INSTANTIATED,
- DELETING,
- DELETED, // Note - only returned in success response to deleteVdu call.
- UPDATING,
- FAILED,
- UNKNOWN
-}
-
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java b/adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java
index ffa6bcd961..c3d9cca0e9 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.vdu.mapper;
+package org.onap.so.adapters.vdu.mapper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -29,15 +29,15 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.openecomp.mso.adapters.vdu.VduArtifact;
-import org.openecomp.mso.adapters.vdu.VduArtifact.ArtifactType;
-import org.openecomp.mso.adapters.vdu.VduModelInfo;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatEnvironment;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.adapters.vdu.VduArtifact;
+import org.onap.so.adapters.vdu.VduArtifact.ArtifactType;
+import org.onap.so.adapters.vdu.VduModelInfo;
+import org.onap.so.db.catalog.CatalogDatabase;
+import org.onap.so.db.catalog.beans.HeatEnvironment;
+import org.onap.so.db.catalog.beans.HeatFiles;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java
deleted file mode 100644
index 445ca54c21..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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
- *l
- * 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.vnf;
-
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertTrue;
-
-public class BpelRestClientTest {
-
- @Test
- public void testBpelRestClient() {
-
- BpelRestClient test = new BpelRestClient();
-
- assertEquals(test.getSocketTimeout(),5);
- assertEquals(test.getConnectTimeout(),5);
- assertEquals(test.getRetryCount(),5);
- test.setRetryCount(6);
- assertEquals(test.getRetryCount(),6);
- assertEquals(test.getRetryInterval(),-15);
- test.setRetryInterval(5);
- assertEquals(test.getRetryInterval(),5);
- test.setCredentials("credentials");
- assertEquals(test.getCredentials(),"credentials");
- test.setRetryList("1, 2, 3");
- assertEquals(test.getRetryList(),"1, 2, 3");
- assertEquals(test.getLastResponseCode(),0);
- assertEquals(test.getLastResponse(),"");
- assertTrue(test.bpelPost("bpelStr","url",true));
-
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/HealthCheckHandlerTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/HealthCheckHandlerTest.java
deleted file mode 100644
index 12e2fa04e5..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/HealthCheckHandlerTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.vnf;
-
-import org.junit.Test;
-
-public class HealthCheckHandlerTest {
-
- HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
-
- @Test(expected = ClassFormatError.class)
- public void healthcheckTest() throws Exception {
- healthCheckHandler.healthcheck("req-123");
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
deleted file mode 100644
index b00b7a0e36..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImplTest.java
+++ /dev/null
@@ -1,114 +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.vnf;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-
-public class MsoVnfAdapterAsyncImplTest {
-
- @Test
- public void healthCheckVNFTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- instance.healthCheckA();
- }
-
- @Test
- public void createVNFTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
-
- instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId",
- null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.updateVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, "messageId", msoRequest,
- "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryVnfTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.queryVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
- "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
- "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void rollbackVnfTest() {
- MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
- VnfRollback vnfRollBack = new VnfRollback();
- vnfRollBack.setCloudSiteId("mdt1");
- vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e");
- vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff");
- try {
- instance.rollbackVnfA(vnfRollBack, "messageId",
- "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
- } catch (Exception e) {
-
- }
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java
deleted file mode 100644
index bdf42a19a2..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java
+++ /dev/null
@@ -1,542 +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.vnf;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import javax.xml.ws.Holder;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.mockito.Mock;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloudify.exceptions.MsoCloudifyException;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class MsoVnfAdapterImplTest {
-
- @InjectMocks
- MsoVnfAdapterImpl msoVnfAdapter;
- @Mock
- MsoHeatUtils heat;
-
- @Before
- public void setup() throws MsoCloudIdentityNotFound{
- ClassLoader classLoader = MsoVnfAdapterImplTest.class.getClassLoader();
- String cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath();
- CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
- cloudConfigFactory.initializeCloudConfig(cloudConfigJsonFilePath, 1);
- msoVnfAdapter = new MsoVnfAdapterImpl(new MsoPropertiesFactory(), cloudConfigFactory);
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void updateVnf() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- msoVnfAdapter.updateVnf("cloudsite", "tenantid", "vfw", "v1", "test",
- "update", "heatid", new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
- Assert.assertTrue(true);
- }
-
-
- @Test(expected = VnfException.class)
- public void nullRequestCreateVnf() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
-
- }
-
- @Test(expected = VnfAlreadyExists.class)
- public void createVnfInProgress() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.INIT);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
-
- }
-
- @Test(expected = VnfAlreadyExists.class)
- public void createVnfFailed() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.FAILED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
-
- }
-
- @Test(expected = VnfAlreadyExists.class)
- public void createVnfUnknown() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.UNKNOWN);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
-
- }
-
- @Test(expected = VnfAlreadyExists.class)
- public void createVnfCreatedAndFail() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, true, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
-
- }
-
- @Test
- public void createVnfCreatedAndContinue() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void createVnfNestedStackException() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void createVnfNestedStackNotFound() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void createVnfBaseNestedStackFailed() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Map<String,Object> nestedMap = new HashMap();
- nestedMap.put("key",new Integer(3));
- StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
- StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void createVnfBaseNestedStackNotFound() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
- StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void createVnfBaseNestedStackSuc() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
- StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
- StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
- msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
- "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
- }
-
- @Test
- public void queryVnfNullPoinerExceptionTest() throws Exception {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- Mockito.reset(heat);
- msoVnfAdapter.queryVnf("cloudSiteId",
- "tenantId",
- "vnfName",
- msoRequest,
- new Holder<>(),
- new Holder<>(),
- new Holder<>(),
- new Holder<>());
- Assert.assertFalse(false);
- }
-
- @Test
- public void rollbackVnfCloudSiteInfoNotAvail() throws Exception {
- VnfRollback rollback = new VnfRollback();
- rollback.setVnfId("vnfid");
- rollback.setVfModuleStackId("stackid");
- rollback.setCloudSiteId("11234");
- rollback.setTenantId("234");
-
- msoVnfAdapter.rollbackVnf(rollback);
- Assert.assertFalse(false);
- }
-
- @Test
- public void healthCheckVNFTest() {
- MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
- instance.healthCheck();
- }
-
- @Test
- public void createVnfTest() {
- MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.createVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfNotFound() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
-
-
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfFailed() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
-
-
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfNestedStackNotFound() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedstackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedstackInfo);
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfNestedStackFailed() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfNestedBaseStackNotFound() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedBaseStackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void updateVnfNestedBaseStackFailed() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = NullPointerException.class)
- public void updateVnfNestedBaseStackSuc() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
- StackInfo nestedBaseStackInfo = new StackInfo("test", HeatStatus.CREATED);
- Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
- msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
- new Holder<>());
- }
-
- @Test
- public void deleteVnfTest() {
- MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfReturnJsonNodeStack() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Map<String,Object> stackOutputs = new HashMap<>();
- JsonNode node = Mockito.mock(JsonNode.class);
- stackOutputs.put("key",node);
- Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
- msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<>());
- }
-
- @Test
- public void deleteVnfReturnLinkedHashMapStack() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Map<String,Object> stackOutputs = new HashMap<>();
- LinkedHashMap<String,Object> node = Mockito.mock(LinkedHashMap.class);
- stackOutputs.put("key",node);
- Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
- msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<>());
- }
-
- @Test
- public void deleteVnfReturnIntegerStack() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Map<String,Object> stackOutputs = new HashMap<>();
- Integer node = new Integer(2);
- stackOutputs.put("key",node);
- Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
- msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<>());
- }
-
- @Test
- public void deleteVnfReturnOtherStack() throws Exception{
-
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- Map<String,Object> stackOutputs = new HashMap<>();
- List<String> node = Mockito.mock(List.class);
- stackOutputs.put("key",node);
- Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
- msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<>());
- }
-
-
-
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
deleted file mode 100644
index 98c40a4b98..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * 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.vnf;
-
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.properties.MsoPropertiesException;
-
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-import java.util.Map;
-
-public class MsoVnfCloudifyAdapterImplTest {
-
- @Test(expected = NullPointerException.class)
- public void queryVnfNullPointerExceptionTest() throws Exception {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.queryVnf("siteid", "1234", "vfname",
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void deleteVnfVnfExceptionTest() throws Exception {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVnf("12344", "234", "vnfname", msoRequest);
-
- }
-
- @Test
- public void rollbackVnf() throws Exception {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test(expected = VnfException.class)
- public void createVfModuleVnfException() throws Exception {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "123", "vf", "v1", "module-005", "create", "3245", "234", "123", new HashMap<>(), true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void updateVfModuleVnfException() throws Exception {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.updateVfModule("123", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234", new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
- }
-
- @Test
- public void healthCheckVNFTest() {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- instance.healthCheck();
- }
-
- @Test
- public void createVnfTest() {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.createVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
-
- map.put("key1", "value1");
- try {
- instance.updateVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfTest() {
- MsoVnfCloudifyAdapterImpl instance = new MsoVnfCloudifyAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
- } catch (Exception e) {
-
- }
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImplTest.java
deleted file mode 100644
index 37ca4f762a..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * 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.vnf;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-
-public class MsoVnfPluginAdapterImplTest {
-
- @Test(expected = NullPointerException.class)
- public void queryVnfNullPointerExceptionTest() throws Exception {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.queryVnf("siteid", "1234", "vfname",
- msoRequest, new Holder<>(), new Holder<>(), new Holder<>(),
- new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void deleteVnfVnfExceptionTest() throws Exception {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.deleteVnf("12344", "234", "vnfname", msoRequest);
-
- }
-
- @Test
- public void rollbackVnf() throws Exception {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setModelCustomizationUuid("1234");
- vnfRollback.setVfModuleStackId("2134");
- vnfRollback.setVnfId("123");
- vnfRollback.setModelCustomizationUuid("1234");
-
- instance.rollbackVnf(vnfRollback);
- }
-
- @Test(expected = VnfException.class)
- public void createVfModuleVnfException() throws Exception {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.createVfModule("123", "123", "vf", "v1", "module-005", "create", "3245", "234", "123", new HashMap<>(), true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test(expected = VnfException.class)
- public void updateVfModuleVnfException() throws Exception {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- instance.updateVfModule("123", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234", new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
- }
-
- @Test
- public void healthCheckVNFTest() {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- instance.healthCheck();
- }
-
- @Test
- public void createVnfTest() {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
- map.put("key1", "value1");
- try {
- instance.createVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
- }
- }
-
- @Test
- public void updateVnfTest() {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
-
- Map<String, String> map = new HashMap<>();
-
- map.put("key1", "value1");
- try {
- instance.updateVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(),
- new Holder<>());
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteVnfTest() {
- MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId("12345");
- msoRequest.setServiceInstanceId("12345");
- try {
- instance.deleteVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
- } catch (Exception e) {
-
- }
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java
deleted file mode 100644
index 06a4cb3307..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java
+++ /dev/null
@@ -1,121 +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.vnf;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-import org.openecomp.mso.openstack.beans.StackInfo;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class QueryTest {
-
- @Test
- public void testQueryCreatedVnf() throws VnfException, MsoException {
- {
- StackInfo info = new StackInfo("stackName", HeatStatus.CREATED);
- MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
- vnfAdapter.heat = Mockito.mock(MsoHeatUtils.class);
- when(vnfAdapter.heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertTrue(vnfExists.value);
- }
- }
-
- @Test
- public void testQueryNotFoundVnf() throws VnfException, MsoException {
- {
- StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND);
- MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
- vnfAdapter.heat = Mockito.mock(MsoHeatUtils.class);
- when(vnfAdapter.heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
-
- assertFalse(vnfExists.value);
- }
- }
-
- @Test(expected = VnfException.class)
- // @Ignore // 1802 merge
- public void testQueryVnfWithException() throws VnfException {
- {
- String propFile = MsoJavaProperties.class.getClassLoader().getResource("mso.properties").getPath();
- String cloudConfigJsonFilePath = MsoJavaProperties.class.getClassLoader().getResource("cloud_config.json")
- .getPath();
-
- MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory();
- CloudConfigFactory cloudConfigFact = new CloudConfigFactory();
- try {
- msoPropFactory.initializeMsoProperties("MSO_PROP_VNF_ADAPTER", propFile);
- cloudConfigFact.initializeCloudConfig(cloudConfigJsonFilePath, 1);
- } catch (org.openecomp.mso.properties.MsoPropertiesException e) {
- // System.err.println("!?!?!?!! mso config exception: " + e);
- // e.printStackTrace();
- } catch (org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound e) {
- // System.err.println("!?!?!?!! cloud config exception: " + e);
- // e.printStackTrace();
- }
-
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropFactory, cloudConfigFact);
-
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
- }
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VfRollbackTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VfRollbackTest.java
deleted file mode 100644
index 03de139b1d..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VfRollbackTest.java
+++ /dev/null
@@ -1,69 +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.vnf;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-public class VfRollbackTest {
- private VfRollback vfRollback = new VfRollback();
-
- @Test
- public void test() {
- vfRollback.setVnfId("vnfId");
- vfRollback.setTenantId("tenantId");
- vfRollback.setCloudSiteId("cloudId");
- vfRollback.setTenantCreated(true);
- vfRollback.setVnfCreated(true);
- vfRollback.setMsoRequest(null);
- vfRollback.setVolumeGroupName("volumeGroupName");
- vfRollback.setVolumeGroupId("volumeGroupId");
- vfRollback.setRequestType("requestType");
- vfRollback.setVolumeGroupHeatStackId("volumeGroupHeatStackId");
- vfRollback.setBaseGroupHeatStackId("baseGroupHeatStackId");
- vfRollback.setIsBase(true);
- vfRollback.setVfModuleStackId("vfModuleStackId");
- assert(vfRollback.getVnfId() != null);
- assert(vfRollback.getTenantId() != null);
- assert(vfRollback.getCloudSiteId() != null);
- assert(vfRollback.getVolumeGroupName() != null);
- assert(vfRollback.getVolumeGroupId() != null);
- assert(vfRollback.getRequestType() != null);
- assert(vfRollback.getVolumeGroupHeatStackId() != null);
- assert(vfRollback.getBaseGroupHeatStackId() != null);
- assert(vfRollback.getVfModuleStackId() != null);
- assertEquals(vfRollback.getVnfId(), "vnfId");
- assertEquals(vfRollback.getTenantId(),"tenantId");
- assertEquals(vfRollback.getCloudSiteId(), "cloudId");
- assertEquals(vfRollback.getTenantCreated(), true);
- assertEquals(vfRollback.getVnfCreated(), true);
- assertEquals(vfRollback.getMsoRequest(), null);
- assertEquals(vfRollback.getVolumeGroupName(), "volumeGroupName");
- assertEquals(vfRollback.getVolumeGroupId(), "volumeGroupId");
- assertEquals(vfRollback.getRequestType(), "requestType");
- assertEquals(vfRollback.getVolumeGroupHeatStackId(), "volumeGroupHeatStackId");
- assertEquals(vfRollback.getBaseGroupHeatStackId(), "baseGroupHeatStackId");
- assertEquals(vfRollback.isBase(), true);
- assertEquals(vfRollback.getVfModuleStackId(), "vfModuleStackId");
- }
-
- @Test
- public void testtoString() {
- assert(vfRollback.toString() != null);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2ExceptionTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2ExceptionTest.java
deleted file mode 100644
index 30936d05d8..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfAdapterRestV2ExceptionTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.vnf;
-
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
-
-public class VnfAdapterRestV2ExceptionTest {
-
-
-
- VnfAdapterRestV2 vnfAdapterRestV2 = new VnfAdapterRestV2();
-
- //TODO THESE ARE RAINY DAY TESTS, NEED TO WRITE THE SUNNY DAY ONES
- // @Test(expected = ClassFormatError.class)
- public void testHealthcheckFailForInvalidCase() throws Exception {
- try{
- vnfAdapterRestV2.healthcheck();
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
-
- // @Test(expected = ClassFormatError.class)
- public void deleteVfModuleClassFormatError() throws Exception {
- try{
- DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setVnfId("vnfid");
- deleteVfModuleRequest.setVfModuleId("moduleid");
- vnfAdapterRestV2.deleteVfModule("vnfid", "moduleid", "mode", deleteVfModuleRequest);
- }
- catch(Exception ex)
- { // EXCEPTION EXPECTED
- assert(true);
- }
-
- }
-
- // @Test(expected = NullPointerException.class)
- public void queryVfModuleNullPointerException() throws Exception {
- try{
- vnfAdapterRestV2.queryVfModule("vnfid", "moduleid", "cloudid", "teanantid", "vfmodulename", true, "requestid", "serviceinstanceid", "mode");
- }
- catch(Exception ex)
- { // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = ClassFormatError.class)
- public void createVfModuleClassFormatError() throws Exception {
- try{
- vnfAdapterRestV2.createVfModule("vnfid", "create", new CreateVfModuleRequest());
- }
- catch(Exception ex)
- { // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = ClassFormatError.class)
- public void updateVfModulClassFormatErrore() throws Exception {
- try{
- vnfAdapterRestV2.updateVfModule("vnfid", "moduleid", "mode", new UpdateVfModuleRequest());
- }
- catch(Exception ex)
- { // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = NullPointerException.class)
- public void rollbackVfModuleNullPointerException() throws Exception {
- try{
-
- vnfAdapterRestV2.rollbackVfModule("vnfid", "moduleid", new RollbackVfModuleRequest());
- }
- catch(Exception ex)
- {
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
-
-} \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java
deleted file mode 100644
index a807aafd24..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfCreateTest.java
+++ /dev/null
@@ -1,87 +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.vnf;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-
-public class VnfCreateTest {
- public final static void main (String args[])
- {
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- log ("Got a VnfAdapter");
-
- // Web Service Inputs
- String cloudId = "MT";
- String tenantName = "John_Test";
- String vnfType = "ApacheDemo";
- String vnfName = "AdapterTest";
- Map<String,String> inputs = new HashMap<>();
- inputs.put("vnf_id", "abc");
- inputs.put("extra", "whocares");
- inputs.put("private_subnet_gateway", "10.4.1.1");
- inputs.put("private_subnet_cidr", "10.4.1.0/29");
-
- // Web Service Outputs
- Holder<String> vnfId = new Holder<>();
- Holder<Map<String,String>> outputs = new Holder<>();
- Holder<VnfRollback> vnfRollback = new Holder<>();
-
- try {
- vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null,
- vnfId, outputs, vnfRollback);
- } catch (VnfException e) {
- log ("Got a Create Exception: " + e);
- System.exit(1);
- }
-
- log ("Created VNF, ID = " + vnfId.value);
- for (String key : outputs.value.keySet()) {
- log (" " + key + " = " + outputs.value.get(key));
- }
- if (vnfRollback.value != null)
- log (vnfRollback.value.toString());
-
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {}
-
- log ("Rolling Back VNF");
- try {
- vnfAdapter.rollbackVnf(vnfRollback.value);
- } catch (VnfException e) {
- log ("Got a Rollback Exception: " + e);
- }
- log ("VNF Rolled Back");
- }
-
- private static void log (String msg) {
- System.out.println (msg);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java
deleted file mode 100644
index a820202855..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfDeleteTest.java
+++ /dev/null
@@ -1,52 +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.vnf;
-
-
-
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-
-public class VnfDeleteTest {
- public final static void main (String args[])
- {
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- log ("Got a VnfAdapter");
-
- // Web Service Inputs
- String cloudId = "MT";
- String tenantName = "MSO_Test";
- String vnfName = "AdapterTest";
-
- try {
- vnfAdapter.deleteVnf(cloudId, tenantName, vnfName, null);
- } catch (VnfException e) {
- log ("Got an Exception: " + e);
- }
-
- log ("Deleted VNF");
- }
-
- private static void log (String msg) {
- System.out.println (msg);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java
deleted file mode 100644
index aca88f3352..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VnfQueryTest.java
+++ /dev/null
@@ -1,64 +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.vnf;
-
-
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
-import org.openecomp.mso.openstack.beans.VnfStatus;
-import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
-
-public class VnfQueryTest {
- public final static void main (String args[])
- {
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- log ("Got a VnfAdapter");
-
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String,String>> outputs = new Holder<>();
-
- try {
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
- vnfExists, vnfId, status, outputs);
- } catch (VnfException e) {
- log ("Got an Exception: " + e);
- }
-
- if (! vnfExists.value){
- log ("VNF Not Found");
- } else {
- log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value);
- }
- }
-
- private static void log (String msg) {
- System.out.println (msg);
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2ExceptionTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2ExceptionTest.java
deleted file mode 100644
index b353079165..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/VolumeAdapterRestV2ExceptionTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.vnf;
-
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
-
-public class VolumeAdapterRestV2ExceptionTest {
-
-//TODO THESE ARE RAINY DAY TESTS, NEED TO WRITE THE SUNNY DAY ONES
- VolumeAdapterRestV2 volumeAdapterRestV2 = new VolumeAdapterRestV2();
-
-
- //@Test(expected = ClassFormatError.class)
- public void createVNFVolumesClassFormatError() throws Exception {
- try{
- volumeAdapterRestV2.createVNFVolumes("mode", new CreateVolumeGroupRequest());
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = ClassFormatError.class)
- public void deleteVNFVolumesClassFormatError() throws Exception {
- try{
- volumeAdapterRestV2.deleteVNFVolumes("volumegrpid", "mode", new DeleteVolumeGroupRequest());
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = ClassFormatError.class)
- public void rollbackVNFVolumesClassFormatError() throws Exception {
- try{
- RollbackVolumeGroupRequest rollbackVolumeGroupRequest = new RollbackVolumeGroupRequest();
- VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback();
- volumeGroupRollback.setVolumeGroupId("grpid");
- rollbackVolumeGroupRequest.setVolumeGroupRollback(volumeGroupRollback);
- volumeAdapterRestV2.rollbackVNFVolumes("grpid", rollbackVolumeGroupRequest);
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = ClassFormatError.class)
- public void updateVNFVolumesClassFormatError() throws Exception {
- try{
- volumeAdapterRestV2.updateVNFVolumes("vgid", "mode", new UpdateVolumeGroupRequest());
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
- // @Test(expected = NullPointerException.class)
- public void queryVNFVolumesNullPointerException() throws Exception {
- try{
- volumeAdapterRestV2.queryVNFVolumes("vgid", "cloudid", "tenantid",
- "stackid", true, "test", "test", "test");
- }
- catch(Exception ex){
- // EXCEPTION EXPECTED
- assert(true);
- }
- }
-
-
-
-} \ No newline at end of file
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java
deleted file mode 100644
index 019ae1e3f9..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 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.vdu.utils;
-
-import static org.junit.Assert.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.vdu.utils.VduBlueprint;
-
-import org.junit.Assert;
-
-public class VduBlueprintTest {
-
- private VduBlueprint vduBlueprint;
-
- private Map<String, byte[]> templateFiles;
- private Map<String, byte[]> attachedFiles;
-
- @Before
- public void setUp() {
- vduBlueprint = new VduBlueprint();
- }
-
- @Test
- public void testGetVduModelId() {
- vduBlueprint.setVduModelId("vduModelId");
- Assert.assertNotNull(vduBlueprint.getVduModelId());
- Assert.assertEquals(vduBlueprint.getVduModelId(), "vduModelId");
- }
-
- @Test
- public void testGetMainTemplateName() {
- vduBlueprint.setMainTemplateName("MainTemplateName");
- Assert.assertNotNull(vduBlueprint.getMainTemplateName());
- Assert.assertEquals(vduBlueprint.getMainTemplateName(), "MainTemplateName");
- }
-
- @Test
- public void testGetTemplateFiles() {
- byte[] templateFileData = "some template file data".getBytes();
- templateFiles = new HashMap<>();
- templateFiles.put("templateKey1", templateFileData);
- vduBlueprint.setTemplateFiles(templateFiles);
- Assert.assertNotNull(vduBlueprint.getTemplateFiles());
- Assert.assertTrue(vduBlueprint.getTemplateFiles().containsKey("templateKey1"));
- Assert.assertTrue(vduBlueprint.getTemplateFiles().containsValue(templateFileData));
- }
-
- @Test
- public void testGetAttachedFiles() {
- byte[] attachedFileData = "some file data".getBytes();
- attachedFiles = new HashMap<>();
- attachedFiles.put("attachedKey1", attachedFileData);
- vduBlueprint.setAttachedFiles(attachedFiles);
- Assert.assertNotNull(vduBlueprint.getAttachedFiles());
- Assert.assertTrue(vduBlueprint.getAttachedFiles().containsKey("attachedKey1"));
- Assert.assertTrue(vduBlueprint.getAttachedFiles().containsValue(attachedFileData));
- }
-}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java
deleted file mode 100644
index 98a00033f7..0000000000
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 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.vdu.utils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class VduInfoTest {
-
- private VduInfo vduInfo;
- private VduStatus status = VduStatus.NOTFOUND;
- private Map<String, Object> outputs;
- private Map<String, Object> inputs;
-
- @Before
- public void setUp() {
- vduInfo = new VduInfo();
- }
-
- @Test
- public void testGetVnfInstanceId() {
- String vnfInstanceId = "vnfInstanceId";
- vduInfo.setVnfInstanceId(vnfInstanceId);
- Assert.assertNotNull(vduInfo.getVnfInstanceId());
- Assert.assertEquals(vduInfo.getVnfInstanceId(), "vnfInstanceId");
- }
-
- @Test
- public void testGetVnfInstanceName() {
- String vnfInstanceName = "vnfInstanceName";
- vduInfo.setVnfInstanceName(vnfInstanceName);
- Assert.assertNotNull(vduInfo.getVnfInstanceName());
- Assert.assertEquals(vduInfo.getVnfInstanceName(), "vnfInstanceName");
- }
-
- @Test
- public void testGetStatus() {
- vduInfo.setStatus(status);
- Assert.assertNotNull(vduInfo.getStatus());
- Assert.assertEquals(status, vduInfo.getStatus());
- }
-
- @Test
- public void testGetOutputs() {
- Object obj = new Object();
- String str = "some text";
- outputs = new HashMap<>();
- outputs.put(str, obj);
- vduInfo.setOutputs(outputs);
- Assert.assertNotNull(vduInfo.getOutputs());
- Assert.assertTrue(vduInfo.getOutputs().containsKey(str));
- Assert.assertTrue(vduInfo.getOutputs().containsValue(obj));
- }
-
- @Test
- public void testGetInputs() {
- Object obj = new Object();
- String str = "some text";
- inputs = new HashMap<>();
- inputs.put(str, obj);
- vduInfo.setInputs(inputs);
- Assert.assertNotNull(vduInfo.getInputs());
- Assert.assertTrue(vduInfo.getInputs().containsKey(str));
- Assert.assertTrue(vduInfo.getInputs().containsValue(obj));
- }
-
-}
diff --git a/adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/adapters/mso-vnf-adapter/src/test/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index 1281d32948..0000000000
--- a/adapters/mso-vnf-adapter/src/test/resources/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-vnf-adapter/src/test/resources/cloud_config.json b/adapters/mso-vnf-adapter/src/test/resources/cloud_config.json
deleted file mode 100644
index ff24633f32..0000000000
--- a/adapters/mso-vnf-adapter/src/test/resources/cloud_config.json
+++ /dev/null
@@ -1,94 +0,0 @@
-{ "cloud_config": {
- "identity_services":
- {
- "MT_KEYSTONE":
- {
- "identity_url": "http://localhost:5000/v2.0",
- "mso_id": "john",
- "mso_pass": "FD205490A48D48475607C36B9AD902BF",
- "admin_tenant": "admin",
- "member_role": "_member_",
- "tenant_metadata": false,
- "identity_server_type": "KEYSTONE",
- "identity_authentication_type": "RACKSPACE_APIKEY"
- },
- "DAN_KEYSTONE":
- {
- "identity_url": "http://localhost:5000/v2.0",
- "mso_id": "mockId",
- "mso_pass": "BC59F80E38208A42ABB81ECCDD4FB3E4",
- "admin_tenant": "service",
- "member_role": "_member_",
- "tenant_metadata": false,
- "identity_server_type": "KEYSTONE",
- "identity_authentication_type": "USERNAME_PASSWORD"
- },
- "MTINJVCC101_DCP":
- {
- "identity_url": "http://localhost:5000/v2.0",
- "mso_id": "mockIdToo",
- "mso_pass": "95604B9EAAC4D77D74786FAE54177206",
- "admin_tenant": "service",
- "member_role": "admin",
- "tenant_metadata": true,
- "identity_server_type": "KEYSTONE",
- "identity_authentication_type": "USERNAME_PASSWORD"
- },
- "MTSNJA3DCP1":
- {
- "identity_url": "https://localhost:5000/v2.0",
- "mso_id": "mockIdToo",
- "mso_pass": "1491DE07AC9D716A7966BB8C2848F031",
- "admin_tenant": "service",
- "member_role": "admin",
- "tenant_metadata": true,
- "identity_server_type": "KEYSTONE",
- "identity_authentication_type": "USERNAME_PASSWORD"
- },
- "CS_service": {}
-
- },
- "cloud_sites":
- {
- "MT":
- {
- "region_id": "regionOne",
- "clli": "MT",
- "aic_version": "2.5",
- "identity_service_id": "MT_KEYSTONE"
- },
- "DAN":
- {
- "region_id": "RegionOne",
- "clli": "DAN",
- "aic_version": "2.5",
- "identity_service_id": "DAN_KEYSTONE"
- },
- "MTINJVCC101":
- {
- "region_id": "regionTwo",
- "clli": "MTINJVCC101",
- "aic_version": "2.5",
- "identity_service_id": "MTINJVCC101_DCP"
- },
- "MTSNJA4LCP1":
- {
- "region_id": "mtsnjlcp1",
- "clli": "MTSNJA4LCP1",
- "aic_version": "2.5",
- "identity_service_id": "MTSNJA3DCP1"
- },
- "CS":
- {
- "region_id": "clliRegion",
- "clli": "CS_clli",
- "aic_version": "2.5",
- "identity_service_id": "CS_service"
- }
- }
-}
-}
-
-
-
-
diff --git a/adapters/mso-vnf-adapter/src/test/resources/logback-test.xml b/adapters/mso-vnf-adapter/src/test/resources/logback-test.xml
deleted file mode 100644
index 238980e0c4..0000000000
--- a/adapters/mso-vnf-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>
diff --git a/adapters/mso-vnf-adapter/src/test/resources/mso.properties b/adapters/mso-vnf-adapter/src/test/resources/mso.properties
deleted file mode 100644
index d58521f1db..0000000000
--- a/adapters/mso-vnf-adapter/src/test/resources/mso.properties
+++ /dev/null
@@ -1,27 +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=========================================================
-###
-
-ecomp.mso.cloud.1.cloudId=MT
-ecomp.mso.cloud.1.keystoneUrl=http://localhost:5000/v2.0
-ecomp.mso.cloud.1.msoId=John
-ecomp.mso.cloud.1.publicNetId=FD205490A48D48475607C36B9AD902BF
-ecomp.mso.cloud.1.test=1234
-ecomp.mso.cloud.1.boolean=true
-ecomp.mso.cloud.1.enum=enum1