aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/pom.xml20
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java58
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java9
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java10
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java10
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java16
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java17
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java8
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java10
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java43
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java14
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java9
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java12
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java108
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java18
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java103
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java61
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java55
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java55
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java44
-rw-r--r--adapters/mso-adapters-rest-interface/pom.xml6
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/pom.xml8
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java198
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java14
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java28
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java72
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java72
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java30
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java28
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java30
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java10
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java16
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java4
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java2
-rw-r--r--adapters/mso-network-adapter-async-client/pom.xml6
-rw-r--r--adapters/mso-network-adapter/pom.xml14
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java1035
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java2
-rw-r--r--adapters/mso-requests-db-adapter/pom.xml10
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java8
-rw-r--r--adapters/mso-sdnc-adapter/pom.xml10
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java10
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java15
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java54
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java47
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java53
-rw-r--r--adapters/mso-tenant-adapter/pom.xml12
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java10
-rw-r--r--adapters/mso-vfc-adapter/pom.xml12
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java2
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java7
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java2
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java3
-rw-r--r--adapters/mso-vnf-adapter-async-client/pom.xml6
-rw-r--r--adapters/mso-vnf-adapter/pom.xml18
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java3
-rw-r--r--adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java689
-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/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java2
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java10
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java24
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java8
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java8
-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-workflow-message-adapter/pom.xml8
-rw-r--r--adapters/pom.xml4
79 files changed, 2688 insertions, 1299 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml
index dd1159f6d1..cd0a688018 100644
--- a/adapters/mso-adapter-utils/pom.xml
+++ b/adapters/mso-adapter-utils/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<name>mso-adapter-utils</name>
<description>Common MSO utilities, including Openstack client wrappers.</description>
@@ -44,32 +44,44 @@
<dependencies>
<dependency>
+<!--
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+-->
<groupId>org.openecomp.so.libs.openstack-java-sdk</groupId>
<artifactId>keystone-client</artifactId>
<version>${openstack.version}</version>
</dependency>
<dependency>
+<!--
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+-->
<groupId>org.openecomp.so.libs.openstack-java-sdk</groupId>
<artifactId>heat-client</artifactId>
<version>${openstack.version}</version>
</dependency>
<dependency>
+<!--
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+-->
<groupId>org.openecomp.so.libs.openstack-java-sdk</groupId>
<artifactId>quantum-client</artifactId>
<version>${openstack.version}</version>
</dependency>
<dependency>
+<!--
+ <groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId>
+-->
<groupId>org.openecomp.so.libs.openstack-java-sdk.client-connectors</groupId>
<artifactId>http-connector</artifactId>
<version>${openstack.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java
index 79fe8fda8e..445c135dab 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java
@@ -185,12 +185,12 @@ public class CloudConfigFactory implements Serializable {
StringBuffer response = new StringBuffer ();
response.append ("Cloud Sites:\n");
for (CloudSite site : cloudConfig.getCloudSites ().values ()) {
- response.append (site.toString () + "\n");
+ response.append(site.toString()).append("\n");
}
response.append ("\n\nCloud Identity Services:\n");
for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) {
- response.append (identity.toString () + "\n");
+ response.append(identity.toString()).append("\n");
}
return Response.status (200).entity (response).build ();
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java
index d0ba7e09fc..3dd4cbfc9c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java
@@ -23,28 +23,23 @@
package org.openecomp.mso.cloud;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
import java.security.GeneralSecurityException;
-
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoKeystoneUtils;
-import org.openecomp.mso.openstack.utils.MsoTenantUtils;
-import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory;
import org.openecomp.mso.cloud.authentication.AuthenticationMethodFactory;
import org.openecomp.mso.cloud.authentication.AuthenticationWrapper;
import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper;
import org.openecomp.mso.cloud.authentication.wrappers.UsernamePasswordWrapper;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
-
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoKeystoneUtils;
+import org.openecomp.mso.openstack.utils.MsoTenantUtils;
+import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory;
import org.openecomp.mso.utils.CryptoUtils;
-import com.woorea.openstack.keystone.model.Authentication;
/**
* JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity
@@ -143,15 +138,11 @@ public class CloudIdentity {
}
}
}
-
- public Authentication getAuthentication () throws MsoException {
+
+ public Authentication getAuthentication() {
if (this.getIdentityAuthenticationType() != null) {
- try {
return AuthenticationMethodFactory.getAuthenticationFor(this);
- } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | IOException | URISyntaxException e) {
- throw new MsoAdapterException("Could not retrieve authentication for " + this.identityAuthenticationType, e);
- }
- } else { // Fallback
+ } else {
return new UsernamePassword(this.getMsoId(), this.getMsoPass());
}
}
@@ -236,29 +227,18 @@ public class CloudIdentity {
public void setIdentityAuthenticationType(IdentityAuthenticationType identityAuthenticationType) {
this.identityAuthenticationType = identityAuthenticationType;
}
-
+
@Override
public String toString () {
- StringBuilder stringBuilder = new StringBuilder ();
- stringBuilder.append ("Cloud Identity Service: id=")
- .append (id)
- .append (", identityUrl=")
- .append (this.identityUrl)
- .append (", msoId=")
- .append (msoId)
- .append (", adminTenant=")
- .append (adminTenant)
- .append (", memberRole=")
- .append (memberRole)
- .append (", tenantMetadata=")
- .append (tenantMetadata)
- .append (", identityServerType=")
- .append (identityServerType == null ? "null" : identityServerType.toString())
- .append (", identityAuthenticationType=")
- .append (identityAuthenticationType == null ? "null" : identityAuthenticationType.toString());
-
- return stringBuilder.toString ();
- }
+ return "Cloud Identity Service: id=" + id +
+ ", identityUrl=" + this.identityUrl +
+ ", msoId=" + msoId +
+ ", adminTenant=" + adminTenant +
+ ", memberRole=" + memberRole +
+ ", tenantMetadata=" + tenantMetadata +
+ ", identityServerType=" + (identityServerType == null ? "null" : identityServerType.toString()) +
+ ", identityAuthenticationType=" + (identityAuthenticationType == null ? "null" : identityAuthenticationType.toString());
+ }
public static String encryptPassword (String msoPass) {
try {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java
index 85cb2967d6..c9be2c7949 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java
@@ -23,18 +23,13 @@
package org.openecomp.mso.cloud.authentication;
-import java.io.IOException;
-import java.net.URISyntaxException;
+import com.woorea.openstack.keystone.model.Authentication;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import org.openecomp.mso.cloud.CloudIdentity;
-import com.woorea.openstack.keystone.model.Authentication;
-
/**
* This factory manages all the wrappers associated to authentication types.
- *
*/
public final class AuthenticationMethodFactory {
@@ -58,7 +53,7 @@ public final class AuthenticationMethodFactory {
}
}
- public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException {
+ public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
throw new IllegalArgumentException("Cloud identity cannot be null");
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java
index 5cf5587481..e82306b6cd 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java
@@ -35,16 +35,6 @@ import com.woorea.openstack.keystone.model.Authentication;
*/
public class RackspaceAPIKeyWrapper extends AuthenticationWrapper {
- /**
- *
- */
- public RackspaceAPIKeyWrapper() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
- */
@Override
public Authentication getAuthentication(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java
index 5fd3e521f0..a1beabe564 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java
@@ -32,19 +32,9 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
/**
* This class implements the authentication wrapper for Openstack provided for
* user name and password authentication.
- *
*/
public class UsernamePasswordWrapper extends AuthenticationWrapper {
- /**
- *
- */
- public UsernamePasswordWrapper() {
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity)
- */
@Override
public Authentication getAuthentication(CloudIdentity cloudIdentity) {
if (cloudIdentity == null) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
index 2cda8f99e2..64460b20bb 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
@@ -139,15 +139,13 @@ public class NetworkInfo {
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("NetworkInfo{");
- sb.append("name='").append(name).append('\'');
- sb.append(", id='").append(id).append('\'');
- sb.append(", status=").append(status);
- sb.append(", provider='").append(provider).append('\'');
- sb.append(", vlans=").append(vlans);
- sb.append(", subnets=").append(subnets);
- sb.append('}');
- return sb.toString();
+ return "NetworkInfo{" + "name='" + name + '\'' +
+ ", id='" + id + '\'' +
+ ", status=" + status +
+ ", provider='" + provider + '\'' +
+ ", vlans=" + vlans +
+ ", subnets=" + subnets +
+ '}';
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java
index 600985e310..506b62994d 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/StackInfo.java
@@ -67,10 +67,8 @@ public class StackInfo {
if (stack.getStackStatus() == null) {
this.status = HeatStatus.INIT;
- } else if (heatStatusMap.containsKey(stack.getStackStatus())) {
- this.status = heatStatusMap.get(stack.getStackStatus());
} else {
- this.status = HeatStatus.UNKNOWN;
+ this.status = heatStatusMap.getOrDefault(stack.getStackStatus(), HeatStatus.UNKNOWN);
}
if (stack.getOutputs() != null) {
this.outputs = new HashMap<>();
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
index 8aa8d3f5e8..eead8439d4 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java
@@ -68,16 +68,13 @@ public class MsoOpenstackException extends MsoException
this.statusMessage = message;
this.errorDetail = detail;
}
-
+
@Override
- public String toString () {
- StringBuilder error = new StringBuilder();
- error.append("");
- error.append(statusCode);
- error.append(" ");
- error.append(statusMessage);
- error.append(": ");
- error.append(errorDetail);
- return error.toString();
+ public String toString() {
+ return statusCode +
+ " " +
+ statusMessage +
+ ": " +
+ errorDetail;
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
index 269f6b0cdf..7d6de317ad 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java
@@ -129,6 +129,7 @@ public class MsoCommonUtils {
Thread.sleep (retryDelay * 1000L);
} catch (InterruptedException e1) {
logger.debug ("Thread interrupted while sleeping", e1);
+ Thread.currentThread().interrupt();
}
}
else
@@ -144,6 +145,7 @@ public class MsoCommonUtils {
Thread.sleep (retryDelay * 1000L);
} catch (InterruptedException e1) {
logger.debug ("Thread interrupted while sleeping", e1);
+ Thread.currentThread().interrupt();
}
}
else
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
index 69da437797..04dbf523d0 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
@@ -65,11 +65,9 @@ public class MsoHeatEnvironmentEntry {
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("MsoHeatEnvironmentEntry{");
- sb.append("parameters=").append(parameters);
- sb.append(", resourceRegistryEntryRaw='").append(resourceRegistryEntryRaw).append('\'');
- sb.append('}');
- return sb.toString();
+ return "MsoHeatEnvironmentEntry{" + "parameters=" + parameters +
+ ", resourceRegistryEntryRaw='" + resourceRegistryEntryRaw + '\'' +
+ '}';
}
public String getRawEntry() {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
index a2e605f897..a0c9b7a105 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
@@ -59,12 +59,10 @@ public class MsoHeatEnvironmentResource {
@Override
public String toString() {
- StringBuilder str = new StringBuilder();
- str.append("\"");
- str.append(this.name);
- str.append("\": ");
- str.append(this.value);
- return str.toString();
+ return "\"" +
+ this.name +
+ "\": " +
+ this.value;
}
@Override
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
index acc6d72f63..6862492d7e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
@@ -143,7 +143,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
String tenantId,
String stackName,
String heatTemplate,
- Map <String, ? extends Object> stackInputs,
+ Map <String, ?> stackInputs,
boolean pollForCompletion,
int timeoutMinutes) throws MsoException {
// Just call the new method with the environment & files variable set to null
@@ -165,7 +165,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
String tenantId,
String stackName,
String heatTemplate,
- Map <String, ? extends Object> stackInputs,
+ Map <String, ?> stackInputs,
boolean pollForCompletion,
int timeoutMinutes,
String environment) throws MsoException {
@@ -188,7 +188,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
String tenantId,
String stackName,
String heatTemplate,
- Map <String, ? extends Object> stackInputs,
+ Map <String, ?> stackInputs,
boolean pollForCompletion,
int timeoutMinutes,
String environment,
@@ -211,7 +211,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
String tenantId,
String stackName,
String heatTemplate,
- Map <String, ? extends Object> stackInputs,
+ Map <String, ?> stackInputs,
boolean pollForCompletion,
int timeoutMinutes,
String environment,
@@ -275,7 +275,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
String tenantId,
String stackName,
String heatTemplate,
- Map <String, ? extends Object> stackInputs,
+ Map <String, ?> stackInputs,
boolean pollForCompletion,
int timeoutMinutes,
String environment,
@@ -886,7 +886,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
public Map <String, Object> validateStackParams (Map <String, Object> inputParams,
HeatTemplate heatTemplate) throws IllegalArgumentException {
// Check that required parameters have been supplied for this template type
- String missingParams = null;
+ StringBuilder missingParams = null;
List <String> paramList = new ArrayList <> ();
// TODO: Enhance DB to support defaults for Heat Template parameters
@@ -894,9 +894,9 @@ public class MsoHeatUtils extends MsoCommonUtils {
for (HeatTemplateParam parm : heatTemplate.getParameters ()) {
if (parm.isRequired () && !inputParams.containsKey (parm.getParamName ())) {
if (missingParams == null) {
- missingParams = parm.getParamName ();
+ missingParams = new StringBuilder(parm.getParamName());
} else {
- missingParams += "," + parm.getParamName ();
+ missingParams.append("," + parm.getParamName());
}
}
paramList.add (parm.getParamName ());
@@ -1106,11 +1106,8 @@ public class MsoHeatUtils extends MsoCommonUtils {
}
public boolean isExpired () {
- if (expires == null) {
- return true;
- }
+ return expires == null || System.currentTimeMillis() > expires.getTimeInMillis();
- return System.currentTimeMillis() > expires.getTimeInMillis();
}
}
@@ -1217,18 +1214,18 @@ public class MsoHeatUtils extends MsoCommonUtils {
} else {
for (String key : params.keySet()) {
if (params.get(key) instanceof String) {
- sb.append("\n" + key + "=" + (String) params.get(key));
+ sb.append("\n").append(key).append("=").append((String) params.get(key));
} else if (params.get(key) instanceof JsonNode) {
String jsonStringOut = this.convertNode((JsonNode)params.get(key));
- sb.append("\n" + key + "=" + jsonStringOut);
+ sb.append("\n").append(key).append("=").append(jsonStringOut);
} else if (params.get(key) instanceof Integer) {
String integerOut = "" + params.get(key);
- sb.append("\n" + key + "=" + integerOut);
+ sb.append("\n").append(key).append("=").append(integerOut);
} else {
try {
String str = params.get(key).toString();
- sb.append("\n" + key + "=" + str);
+ sb.append("\n").append(key).append("=").append(str);
} catch (Exception e) {
LOGGER.debug("Exception :",e);
}
@@ -1243,8 +1240,6 @@ public class MsoHeatUtils extends MsoCommonUtils {
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(), jpe);
} catch (Exception e) {
LOGGER.debug("Error converting json to string " + e.getMessage(), e);
}
@@ -1272,16 +1267,16 @@ public class MsoHeatUtils extends MsoCommonUtils {
int counter = 0;
sb.append("OUTPUTS:\n");
for (String key : outputs.keySet()) {
- sb.append("outputs[" + counter++ + "]: " + key + "=");
+ sb.append("outputs[").append(counter++).append("]: ").append(key).append("=");
Object obj = outputs.get(key);
if (obj instanceof String) {
- sb.append((String)obj +" (a string)");
+ sb.append((String) obj).append(" (a string)");
} else if (obj instanceof JsonNode) {
- sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)");
+ sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)");
} else if (obj instanceof java.util.LinkedHashMap) {
try {
String str = JSON_MAPPER.writeValueAsString(obj);
- sb.append(str + " (a java.util.LinkedHashMap)");
+ sb.append(str).append(" (a java.util.LinkedHashMap)");
} catch (Exception e) {
LOGGER.debug("Exception :",e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
@@ -1439,7 +1434,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
if (inputs == null) {
LOGGER.debug("convertInputMap - inputs is null - nothing to do here");
- return new HashMap<String, Object>();
+ return new HashMap<>();
}
LOGGER.debug("convertInputMap in MsoHeatUtils called, with " + inputs.size() + " inputs, and template " + template.getArtifactUuid());
@@ -1548,7 +1543,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
}
} else if ("boolean".equalsIgnoreCase(type)) {
String booleanString = inputs.get(key);
- Boolean aBool = new Boolean(booleanString);
+ Boolean aBool = Boolean.valueOf(booleanString);
if (alias)
newInputs.put(realName, aBool);
else
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java
index 2465b30eca..75bb00351c 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsWithUpdate.java
@@ -230,7 +230,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
if (haveFiles && haveHeatFiles) {
// Let's do this here - not in the bean
LOGGER.debug ("Found files AND heatFiles - combine and add!");
- Map <String, Object> combinedFiles = new HashMap <String, Object> ();
+ Map <String, Object> combinedFiles = new HashMap<>();
for (String keyString : files.keySet ()) {
combinedFiles.put (keyString, files.get (keyString));
}
@@ -358,23 +358,23 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
sb.append("(outputs is empty)");
return sb;
}
- Map<String, Object> outputs = new HashMap<String,Object>();
+ Map<String, Object> outputs = new HashMap<>();
for (Output outputItem : outputList) {
outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue());
}
int counter = 0;
sb.append("OUTPUTS:\n");
for (String key : outputs.keySet()) {
- sb.append("outputs[" + counter++ + "]: " + key + "=");
+ sb.append("outputs[").append(counter++).append("]: ").append(key).append("=");
Object obj = outputs.get(key);
if (obj instanceof String) {
- sb.append((String)obj +" (a string)");
+ sb.append((String) obj).append(" (a string)");
} else if (obj instanceof JsonNode) {
- sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)");
+ sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)");
} else if (obj instanceof java.util.LinkedHashMap) {
try {
String str = JSON_MAPPER.writeValueAsString(obj);
- sb.append(str + " (a java.util.LinkedHashMap)");
+ sb.append(str).append(" (a java.util.LinkedHashMap)");
} catch (Exception e) {
LOGGER.debug("Exception :", e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
@@ -428,8 +428,6 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
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(), jpe);
} catch (Exception e) {
LOGGER.debug("Error converting json to string " + e.getMessage(), e);
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java
index be36d67e0b..3b710032c1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java
@@ -209,7 +209,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map <String, String> metadata = new HashMap <String, String> ();
+ Map <String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService ().hasTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps);
@@ -255,7 +255,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map <String, String> metadata = new HashMap <String, String> ();
+ Map <String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService ().hasTenantMetadata ()) {
OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ());
Metadata tenantMetadata = executeAndRecordOpenstackRequest (request, msoProps);
@@ -567,11 +567,8 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
}
public boolean isExpired () {
- if (expires == null) {
- return true;
- }
+ return expires == null || System.currentTimeMillis() > expires.getTimeInMillis();
- return System.currentTimeMillis() > expires.getTimeInMillis();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java
index 50a594663e..9eba799e18 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java
@@ -63,7 +63,7 @@ public class MsoNeutronUtils extends MsoCommonUtils
// token will be used until it expires.
//
// The cache key is "tenantId:cloudId"
- private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<String,NeutronCacheEntry>();
+ private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<>();
// Fetch cloud configuration each time (may be cached in CloudConfig class)
private CloudConfig cloudConfig;
@@ -129,7 +129,7 @@ public class MsoNeutronUtils extends MsoCommonUtils
}
} else if (type == NetworkType.MULTI_PROVIDER) {
if (provider != null && vlans != null && vlans.size() > 0) {
- List<Segment> segments = new ArrayList<Segment>(vlans.size());
+ List<Segment> segments = new ArrayList<>(vlans.size());
for (int vlan : vlans) {
Segment segment = new Segment();
segment.setProviderPhysicalNetwork (provider);
@@ -297,7 +297,7 @@ public class MsoNeutronUtils extends MsoCommonUtils
}
} else if (type == NetworkType.MULTI_PROVIDER) {
if (provider != null && vlans != null && vlans.size() > 0) {
- List<Segment> segments = new ArrayList<Segment>(vlans.size());
+ List<Segment> segments = new ArrayList<>(vlans.size());
for (int vlan : vlans) {
Segment segment = new Segment();
segment.setProviderPhysicalNetwork (provider);
@@ -559,11 +559,7 @@ public class MsoNeutronUtils extends MsoCommonUtils
}
public boolean isExpired() {
- if (expires == null) {
- return true;
- }
-
- return System.currentTimeMillis() > expires.getTimeInMillis();
+ return expires == null || System.currentTimeMillis() > expires.getTimeInMillis();
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
index c227d72f0c..8002087ddd 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
@@ -27,6 +27,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -73,33 +74,32 @@ public class MsoYamlEditorWithEnvt {
if (resourceMap == null) {
return paramSet;
}
- Iterator <Entry <String, Object>> it = resourceMap.entrySet().iterator();
-
- while (it.hasNext()) {
- MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter();
- Map.Entry <String, Object> pair = it.next();
- String value;
- Object obj = pair.getValue();
- if (obj instanceof java.lang.String) {
- value = yaml.dump(obj);
- // but this adds an extra '\n' at the end - which won't hurt - but we don't need it
- value = value.substring(0, value.length() - 1);
- } else if (obj instanceof java.util.LinkedHashMap) {
- //Handle that it's json
- try {
- value = JSON_MAPPER.writeValueAsString(obj);
- } catch (Exception e) {
- LOGGER.debug("Exception:", e);
- value = "_BAD_JSON_MAPPING";
- }
- } else {
- //this handles integers/longs/floats/etc.
- value = String.valueOf(obj);
- }
- hep.setName((String) pair.getKey());
- hep.setValue(value);
- paramSet.add(hep);
- }
+
+ for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) {
+ MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter();
+ Entry<String, Object> pair = stringObjectEntry;
+ String value;
+ Object obj = pair.getValue();
+ if (obj instanceof String) {
+ value = yaml.dump(obj);
+ // but this adds an extra '\n' at the end - which won't hurt - but we don't need it
+ value = value.substring(0, value.length() - 1);
+ } else if (obj instanceof LinkedHashMap) {
+ //Handle that it's json
+ try {
+ value = JSON_MAPPER.writeValueAsString(obj);
+ } catch (Exception e) {
+ LOGGER.debug("Exception:", e);
+ value = "_BAD_JSON_MAPPING";
+ }
+ } else {
+ //this handles integers/longs/floats/etc.
+ value = String.valueOf(obj);
+ }
+ hep.setName((String) pair.getKey());
+ hep.setValue(value);
+ paramSet.add(hep);
+ }
return paramSet;
}
public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() {
@@ -107,15 +107,14 @@ public class MsoYamlEditorWithEnvt {
Set<MsoHeatEnvironmentResource> resourceList = new HashSet<>();
@SuppressWarnings("unchecked")
Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry");
- Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator();
-
- while (it.hasNext()) {
- MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource();
- Map.Entry<String, Object> pair = it.next();
- her.setName((String) pair.getKey());
- her.setValue((String) pair.getValue());
- resourceList.add(her);
- }
+
+ for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) {
+ MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource();
+ Entry<String, Object> pair = stringObjectEntry;
+ her.setName((String) pair.getKey());
+ her.setValue((String) pair.getValue());
+ resourceList.add(her);
+ }
return resourceList;
} catch (Exception e) {
LOGGER.debug("Exception:", e);
@@ -126,35 +125,34 @@ public class MsoYamlEditorWithEnvt {
Set <HeatTemplateParam> paramSet = new HashSet <> ();
@SuppressWarnings("unchecked")
Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters");
- Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator ();
- while (it.hasNext ()) {
- HeatTemplateParam param = new HeatTemplateParam ();
- Map.Entry <String, Object> pair = it.next ();
+ for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) {
+ HeatTemplateParam param = new HeatTemplateParam();
+ Entry<String, Object> pair = stringObjectEntry;
@SuppressWarnings("unchecked")
- Map <String, String> resourceEntry = (Map <String, String>) pair.getValue ();
+ Map<String, String> resourceEntry = (Map<String, String>) pair.getValue();
String value = null;
try {
- value = resourceEntry.get ("default");
- } catch (java.lang.ClassCastException cce) {
+ value = resourceEntry.get("default");
+ } catch (ClassCastException cce) {
LOGGER.debug("Exception:", cce);
- // This exception only - the value is an integer. For what we're doing
- // here - we don't care - so set value to something - and it will
- // get marked as not being required - which is correct.
- //System.out.println("cce exception!");
- value = "300";
- // okay
+ // This exception only - the value is an integer. For what we're doing
+ // here - we don't care - so set value to something - and it will
+ // get marked as not being required - which is correct.
+ //System.out.println("cce exception!");
+ value = "300";
+ // okay
}
- param.setParamName ((String) pair.getKey ());
+ param.setParamName((String) pair.getKey());
if (value != null) {
- param.setRequired (false);
+ param.setRequired(false);
} else {
- param.setRequired (true);
+ param.setRequired(true);
}
- value = resourceEntry.get ("type");
- param.setParamType (value);
+ value = resourceEntry.get("type");
+ param.setParamType(value);
- paramSet.add (param);
+ paramSet.add(param);
}
return paramSet;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
index 6fd95d5948..c2d4f9ba60 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
@@ -60,7 +60,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
public final void testCreateStackBadCloudConfig()
throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
try {
- msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String, Object>(),
+ msoHeatUtils.createStack("DOESNOTEXIST", "test", "stackName", "test", new HashMap<>(),
Boolean.TRUE, 10);
} catch (MsoCloudSiteNotFound e) {
@@ -74,7 +74,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
public final void testCreateStackFailedConnectionHeatClient()
throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
try {
- msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE,
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE,
10);
} catch (MsoIOException e) {
@@ -86,7 +86,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
public final void testCreateStackFailedConnection()
throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound {
try {
- msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE,
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE,
10);
} catch (MsoIOException e) {
@@ -97,7 +97,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
@Test
public final void createStackSuccessWithEnvironment() throws MsoException {
try {
- msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10,
"environment");
} catch (MsoIOException e) {
@@ -108,8 +108,8 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
@Test
public final void createStackSuccessWithFiles() throws MsoException {
try {
- msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
- "environment", new HashMap<String, Object>());
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10,
+ "environment", new HashMap<>());
} catch (MsoIOException e) {
}
@@ -119,8 +119,8 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
@Test
public final void createStackSuccessWithHeatFiles() throws MsoException {
try {
- msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<String, Object>(), Boolean.TRUE, 10,
- "environment", new HashMap<String, Object>(), new HashMap<String, Object>());
+ msoHeatUtils.createStack("MT", "test", "stackName", "test", new HashMap<>(), Boolean.TRUE, 10,
+ "environment", new HashMap<>(), new HashMap<>());
} catch (MsoIOException e) {
}
@@ -131,7 +131,7 @@ public class MsoHeatUtilsTest extends MsoCommonUtils {
CreateStackParam param = new CreateStackParam();
param.setDisableRollback(false);
param.setEnvironment("environment");
- param.setFiles(new HashMap<String, Object>());
+ param.setFiles(new HashMap<>());
param.setParameters(new HashMap<>());
param.setStackName("stackName");
param.setTemplate("template");
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java
new file mode 100644
index 0000000000..2cfce276d8
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactoryTest.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import org.junit.Test;
+import org.openecomp.mso.cloud.CloudIdentity;
+import org.openecomp.mso.cloud.CloudIdentity.IdentityAuthenticationType;
+import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper;
+
+public class AuthenticationMethodFactoryTest {
+
+ private static final Class WRAPPER_CLASS = RackspaceAPIKeyWrapper.class;
+ private static final String AUTHENTICATION_TYPE = "authenticationTest";
+
+ @Test
+ public void register_NoExceptionThrown() throws IllegalAccessException, InstantiationException {
+ AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, WRAPPER_CLASS);
+ }
+
+ @Test
+ public void register_throwExceptionWhenAuthTypeIsNull() throws InstantiationException, IllegalAccessException {
+ try {
+ AuthenticationMethodFactory.register(null, WRAPPER_CLASS);
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null "
+ + "or an empty name string");
+ }
+ }
+
+ @Test
+ public void register_throwExceptionWhenAuthTypeIsEmpty() throws InstantiationException, IllegalAccessException {
+ try {
+ AuthenticationMethodFactory.register("", WRAPPER_CLASS);
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).isNotEmpty().contains("Authentication Type to register cannot be null "
+ + "or an empty name string");
+ }
+ }
+
+ @Test
+ public void register_throwExceptionWhenWrapperIsNull() throws IllegalAccessException, InstantiationException {
+ try {
+ AuthenticationMethodFactory.register(AUTHENTICATION_TYPE, null);
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).isNotEmpty()
+ .contains("Wrapper Class to register for Authentication cannot be null");
+ }
+ }
+
+ @Test
+ public void getAuthentication_NoExceptionThrown() {
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setIdentityAuthenticationType(IdentityAuthenticationType.RACKSPACE_APIKEY);
+ cloudIdentity.setMsoId("msoIdTest");
+ cloudIdentity.setMsoPass("123");
+ Authentication result = AuthenticationMethodFactory.getAuthenticationFor(cloudIdentity);
+ assertThat(result).isNotNull();
+ }
+
+ @Test
+ public void getAuthentication_ThrowExWhenCloudSiteIsNull() {
+ try {
+ AuthenticationMethodFactory.getAuthenticationFor(null);
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).isNotEmpty().contains("Cloud identity cannot be null");
+ }
+ }
+
+ @Test
+ public void getAuthentication_ThrowExWhenIdentityAuthenticationTypeIsNotSet() {
+ try {
+ AuthenticationMethodFactory.getAuthenticationFor(new CloudIdentity());
+ } catch (IllegalArgumentException e) {
+ assertThat(e.getMessage()).isNotEmpty()
+ .contains("Cloud identity authentication type cannot be null or empty");
+ }
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java
index ccfede7297..b6c1c7373f 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java
@@ -25,16 +25,11 @@ package org.openecomp.mso.cloud.authentication;
import static org.junit.Assert.assertTrue;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
import org.junit.Test;
import org.openecomp.mso.cloud.CloudIdentity;
import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
/**
* A few JUnit tests to evaluate the new factory that manages authentication
@@ -50,52 +45,15 @@ public class AuthenticationMethodTest {
public AuthenticationMethodTest() {
// TODO Auto-generated constructor stub
}
-
- @Test
- public void testCustomRackspaceAuth() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("test");
-
- try {
- Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
- | URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testCoreUsernamePasswordAuth() {
- CloudIdentity ci = new CloudIdentity();
- ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
- ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
- ci.setMsoId("someuser");
-
- try {
- Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci);
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException
- | URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
+
@Test
public void testCustomRackspaceAuthFromCloudIdentity() {
CloudIdentity ci = new CloudIdentity();
ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY);
ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
ci.setMsoId("test");
-
- try {
- Authentication auth = ci.getAuthentication();
- assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
- } catch (MsoException e) {
- e.printStackTrace();
- }
+ Authentication auth = ci.getAuthentication();
+ assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
}
@Test
@@ -104,12 +62,7 @@ public class AuthenticationMethodTest {
ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD);
ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
ci.setMsoId("someuser");
-
- try {
- Authentication auth = ci.getAuthentication();
- assertTrue(UsernamePassword.class.equals(auth.getClass()));
- } catch (MsoException e) {
- e.printStackTrace();
- }
+ Authentication auth = ci.getAuthentication();
+ assertTrue(UsernamePassword.class.equals(auth.getClass()));
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java
new file mode 100644
index 0000000000..33f91c641e
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapperTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication.wrappers;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import org.junit.Test;
+import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication;
+
+public class RackspaceAPIKeyWrapperTest {
+
+ @Test
+ public void getAuthenticationSuccessful() {
+ RackspaceAPIKeyWrapper testedObject = new RackspaceAPIKeyWrapper();
+ Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity());
+
+ assertThat(authentication).isInstanceOf(RackspaceAuthentication.class);
+ RackspaceAuthentication rackspaceAuthentication = (RackspaceAuthentication) authentication;
+ assertThat(rackspaceAuthentication.getToken().getUsername())
+ .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID);
+ assertThat(rackspaceAuthentication.getToken().getApiKey())
+ .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS);
+ }
+
+ @Test
+ public void getAuthenticationThrowsException() {
+ assertThatThrownBy(() -> new RackspaceAPIKeyWrapper().getAuthentication(null))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java
new file mode 100644
index 0000000000..0cfe287dfe
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapperTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication.wrappers;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+import org.junit.Test;
+
+public class UsernamePasswordWrapperTest {
+
+ @Test
+ public void getAuthenticationSuccessful() {
+ UsernamePasswordWrapper testedObject = new UsernamePasswordWrapper();
+ Authentication authentication = testedObject.getAuthentication(WrapperTestUtility.createCloudIdentity());
+
+ assertThat(authentication).isInstanceOf(UsernamePassword.class);
+ UsernamePassword usernamePassword = (UsernamePassword) authentication;
+ assertThat(usernamePassword.getPasswordCredentials().getUsername())
+ .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_ID);
+ assertThat(usernamePassword.getPasswordCredentials().getPassword())
+ .isEqualTo(WrapperTestUtility.CLOUD_IDENTITY_MSO_PASS);
+ }
+
+ @Test
+ public void getAuthenticationThrowsException() {
+ assertThatThrownBy(() -> new UsernamePasswordWrapper().getAuthentication(null)).
+ isInstanceOf(IllegalArgumentException.class).
+ hasMessage(WrapperTestUtility.EXCEPTION_MESSAGE);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java
new file mode 100644
index 0000000000..3cbc48d090
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/wrappers/WrapperTestUtility.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * 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 and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package org.openecomp.mso.cloud.authentication.wrappers;
+
+import org.openecomp.mso.cloud.CloudIdentity;
+
+final class WrapperTestUtility {
+
+ static final String CLOUD_IDENTITY_MSO_ID = "msoIdTest";
+ static final String CLOUD_IDENTITY_MSO_PASS = "msoPassTest";
+ static final String EXCEPTION_MESSAGE = "Provided cloud identity is null, cannot extract username and "
+ + "password";
+
+ private WrapperTestUtility() {
+ }
+
+ static CloudIdentity createCloudIdentity() {
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setMsoId(CLOUD_IDENTITY_MSO_ID);
+ cloudIdentity.setMsoPass(CloudIdentity.encryptPassword(CLOUD_IDENTITY_MSO_PASS));
+ return cloudIdentity;
+ }
+}
diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml
index f10500d2ca..98cd1831c1 100644
--- a/adapters/mso-adapters-rest-interface/pom.xml
+++ b/adapters/mso-adapters-rest-interface/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<packaging>jar</packaging>
<name>mso-adapters-rest-interface</name>
@@ -44,7 +44,7 @@
<version>3.0.19.Final</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
index 5c3470acd9..9efaee921f 100644
--- a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
@@ -433,7 +433,7 @@ public class BeanTest {
m.invoke(obj);
} else if (types.length == 1) {
String type = types[0].getTypeName();
- if (type.indexOf("<") != -1) {
+ if (type.contains("<")) {
type = type.substring(0, type.indexOf("<"));
}
Class paramCls = Class.forName(type);
diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml
index c9590ee1a1..9bacb17a51 100644
--- a/adapters/mso-catalog-db-adapter/pom.xml
+++ b/adapters/mso-catalog-db-adapter/pom.xml
@@ -2,12 +2,12 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-catalog-db-adapter</artifactId>
<packaging>war</packaging>
@@ -65,7 +65,7 @@
<dependencies>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
@@ -95,7 +95,7 @@
<version>3.0.16.Final</version>
</dependency>
<!--<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>-->
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
index 668f73816d..c1c5aee8f1 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
@@ -52,34 +52,39 @@ Once the network-level distribution artifacts are defined, similar updates can b
import java.util.ArrayList;
import java.util.List;
+
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
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.HttpHeaders;
import javax.ws.rs.core.MediaType;
-import org.apache.http.HttpStatus;
+import javax.ws.rs.core.Response;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
+import org.apache.http.HttpStatus;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery;
import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException;
import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryResourceRecipe;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceCsar;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks;
+import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryVfModule;
import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.Recipe;
import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
/**
* This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
@@ -425,45 +430,144 @@ public class CatalogDbAdapterRest {
QueryVfModule qryResp;
int respStatus = HttpStatus.SC_OK;
List<VfModuleCustomization> ret = null;
- CatalogDatabase db = CatalogDatabase.getInstance();
-
- try{
- if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
- LOGGER.debug ("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
- VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
- if(vfModule != null){
- ret = new ArrayList<>(1);
- ret.add(vfModule);
+
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
+ LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
+ VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
+ if (vfModule != null) {
+ ret = new ArrayList<>(1);
+ ret.add(vfModule);
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ if (ret == null || ret.isEmpty()) {
+ LOGGER.debug("vfModules not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryVfModule();
+ } else {
+ LOGGER.debug("vfModules found");
+ qryResp = new QueryVfModule(ret);
+ LOGGER.debug("vfModules query Results is: " + qryResp);
+ LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false));
+ }
+ LOGGER.debug("Query vfModules exit");
+ return Response
+ .status(respStatus)
+ .entity(qryResp.JSON2(false, false))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ",
+ e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
+ }
+
+ /**
+ * Get the tosca csar info from catalog
+ * <br>
+ *
+ * @param smUuid service model uuid
+ * @return the tosca csar information of the serivce.
+ * @since ONAP Beijing Release
+ */
+ @GET
+ @Path("serviceToscaCsar")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
+ int respStatus = HttpStatus.SC_OK;
+ String entity = "";
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (smUuid != null && !"".equals(smUuid)) {
+ LOGGER.debug("Query Csar by service model uuid: " + smUuid);
+ ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid);
+ if (toscaCsar != null) {
+ QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
+ entity = serviceCsar.JSON2(false, false);
+ } else {
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ LOGGER.debug("Query Csar exit");
+ return Response
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
+ }
+
+ /**
+ * Get the resource recipe info from catalog
+ * <br>
+ *
+ * @param rmUuid resource model uuid
+ * @return the recipe information of the resource.
+ * @since ONAP Beijing Release
+ */
+ @GET
+ @Path("resourceRecipe")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
+ int respStatus = HttpStatus.SC_OK;
+ String entity = "";
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (rmUuid != null && !"".equals(rmUuid)) {
+ LOGGER.debug("Query recipe by resource model uuid: " + rmUuid);
+ //check vnf and network and ar, the resource could be any resource.
+ Recipe recipe = db.getVnfRecipeByModuleUuid(rmUuid, action);
+ if (null == recipe) {
+ recipe = db.getNetworkRecipeByModuleUuid(rmUuid, action);
}
- }else{
- throw(new Exception("Incoming parameter is null or blank"));
- }
- if(ret == null || ret.isEmpty()){
- LOGGER.debug ("vfModules not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryVfModule();
- }else{
- LOGGER.debug ("vfModules found");
- qryResp = new QueryVfModule(ret);
- LOGGER.debug ("vfModules query Results is: "+ qryResp);
- LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
+ if (null == recipe) {
+ recipe = db.getArRecipeByModuleUuid(rmUuid, action);
+ }
+ if (recipe != null) {
+ QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
+ entity = resourceRecipe.JSON2(false, false);
+ } else {
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
}
- LOGGER.debug ("Query vfModules exit");
+ LOGGER.debug("Query recipe exit");
return Response
- .status(respStatus)
- .entity(qryResp.JSON2(false, false))
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }catch(Exception e){
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }finally {
- db.close();
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
}
- }
-
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
index a74cf07b89..4a8233bb03 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
@@ -46,21 +46,21 @@ public abstract class CatalogQuery {
}
protected String setTemplate(String template, Map<String, String> valueMap) {
- LOGGER.debug ("CatalogQuery setTemplate");
+ LOGGER.debug("CatalogQuery setTemplate");
StringBuffer result = new StringBuffer();
String pattern = "<.*>";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(template);
- LOGGER.debug ("CatalogQuery template:"+ template);
- while(m.find()) {
- String key = template.substring(m.start()+1, m.end()-1);
- LOGGER.debug ("CatalogQuery key:"+ key+ " contains key? "+ valueMap.containsKey(key));
- m.appendReplacement(result, valueMap.containsKey(key)? valueMap.get(key): "\"TBD\"");
+ LOGGER.debug("CatalogQuery template:" + template);
+ while (m.find()) {
+ String key = template.substring(m.start() + 1, m.end() - 1);
+ LOGGER.debug("CatalogQuery key:" + key + " contains key? " + valueMap.containsKey(key));
+ m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\""));
}
m.appendTail(result);
- LOGGER.debug ("CatalogQuery return:"+ result.toString());
+ LOGGER.debug("CatalogQuery return:" + result.toString());
return result.toString();
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
index 9a82ed2c6e..f7758c315c 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
@@ -62,30 +62,30 @@ public class QueryAllottedResourceCustomization extends CatalogQuery {
@Override
public String toString () {
- StringBuilder buf = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (AllottedResourceCustomization o : allottedResourceCustomization) {
- buf.append(i+"\t");
- if (!first) buf.append("\n"); first = false;
- buf.append(o);
+ sb.append(i).append("\t");
+ if (!first) sb.append("\n"); first = false;
+ sb.append(o);
}
- return buf.toString();
+ return sb.toString();
}
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
- StringBuilder buf = new StringBuilder();
- if (!isEmbed && isArray) buf.append("{ ");
- if (isArray) buf.append("\"serviceAllottedResources\": [");
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) sb.append("{ ");
+ if (isArray) sb.append("\"serviceAllottedResources\": [");
Map<String, String> valueMap = new HashMap<>();
String sep = "";
boolean first = true;
if (this.allottedResourceCustomization != null) {
for (AllottedResourceCustomization o : allottedResourceCustomization) {
- if (first) buf.append("\n"); first = false;
+ if (first) sb.append("\n"); first = false;
boolean arNull = o.getAllottedResource() == null ? true : false;
@@ -104,14 +104,14 @@ public class QueryAllottedResourceCustomization extends CatalogQuery {
put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode());
put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUuid());
- buf.append(sep+ this.setTemplate(template, valueMap));
+ sb.append(sep).append(this.setTemplate(template, valueMap));
sep = ",\n";
}
}
- if (!first) buf.append("\n");
- if (isArray) buf.append("]");
- if (!isEmbed && isArray) buf.append("}");
- return buf.toString();
+ if (!first) sb.append("\n");
+ if (isArray) sb.append("]");
+ if (!isEmbed && isArray) sb.append("}");
+ return sb.toString();
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
new file mode 100644
index 0000000000..5be6970554
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
@@ -0,0 +1,72 @@
+/*-
+ * ============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.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.mso.db.catalog.beans.Recipe;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryResourceRecipe extends CatalogQuery{
+
+ private Recipe resourceRecipe;
+
+ public QueryResourceRecipe(Recipe resourceRecipe){
+ this.resourceRecipe =resourceRecipe;
+ }
+
+ private final String template =
+ "\t{\n"+
+ "\t\t\"id\" : <ID>,\n"+
+ "\t\t\"action\" : <ACTION>,\n"+
+ "\t\t\"orchestrationUri\" : <ORCHESTRATION_URI>,\n"+
+ "\t\t\"recipeTimeout\" : <RECIPE_TIMEOUT>,\n"+
+ "\t\t\"paramXSD\" : <PARAM_XSD>,\n"+
+ "\t\t\"description\" : <DESCRIPTION>\n"+
+ "\t}";
+
+ @Override
+ public String toString() {
+
+ return resourceRecipe.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ put(valueMap, "ID", null == resourceRecipe ? null : resourceRecipe.getId());
+ put(valueMap, "ACTION", null == resourceRecipe ? null : resourceRecipe.getAction());
+ put(valueMap, "ORCHESTRATION_URI", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
+ put(valueMap, "RECIPE_TIMEOUT", null == resourceRecipe ? null : resourceRecipe.getRecipeTimeout());
+ put(valueMap, "PARAM_XSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
+ put(valueMap, "DESCRIPTION", null == resourceRecipe ? null : resourceRecipe.getDescription());
+ return this.setTemplate(template, valueMap);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java
new file mode 100644
index 0000000000..6b1eb836d9
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java
@@ -0,0 +1,72 @@
+/*-
+ * ============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.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryServiceCsar extends CatalogQuery{
+
+ private ToscaCsar toscaCsar;
+
+ public QueryServiceCsar(ToscaCsar toscaCsar){
+ this.toscaCsar = toscaCsar;
+ }
+
+ private final String template =
+ "\t{\n"+
+ "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+
+ "\t\t\"name\" : <NAME>,\n"+
+ "\t\t\"version\" : <VERSION>,\n"+
+ "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n"+
+ "\t\t\"url\" : <URL>,\n"+
+ "\t\t\"description\" : <DESCRIPTION>\n"+
+ "\t}";
+
+ @Override
+ public String toString() {
+
+ return toscaCsar.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
+ put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
+ put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
+ put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
+ put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
+ put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
+ return this.setTemplate(template, valueMap);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
index 59c601ef19..c04068d680 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
@@ -67,30 +67,30 @@ public class QueryServiceNetworks extends CatalogQuery {
@Override
public String toString () {
- StringBuilder buf = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (NetworkResourceCustomization o : serviceNetworks) {
- buf.append(i+"\t");
- if (!first) buf.append("\n"); first = false;
- buf.append(o);
+ sb.append(i).append("\t");
+ if (!first) sb.append("\n"); first = false;
+ sb.append(o);
}
- return buf.toString();
+ return sb.toString();
}
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
- StringBuilder buf = new StringBuilder();
- if (!isEmbed && isArray) buf.append("{ ");
- if (isArray) buf.append("\"serviceNetworks\": [");
- //if (isArray) buf.append("[");
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) sb.append("{ ");
+ if (isArray) sb.append("\"serviceNetworks\": [");
+
Map<String, String> valueMap = new HashMap<>();
String sep = "";
boolean first = true;
for (NetworkResourceCustomization o : serviceNetworks) {
- if (first) buf.append("\n"); first = false;
+ if (first) sb.append("\n"); first = false;
boolean nrNull = o.getNetworkResource() == null ? true : false;
put(valueMap, "MODEL_NAME", nrNull ? null : o.getNetworkResource().getModelName());
put(valueMap, "MODEL_UUID", nrNull ? null : o.getNetworkResource().getModelUUID());
@@ -104,12 +104,12 @@ public class QueryServiceNetworks extends CatalogQuery {
put(valueMap, "NETWORK_SCOPE", o.getNetworkScope());
put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology());
- buf.append(sep+ this.setTemplate(template, valueMap));
+ sb.append(sep).append(this.setTemplate(template, valueMap));
sep = ",\n";
}
- if (!first) buf.append("\n");
- if (isArray) buf.append("]");
- if (!isEmbed && isArray) buf.append("}");
- return buf.toString();
+ if (!first) sb.append("\n");
+ if (isArray) sb.append("]");
+ if (!isEmbed && isArray) sb.append("}");
+ return sb.toString();
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
index cfbb781ae8..f0d4327950 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
@@ -72,29 +72,29 @@ public class QueryServiceVnfs extends CatalogQuery {
@Override
public String toString () {
- StringBuilder buf = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (VnfResourceCustomization o : serviceVnfs) {
- buf.append(i+"\t");
- if (!first) buf.append("\n"); first = false;
- buf.append(o);
+ sb.append(i).append("\t");
+ if (!first) sb.append("\n"); first = false;
+ sb.append(o);
}
- return buf.toString();
+ return sb.toString();
}
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
- StringBuilder buf = new StringBuilder();
- if (!isEmbed && isArray) buf.append("{ ");
- if (isArray) buf.append("\"serviceVnfs\": [");
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) sb.append("{ ");
+ if (isArray) sb.append("\"serviceVnfs\": [");
Map<String, String> valueMap = new HashMap<>();
String sep = "";
boolean first = true;
for (VnfResourceCustomization o : serviceVnfs) {
- if (first) buf.append("\n"); first = false;
+ if (first) sb.append("\n"); first = false;
boolean vrNull = o.getVnfResource() == null ? true : false;
@@ -113,12 +113,12 @@ public class QueryServiceVnfs extends CatalogQuery {
String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true);
valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t"));
- buf.append(sep+ this.setTemplate(template, valueMap));
+ sb.append(sep).append(this.setTemplate(template, valueMap));
sep = ",\n";
}
- if (!first) buf.append("\n");
- if (isArray) buf.append("]");
- if (!isEmbed && isArray) buf.append("}");
- return buf.toString();
+ if (!first) sb.append("\n");
+ if (isArray) sb.append("]");
+ if (!isEmbed && isArray) sb.append("}");
+ return sb.toString();
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
index 309aa0641a..fe0f0cbc17 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
@@ -69,28 +69,28 @@ public class QueryVfModule extends CatalogQuery {
@Override
public String toString () {
- StringBuilder buf = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (VfModuleCustomization o : vfModules) {
- buf.append(i+"\t");
- if (!first) buf.append("\n"); first = false;
- buf.append(o);
+ sb.append(i).append("\t");
+ if (!first) sb.append("\n"); first = false;
+ sb.append(o);
}
- return buf.toString();
+ return sb.toString();
}
@Override
public String JSON2(boolean isArray, boolean x) {
- StringBuilder buf = new StringBuilder();
- if (isArray) buf.append("\"vfModules\": [");
+ StringBuilder sb = new StringBuilder();
+ if (isArray) sb.append("\"vfModules\": [");
Map<String, String> valueMap = new HashMap<>();
String sep = "";
boolean first = true;
for (VfModuleCustomization o : vfModules) {
- if (first) buf.append("\n"); first = false;
+ if (first) sb.append("\n"); first = false;
boolean vfNull = o.getVfModule() == null ? true : false;
boolean hasVolumeGroup = false;
@@ -104,16 +104,16 @@ public class QueryVfModule extends CatalogQuery {
put(valueMap, "MODEL_INVARIANT_ID", vfNull ? null : o.getVfModule().getModelInvariantUuid());
put(valueMap, "MODEL_VERSION", vfNull ? null : o.getVfModule().getVersion());
put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
- put(valueMap, "IS_BASE", vfNull ? false : new Boolean(o.getVfModule().isBase()? true: false));
- put(valueMap, "VF_MODULE_LABEL", o.getLabel());
+ put(valueMap, "IS_BASE", vfNull ? false : o.getVfModule().isBase() ? true : false);
+ put(valueMap, "VF_MODULE_LABEL", o.getLabel());
put(valueMap, "INITIAL_COUNT", o.getInitialCount());
- put(valueMap, "HAS_VOLUME_GROUP", new Boolean(hasVolumeGroup));
+ put(valueMap, "HAS_VOLUME_GROUP", hasVolumeGroup);
- buf.append(sep+ this.setTemplate(template, valueMap));
+ sb.append(sep).append(this.setTemplate(template, valueMap));
sep = ",\n";
}
- if (!first) buf.append("\n");
- if (isArray) buf.append("]");
- return buf.toString();
+ if (!first) sb.append("\n");
+ if (isArray) sb.append("]");
+ return sb.toString();
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
index ff713991f9..00a5cafb29 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
@@ -58,17 +58,17 @@ public class QueryVfModules {
@Override
public String toString () {
- StringBuilder buf = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
boolean first = true;
int i = 1;
for (VfModule o : vfModules) {
- buf.append(i+"\t");
- if (!first) buf.append("\n");
+ sb.append(i).append("\t");
+ if (!first) sb.append("\n");
first = false;
- buf.append(o);
+ sb.append(o);
}
- return buf.toString();
+ return sb.toString();
}
public String toJsonString() {
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
index 31a58329d6..31594905fd 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
@@ -70,7 +70,7 @@ public class CatalogDbAdapterRestClassTest {
*
*/
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("ciVFOnboarded-FNAT-aab06c41 1");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
index 33f5553115..ae5e663777 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
@@ -114,7 +114,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -154,7 +154,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setVnfResourceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -198,7 +198,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -242,7 +242,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -282,7 +282,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -322,7 +322,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
ArrayList<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -367,7 +367,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<AllottedResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -409,7 +409,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<AllottedResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
index 31e828d19a..ee2c8db577 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
@@ -49,7 +49,7 @@ public class CatalogQueryTest {
CatalogQuery mockCatalogQuery = Mockito.mock(CatalogQuery.class);
Mockito.doCallRealMethod().when(mockCatalogQuery).setTemplate(Mockito.anyString(), Mockito.anyMapOf(String.class, String.class));
- Map<String,String> valueMap = new HashMap<String,String>();
+ Map<String,String> valueMap = new HashMap<>();
valueMap.put("somekey", "somevalue");
String ret = mockCatalogQuery.setTemplate("<somekey>", valueMap);
@@ -60,7 +60,7 @@ public class CatalogQueryTest {
@Test
public void smartToJson_Test()
{
- List<VnfResourceCustomization> paramList = new ArrayList<VnfResourceCustomization>();
+ List<VnfResourceCustomization> paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
index 71352b5272..0d86a6cf10 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
@@ -43,7 +43,7 @@ public class QueryAllottedResourceCustomizationTest {
public void JSON2_Test()
{
List<AllottedResourceCustomization> paramList;
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
index dfbc2dc384..3a767a8609 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
@@ -47,7 +47,7 @@ public class QueryServiceMarcoHolderTest {
svc.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9");
svc.setModelName("Testing Model One");
ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
index b237dbe0a8..1c855eaa72 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
@@ -45,7 +45,7 @@ public class QueryServiceNetworksTest {
public void JSON2_Test()
{
ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
index 262fe06988..8c8fc967da 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
@@ -44,7 +44,7 @@ public class QueryServiceVnfsTest {
public void JSON2_Test()
{
List<VnfResourceCustomization> paramList;
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
diff --git a/adapters/mso-network-adapter-async-client/pom.xml b/adapters/mso-network-adapter-async-client/pom.xml
index cc1ae6ea30..9920c729a1 100644
--- a/adapters/mso-network-adapter-async-client/pom.xml
+++ b/adapters/mso-network-adapter-async-client/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-network-adapter-async-client</artifactId>
<packaging>jar</packaging>
<name>mso-network-adapter-async-client</name>
diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml
index 48b5b3ebd4..48a19bda6e 100644
--- a/adapters/mso-network-adapter/pom.xml
+++ b/adapters/mso-network-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-network-adapter</artifactId>
<packaging>war</packaging>
<name>mso-network-adapter</name>
@@ -53,7 +53,7 @@
<version>2.2.7</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
@@ -106,17 +106,17 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-network-adapter-async-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
@@ -145,7 +145,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
index 2c04ae9d6b..6063956af9 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
@@ -288,39 +288,45 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
- NetworkResource networkResource = networkCheck (db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
- String mode = networkResource.getOrchestrationMode ();
- NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ());
-
- if (NEUTRON_MODE.equals (mode)) {
+ try (CatalogDatabase db = getCatalogDB()) {
+ NetworkResource networkResource = networkCheck(db,
+ startTime,
+ networkType,
+ modelCustomizationUuid,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ cloudSiteOpt.get());
+ String mode = networkResource.getOrchestrationMode();
+ NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
+
+ if (NEUTRON_MODE.equals(mode)) {
// Use an MsoNeutronUtils for all neutron commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
// See if the Network already exists (by name)
NetworkInfo netInfo = null;
- long queryNetworkStarttime = System.currentTimeMillis ();
+ long queryNetworkStarttime = System.currentTimeMillis();
try {
- netInfo = neutron.queryNetwork (networkName, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null);
+ netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null);
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me);
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack");
- throw new NetworkException (me);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack",
+ "OpenStack", "QueryNetwork", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack",
+ me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack");
+ throw new NetworkException(me);
}
if (netInfo != null) {
@@ -328,49 +334,59 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Otherwise, return an exception.
if (failIfExists != null && failIfExists) {
String error = "Create Nework: Network " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " with ID " + netInfo.getId();
- LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
+ + " already exists in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + " with ID " + netInfo.getId();
+ LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId,
+ "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ error);
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
} else {
// Populate the outputs from the existing network.
- networkId.value = netInfo.getId ();
- neutronNetworkId.value = netInfo.getId ();
+ networkId.value = netInfo.getId();
+ neutronNetworkId.value = netInfo.getId();
rollback.value = networkRollback; // Default rollback - no updates performed
- String msg = "Found Existing network, status=" + netInfo.getStatus () + " for Neutron mode";
- LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg);
+ String msg = "Found Existing network, status=" + netInfo.getStatus() + " for Neutron mode";
+ LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError, "Found Existing network, status=" + netInfo.getStatus());
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ msg);
}
return;
}
- long createNetworkStarttime = System.currentTimeMillis ();
+ long createNetworkStarttime = System.currentTimeMillis();
try {
- netInfo = neutron.createNetwork (cloudSiteId,
- tenantId,
- neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "CreateNetwork", null);
+ netInfo = neutron.createNetwork(cloudSiteId,
+ tenantId,
+ neutronNetworkType,
+ networkName,
+ physicalNetworkName,
+ vlans);
+ LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "CreateNetwork", null);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent (createNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack", "OpenStack", "CreateNetwork", null);
- String error = "Create Network: type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
-
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordMetricEvent(createNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with OpenStack",
+ "OpenStack", "CreateNetwork", null);
+ String error = "Create Network: type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception while communicate with OpenStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+
+ throw new NetworkException(me);
}
// Note: ignoring MsoNetworkAlreadyExists because we already checked.
@@ -378,263 +394,287 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// If reach this point, network creation is successful.
// Since directly created via Neutron, networkId tracked by MSO is the same
// as the neutron network ID.
- networkId.value = netInfo.getId ();
- neutronNetworkId.value = netInfo.getId ();
+ networkId.value = netInfo.getId();
+ neutronNetworkId.value = netInfo.getId();
- networkRollback.setNetworkCreated (true);
- networkRollback.setNetworkId (netInfo.getId ());
- networkRollback.setNeutronNetworkId (netInfo.getId ());
- networkRollback.setNetworkType (networkType);
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkId(netInfo.getId());
+ networkRollback.setNeutronNetworkId(netInfo.getId());
+ networkRollback.setNetworkType(networkType);
- LOGGER.debug ("Network " + networkName + " created, id = " + netInfo.getId ());
- } else if ("HEAT".equals (mode)) {
+ LOGGER.debug("Network " + networkName + " created, id = " + netInfo.getId());
+ } else if ("HEAT".equals(mode)) {
// Use an MsoHeatUtils for all Heat commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
//HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID());
+ HeatTemplate heatTemplate = db
+ .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
if (heatTemplate == null) {
String error = "Network error - undefined Heat Template. Network Type = " + networkType;
- LOGGER.error (MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type = " + networkType);
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- throw new NetworkException (error, MsoExceptionCategory.INTERNAL);
+ LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
+ "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Network error - undefined Heat Template. Network Type = " + networkType);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
+ // error,
+ // configuration
+ // must be fixed
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ error);
+ throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
+ LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString());
// "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate ();
- template = template.replaceAll ("\r\n", "\n");
+ String template = heatTemplate.getHeatTemplate();
+ template = template.replaceAll("\r\n", "\n");
- boolean aic3template=false;
+ boolean aic3template = false;
String aic3nw = AIC3_NW;
try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW);
- } catch (MsoPropertiesException e) {
- String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e);
- }
+ aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
+ .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
+ } catch (MsoPropertiesException e) {
+ String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "", "", MsoLogger.ErrorCode.DataError,
+ "Exception - Unable to get properties", e);
+ }
if (template.contains(aic3nw))
- aic3template = true;
+ aic3template = true;
// First, look up to see if the Network already exists (by name).
// For HEAT orchestration of networks, the stack name will always match the network name
StackInfo heatStack = null;
- long queryNetworkStarttime = System.currentTimeMillis ();
+ long queryNetworkStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack (cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null);
+ heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack", "OpenStack", "QueryNetwork", null);
- String error = "Create Network (heat): query network " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while querying stack from OpenStack",
+ "OpenStack", "QueryNetwork", null);
+ String error = "Create Network (heat): query network " + networkName
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception while querying stack from OpenStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
- if (heatStack != null && (heatStack.getStatus () != HeatStatus.NOTFOUND)) {
+ if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) {
// Stack exists. Return success or error depending on input directive
if (failIfExists != null && failIfExists) {
String error = "CreateNetwork: Stack " + networkName
- + " already exists in "
- + cloudSiteId
- + "/"
- + tenantId
- + " as " + heatStack.getCanonicalName();
- LOGGER.error (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Network already exists");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error);
+ + " already exists in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + " as " + heatStack.getCanonicalName();
+ LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError, "Network already exists");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ error);
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
} else {
// Populate the outputs from the existing stack.
- networkId.value = heatStack.getCanonicalName ();
- neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID);
+ networkId.value = heatStack.getCanonicalName();
+ neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
rollback.value = networkRollback; // Default rollback - no updates performed
- if (aic3template)
- {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+ if (aic3template) {
+ networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
}
- Map <String, Object> outputs = heatStack.getOutputs ();
- Map <String, String> sMap = new HashMap <> ();
+ Map<String, Object> outputs = heatStack.getOutputs();
+ Map<String, String> sMap = new HashMap<>();
if (outputs != null) {
- for (String key : outputs.keySet ()) {
- if (key != null && key.startsWith ("subnet")) {
- if (aic3template) //one subnet_id output
- {
- Map <String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- }
- else //multiples subnet_%aaid% outputs
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put (key.substring("subnet_id_".length()), subnetUUId);
- }
- }
- }
+ for (String key : outputs.keySet()) {
+ if (key != null && key.startsWith("subnet")) {
+ if (aic3template) //one subnet_id output
+ {
+ Map<String, String> map = getSubnetUUId(key, outputs, subnets);
+ sMap.putAll(map);
+ } else //multiples subnet_%aaid% outputs
+ {
+ String subnetUUId = (String) outputs.get(key);
+ sMap.put(key.substring("subnet_id_".length()), subnetUUId);
+ }
+ }
+ }
}
subnetIdMap.value = sMap;
- LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ());
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack");
+ LOGGER.warn(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Found Existing network stack, status=" + heatStack.getStatus());
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc,
+ "Found Existing network stack");
}
return;
}
// Ready to deploy the new Network
// Build the common set of HEAT template parameters
- Map <String, Object> stackParams = populateNetworkParams (neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
+ Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ shared,
+ external,
+ aic3template);
// Validate (and update) the input parameters against the DB definition
// Shouldn't happen unless DB config is wrong, since all networks use same inputs
// and inputs were already validated.
try {
- stackParams = heat.validateStackParams (stackParams, heatTemplate);
+ stackParams = heat.validateStackParams(stackParams, heatTemplate);
} catch (IllegalArgumentException e) {
- String error = "Create Network: Configuration Error: " + e.getMessage ();
- LOGGER.error (MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e);
- alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
- // error,
- // configuration
- // must be fixed
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
+ String error = "Create Network: Configuration Error: " + e.getMessage();
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, e.getMessage(), "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - Create Network, Configuration Error", e);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); // Alarm on this
+ // error,
+ // configuration
+ // must be fixed
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError,
+ error);
// Input parameters were not valid
- throw new NetworkException (error, MsoExceptionCategory.INTERNAL);
+ throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
if (subnets != null) {
- try {
- if (aic3template)
- {
- template = mergeSubnetsAIC3 (template, subnets, stackParams);
- }
- else
- {
- template = mergeSubnets (template, subnets);
- }
- } catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging subnets", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
- }
+ try {
+ if (aic3template) {
+ template = mergeSubnetsAIC3(template, subnets, stackParams);
+ } else {
+ template = mergeSubnets(template, subnets);
+ }
+ } catch (MsoException me) {
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat): type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging subnets", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
+ }
}
if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) {
try {
- mergePolicyRefs (policyFqdns, stackParams);
+ mergePolicyRefs(policyFqdns, stackParams);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging policyRefs", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat) mergePolicyRefs type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging policyRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
}
}
if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) {
try {
- mergeRouteTableRefs (routeTableFqdns, stackParams);
+ mergeRouteTableRefs(routeTableFqdns, stackParams);
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception Create Network, merging routeTableRefs", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat) mergeRouteTableRefs type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception Create Network, merging routeTableRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
+ throw new NetworkException(me);
}
}
// Deploy the network stack
// Ignore MsoStackAlreadyExists exception because we already checked.
try {
- if (backout == null)
- backout = true;
- heatStack = heat.createStack (cloudSiteId,
- tenantId,
- networkName,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes (),
- null,
- null,
- null,
- backout.booleanValue());
+ if (backout == null)
+ backout = true;
+ heatStack = heat.createStack(cloudSiteId,
+ tenantId,
+ networkName,
+ template,
+ stackParams,
+ true,
+ heatTemplate.getTimeoutMinutes(),
+ null,
+ null,
+ null,
+ backout.booleanValue());
} catch (MsoException me) {
- me.addContext (CREATE_NETWORK_CONTEXT);
- String error = "Create Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error (MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception creating network", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext(CREATE_NETWORK_CONTEXT);
+ String error = "Create Network (heat): type " + neutronNetworkType
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_CREATE_NETWORK_EXC, networkName, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Exception creating network", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
// Reach this point if createStack is successful.
// For Heat-based orchestration, the MSO-tracked network ID is the heat stack,
// and the neutronNetworkId is the network UUID returned in stack outputs.
- networkId.value = heatStack.getCanonicalName ();
- neutronNetworkId.value = (String) heatStack.getOutputs ().get (NETWORK_ID);
- if (aic3template)
- {
- networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
+ networkId.value = heatStack.getCanonicalName();
+ neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID);
+ if (aic3template) {
+ networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN);
}
- Map <String, Object> outputs = heatStack.getOutputs ();
- Map <String, String> sMap = new HashMap <> ();
+ Map<String, Object> outputs = heatStack.getOutputs();
+ Map<String, String> sMap = new HashMap<>();
if (outputs != null) {
- for (String key : outputs.keySet ()) {
- if (key != null && key.startsWith ("subnet")) {
- if (aic3template) //one subnet output expected
- {
- Map <String, String> map = getSubnetUUId(key, outputs, subnets);
- sMap.putAll(map);
- }
- else //multiples subnet_%aaid% outputs allowed
- {
- String subnetUUId = (String) outputs.get(key);
- sMap.put (key.substring("subnet_id_".length()), subnetUUId);
- }
+ for (String key : outputs.keySet()) {
+ if (key != null && key.startsWith("subnet")) {
+ if (aic3template) //one subnet output expected
+ {
+ Map<String, String> map = getSubnetUUId(key, outputs, subnets);
+ sMap.putAll(map);
+ } else //multiples subnet_%aaid% outputs allowed
+ {
+ String subnetUUId = (String) outputs.get(key);
+ sMap.put(key.substring("subnet_id_".length()), subnetUUId);
+ }
}
}
}
@@ -642,15 +682,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
rollback.value = networkRollback;
// Populate remaining rollback info and response parameters.
- networkRollback.setNetworkStackId (heatStack.getCanonicalName ());
- networkRollback.setNeutronNetworkId ((String) heatStack.getOutputs ().get (NETWORK_ID));
- networkRollback.setNetworkCreated (true);
- networkRollback.setNetworkType (networkType);
+ networkRollback.setNetworkStackId(heatStack.getCanonicalName());
+ networkRollback.setNeutronNetworkId((String) heatStack.getOutputs().get(NETWORK_ID));
+ networkRollback.setNetworkCreated(true);
+ networkRollback.setNetworkType(networkType);
- LOGGER.debug ("Network " + networkName + " successfully created via HEAT");
+ LOGGER.debug("Network " + networkName + " successfully created via HEAT");
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Successfully created network");
return;
@@ -803,19 +841,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
+ try (CatalogDatabase db = getCatalogDB()) {
NetworkResource networkResource = networkCheck(db,
- startTime,
- networkType,
- modelCustomizationUuid,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- cloudSiteOpt.get());
+ startTime,
+ networkType,
+ modelCustomizationUuid,
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ cloudSiteOpt.get());
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
@@ -830,54 +867,66 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long queryNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.queryNetwork(networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryNetwork", null);
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "QueryNetwork", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (neutron): query " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(queryNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryNetwork", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
+ "QueryNetwork", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryNetwork", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
if (netInfo == null) {
String error = "Update Nework: Network " + networkId
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ + " does not exist in "
+ + cloudSiteId
+ + "/"
+ + tenantId;
+ LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Network not found");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
// Does not exist. Throw an exception (can't update a non-existent network)
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
long updateNetworkStarttime = System.currentTimeMillis();
try {
netInfo = neutron.updateNetwork(cloudSiteId,
- tenantId,
- networkId,
- neutronNetworkType,
- physicalNetworkName,
- vlans);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateNetwork", null);
+ tenantId,
+ networkId,
+ neutronNetworkType,
+ physicalNetworkName,
+ vlans);
+ LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "UpdateNetwork", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack", "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me);
- LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "Openstack",
+ "updateNetwork", MsoLogger.ErrorCode.DataError, "Exception - updateNetwork", me);
+ LOGGER.recordMetricEvent(updateNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateNetwork", null);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
@@ -894,7 +943,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} else if ("HEAT".equals(mode)) {
// Use an MsoHeatUtils for all Heat commands
- MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
+ MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
// First, look up to see that the Network already exists.
// For Heat-based orchestration, the networkId is the network Stack ID.
@@ -902,30 +952,37 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long queryStackStarttime = System.currentTimeMillis();
try {
heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", null);
+ LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "QueryStack", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat): query " + networkName
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
- LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null);
+ LOGGER.error(MessageEnum.RA_QUERY_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack",
+ "queryStack", MsoLogger.ErrorCode.DataError, "Exception - QueryStack", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
if (heatStack == null || (heatStack.getStatus() == HeatStatus.NOTFOUND)) {
String error = "UpdateNetwork: Stack " + networkName
- + " does not exist in "
- + cloudSiteId
- + "/"
- + tenantId;
- LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Network not found");
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ + " does not exist in "
+ + cloudSiteId
+ + "/"
+ + tenantId;
+ LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "OpenStack",
+ "queryStack", MsoLogger.ErrorCode.DataError, "Network not found");
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
// Network stack does not exist. Return an error
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
@@ -943,7 +1000,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
try {
previousVlans.add(Integer.parseInt(vlan));
} catch (NumberFormatException e) {
- LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "", MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e);
+ LOGGER.warn(MessageEnum.RA_VLAN_PARSE, networkId, vlansParam, "", "",
+ MsoLogger.ErrorCode.DataError, "Exception - VLAN parse", e);
}
}
}
@@ -952,12 +1010,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Ready to deploy the updated Network via Heat
//HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
- HeatTemplate heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery (networkResource.getHeatTemplateArtifactUUID());
+ HeatTemplate heatTemplate = db
+ .getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
if (heatTemplate == null) {
String error = "Network error - undefined Heat Template. Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType, "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError, "Network error - undefined Heat Template. Network Type=" + networkType);
+ LOGGER.error(MessageEnum.RA_PARAM_NOT_FOUND, "Heat Template", "Network Type", networkType,
+ "OpenStack", "getHeatTemplate", MsoLogger.ErrorCode.DataError,
+ "Network error - undefined Heat Template. Network Type=" + networkType);
alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest,
+ error);
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
@@ -970,23 +1032,25 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
boolean aic3template = false;
String aic3nw = AIC3_NW;
try {
- aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER).getProperty(AIC3_NW_PROPERTY, AIC3_NW);
+ aic3nw = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_NETWORK_ADAPTER)
+ .getProperty(AIC3_NW_PROPERTY, AIC3_NW);
} catch (MsoPropertiesException e) {
String error = "Unable to get properties:" + MSO_PROP_NETWORK_ADAPTER;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to get properties", e);
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - Unable to get properties", e);
}
if (template.contains(aic3nw))
aic3template = true;
// Build the common set of HEAT template parameters
Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType,
- networkName,
- physicalNetworkName,
- vlans,
- routeTargets,
- shared,
- external,
- aic3template);
+ networkName,
+ physicalNetworkName,
+ vlans,
+ routeTargets,
+ shared,
+ external,
+ aic3template);
// Validate (and update) the input parameters against the DB definition
// Shouldn't happen unless DB config is wrong, since all networks use same inputs
@@ -994,9 +1058,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
stackParams = heat.validateStackParams(stackParams, heatTemplate);
} catch (IllegalArgumentException e) {
String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType;
- LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error");
+ LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork: Configuration Error");
alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, error);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ error);
throw new NetworkException(error, MsoExceptionCategory.INTERNAL, e);
}
@@ -1010,14 +1076,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network (heat): type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeSubnets ", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergeSubnets ", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1028,14 +1097,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat) mergePolicyRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergePolicyRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergePolicyRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1046,14 +1118,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "UpdateNetwork (heat) mergeRouteTableRefs type " + neutronNetworkType
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - UpdateNetwork mergeRouteTableRefs", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, error);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, neutronNetworkType.toString(), cloudSiteId,
+ tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError,
+ "Exception - UpdateNetwork mergeRouteTableRefs", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError, error);
throw new NetworkException(me);
}
}
@@ -1063,19 +1138,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long updateStackStarttime = System.currentTimeMillis();
try {
heatStack = heat.updateStack(cloudSiteId,
- tenantId,
- networkId,
- template,
- stackParams,
- true,
- heatTemplate.getTimeoutMinutes());
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "UpdateStack", null);
+ tenantId,
+ networkId,
+ template,
+ stackParams,
+ true,
+ heatTemplate.getTimeoutMinutes());
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "UpdateStack", null);
} catch (MsoException me) {
me.addContext(UPDATE_NETWORK_CONTEXT);
String error = "Update Network: " + networkId + " in " + cloudSiteId + "/" + tenantId + ": " + me;
- LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
- LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - update network", me);
- LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
+ LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null);
+ LOGGER.error(MessageEnum.RA_UPDATE_NETWORK_ERR, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.DataError, "Exception - update network", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
throw new NetworkException(me);
}
@@ -1101,10 +1181,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Reach this point if createStack is successful.
// Populate remaining rollback info and response parameters.
networkRollback.setNetworkStackId(heatStack.getCanonicalName());
- if(null != outputs) {
+ if (null != outputs) {
networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID));
- }
- else {
+ } else {
LOGGER.debug("outputs is NULL");
}
networkRollback.setNetworkType(networkType);
@@ -1117,8 +1196,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
LOGGER.debug("Network " + networkId + " successfully updated via HEAT");
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully updated network");
return;
@@ -1472,97 +1549,102 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
long startTime = System.currentTimeMillis ();
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
- if (isNullOrEmpty (cloudSiteId)
- || isNullOrEmpty(tenantId)
- || isNullOrEmpty(networkId)) {
+ try (CatalogDatabase db = getCatalogDB()) {
+ if (isNullOrEmpty(cloudSiteId)
+ || isNullOrEmpty(tenantId)
+ || isNullOrEmpty(networkId)) {
String error = "Missing mandatory parameter cloudSiteId, tenantId or networkId";
- LOGGER.error (MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new NetworkException (error, MsoExceptionCategory.USERDATA);
+ LOGGER.error(MessageEnum.RA_MISSING_PARAM, "cloudSiteId or tenantId or networkId", "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Missing mandatory parameter cloudSiteId, tenantId or networkId");
+ LOGGER
+ .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
+ throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource (networkType);
- }
- else if (!isNullOrEmpty(networkType))
- {
+ networkResource = db.getNetworkResource(networkType);
+ } else if (!isNullOrEmpty(networkType)) {
networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
}
String mode = "";
if (networkResource != null) {
- LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ());
+ LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
- mode = networkResource.getOrchestrationMode ();
+ mode = networkResource.getOrchestrationMode();
}
- if (NEUTRON_MODE.equals (mode)) {
+ if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
- long deleteNetworkStarttime = System.currentTimeMillis ();
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
// was not found. So don't bother to query first.
- boolean deleted = neutron.deleteNetwork (networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null);
+ boolean deleted = neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteNetwork", null);
networkDeleted.value = deleted;
} catch (MsoException me) {
- me.addContext ("DeleteNetwork");
- String error = "Delete Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext("DeleteNetwork");
+ String error = "Delete Network (neutron): " + networkId
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
+ LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Delete Network (neutron)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
} else { // DEFAULT to ("HEAT".equals (mode))
- long deleteStackStarttime = System.currentTimeMillis ();
+ long deleteStackStarttime = System.currentTimeMillis();
// Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
try {
// The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted.
// So query first to report back if stack WAS deleted or just NOTOFUND
- StackInfo heatStack = null;
- heatStack = heat.queryStack(cloudSiteId, tenantId, networkId);
- if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND)
- {
- heat.deleteStack (tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null);
- networkDeleted.value = true;
- }
- else
- {
- networkDeleted.value = false;
- }
+ StackInfo heatStack = null;
+ heatStack = heat.queryStack(cloudSiteId, tenantId, networkId);
+ if (heatStack != null && heatStack.getStatus() != HeatStatus.NOTFOUND) {
+ heat.deleteStack(tenantId, cloudSiteId, networkId, true);
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteStack", null);
+ networkDeleted.value = true;
+ } else {
+ networkDeleted.value = false;
+ }
} catch (MsoException me) {
- me.addContext ("DeleteNetwork");
- String error = "Delete Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ me.addContext("DeleteNetwork");
+ String error = "Delete Network (heat): " + networkId
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
+ LOGGER.error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "",
+ MsoLogger.ErrorCode.DataError, "Delete Network (heat)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
}
- } finally {
- db.close ();
}
// On success, nothing is returned.
@@ -1608,80 +1690,89 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// rollback may be null (e.g. if network already existed when Create was called)
// Get a handle to the Catalog Database
- CatalogDatabase db = getCatalogDB ();
// Make sure DB connection is always closed
- try {
+ try (CatalogDatabase db = getCatalogDB()) {
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
if (isNullOrEmpty(modelCustomizationUuid)) {
- networkResource = db.getNetworkResource (networkType);
- }
- else
- {
+ networkResource = db.getNetworkResource(networkType);
+ } else {
networkResource = db.getNetworkResourceByModelCustUuid(modelCustomizationUuid);
}
String mode = "";
if (networkResource != null) {
- LOGGER.debug ("Got Network definition from Catalog: " + networkResource.toString ());
+ LOGGER.debug("Got Network definition from Catalog: " + networkResource.toString());
- mode = networkResource.getOrchestrationMode ();
+ mode = networkResource.getOrchestrationMode();
}
- if (rollback.getNetworkCreated ()) {
+ if (rollback.getNetworkCreated()) {
// Rolling back a newly created network, so delete it.
- if (NEUTRON_MODE.equals (mode)) {
+ if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
- long deleteNetworkStarttime = System.currentTimeMillis ();
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
// was not found. So don't bother to query first.
- neutron.deleteNetwork (networkId, tenantId, cloudSiteId);
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteNetwork", null);
+ neutron.deleteNetwork(networkId, tenantId, cloudSiteId);
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteNetwork", null);
} catch (MsoException me) {
- me.addContext ("RollbackNetwork");
+ me.addContext("RollbackNetwork");
String error = "Rollback Network (neutron): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteNetworkStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteNetwork", null);
+ LOGGER
+ .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (neutron)",
+ me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
} else { // DEFAULT to if ("HEAT".equals (mode))
// Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,cloudConfigFactory);
- long deleteStackStarttime = System.currentTimeMillis ();
+ MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
+ long deleteStackStarttime = System.currentTimeMillis();
try {
// The deleteStack function in MsoHeatUtils returns success if the stack
// was not found. So don't bother to query first.
- heat.deleteStack (tenantId, cloudSiteId, networkId, true);
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "DeleteStack", null);
+ heat.deleteStack(tenantId, cloudSiteId, networkId, true);
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.COMPLETE,
+ MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
+ "DeleteStack", null);
} catch (MsoException me) {
- me.addContext ("RollbackNetwork");
+ me.addContext("RollbackNetwork");
String error = "Rollback Network (heat): " + networkId
- + " in "
- + cloudSiteId
- + "/"
- + tenantId
- + ": "
- + me;
- LOGGER.recordMetricEvent (deleteStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
- LOGGER.error (MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new NetworkException (me);
+ + " in "
+ + cloudSiteId
+ + "/"
+ + tenantId
+ + ": "
+ + me;
+ LOGGER.recordMetricEvent(deleteStackStarttime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "DeleteStack", null);
+ LOGGER
+ .error(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "OpenStack", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Rollback Network (heat)", me);
+ LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, error);
+ throw new NetworkException(me);
}
}
}
- } finally {
- db.close ();
}
LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully rolled back network");
return;
@@ -1747,20 +1838,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
stackParams.put (VLANS, csl);
}
if (routeTargets != null && !routeTargets.isEmpty()) {
- StringBuilder buf = new StringBuilder ();
+ StringBuilder sb = new StringBuilder ();
String sep = "";
for (String rt : routeTargets) {
if (!isNullOrEmpty(rt))
{
if (aic3template)
- buf.append (sep).append ("target:" + rt);
+ sb.append(sep).append("target:").append(rt);
else
- buf.append (sep).append (rt);
+ sb.append (sep).append (rt);
sep = ",";
}
}
- String csl = buf.toString ();
+ String csl = sb.toString ();
stackParams.put ("route_targets", csl);
}
@@ -1985,16 +2076,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n"
+ " value: {get_resource: subnet_%subnetId%}\n";
- String curR;
+ StringBuilder curR;
String curO;
StringBuilder resourcesBuf = new StringBuilder ();
StringBuilder outputsBuf = new StringBuilder ();
for (Subnet subnet : subnets) {
// build template for each subnet
- curR = resourceTempl;
+ curR = new StringBuilder(resourceTempl);
if (subnet.getSubnetId () != null) {
- curR = curR.replace ("%subnetId%", subnet.getSubnetId ());
+ curR = new StringBuilder(curR.toString().replace("%subnetId%", subnet.getSubnetId()));
} else {
String error = "Missing Required AAI SubnetId for subnet in HEAT Template";
LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required AAI ID for subnet in HEAT Template");
@@ -2002,13 +2093,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
if (subnet.getSubnetName () != null) {
- curR = curR.replace ("%name%", subnet.getSubnetName ());
+ curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetName()));
} else {
- curR = curR.replace ("%name%", subnet.getSubnetId ());
+ curR = new StringBuilder(curR.toString().replace("%name%", subnet.getSubnetId()));
}
if (subnet.getCidr () != null) {
- curR = curR.replace ("%cidr%", subnet.getCidr ());
+ curR = new StringBuilder(curR.toString().replace("%cidr%", subnet.getCidr()));
} else {
String error = "Missing Required cidr for subnet in HEAT Template";
LOGGER.error (MessageEnum.RA_MISSING_PARAM, error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Missing Required cidr for subnet in HEAT Template");
@@ -2016,23 +2107,23 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
if (subnet.getIpVersion () != null) {
- curR = curR + " ip_version: " + subnet.getIpVersion () + "\n";
+ curR.append(" ip_version: " + subnet.getIpVersion() + "\n");
}
if (subnet.getEnableDHCP () != null) {
- curR = curR + " enable_dhcp: " + Boolean.toString (subnet.getEnableDHCP ()) + "\n";
+ curR.append(" enable_dhcp: ").append(Boolean.toString(subnet.getEnableDHCP())).append("\n");
}
if (subnet.getGatewayIp () != null && !subnet.getGatewayIp ().isEmpty() ) {
- curR = curR + " gateway_ip: " + subnet.getGatewayIp () + "\n";
+ curR.append(" gateway_ip: " + subnet.getGatewayIp() + "\n");
}
if (subnet.getAllocationPools() != null) {
- curR = curR + " allocation_pools:\n";
+ curR.append(" allocation_pools:\n");
for (Pool pool : subnet.getAllocationPools())
{
if (!isNullOrEmpty(pool.getStart()) && !isNullOrEmpty(pool.getEnd()))
{
- curR = curR + " - start: " + pool.getStart () + "\n";
- curR = curR + " end: " + pool.getEnd () + "\n";
+ curR.append(" - start: " + pool.getStart() + "\n");
+ curR.append(" end: " + pool.getEnd() + "\n");
}
}
}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
index e96e416d65..ae198142bd 100644
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
+++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
@@ -71,7 +71,7 @@ public class NetworkBeansTest {
contrailSubnet.setAddrFromStart(true);
contrailSubnet.setDefaultGateway("defaultGateway");
contrailSubnet.setEnableDhcp(true);
- contrailSubnet.setPools(new ArrayList<ContrailSubnetPool>());
+ contrailSubnet.setPools(new ArrayList<>());
contrailSubnet.setSubnet(new ContrailSubnetIp());
contrailSubnet.setSubnetName("subnetName");
contrailSubnet.getAllocationPools();
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml
index ed8b2b3b88..8bec34e785 100644
--- a/adapters/mso-requests-db-adapter/pom.xml
+++ b/adapters/mso-requests-db-adapter/pom.xml
@@ -2,12 +2,12 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-requests-db-adapter</artifactId>
<packaging>war</packaging>
@@ -15,7 +15,7 @@
<dependencies>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
<version>${project.version}</version>
</dependency>
@@ -40,7 +40,7 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
@@ -85,7 +85,7 @@
<version>2.2.7</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index 0b404d76bd..99f6e86b00 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -333,7 +333,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
*
* @param serviceId
* @param operationId
- * @param resourceUUID
+ * @param resourceTemplateUUID
* @return
* @throws MsoRequestsDbException
* @since ONAP Amsterdam Release
@@ -350,7 +350,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
*
* @param serviceId
* @param operationId
- * @param resourceUUID
+ * @param resourceTemplateUUID
* @param operationType
* @param resourceInstanceID
* @param jobId
@@ -363,13 +363,13 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
*/
@Override
public void updateResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID,
- String operType, String resourceInstanceID, String jobId, String status, String progress,
+ String operationType, String resourceInstanceID, String jobId, String status, String progress,
String errorCode, String statusDescription) throws MsoRequestsDbException {
ResourceOperationStatus resStatus = new ResourceOperationStatus();
resStatus.setServiceId(serviceId);
resStatus.setOperationId(operationId);
resStatus.setResourceTemplateUUID(resourceTemplateUUID);
- resStatus.setOperType(operType);
+ resStatus.setOperType(operationType);
resStatus.setResourceInstanceID(resourceInstanceID);
resStatus.setJobId(jobId);
resStatus.setStatus(status);
diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml
index e7cb4d5318..b0457e968e 100644
--- a/adapters/mso-sdnc-adapter/pom.xml
+++ b/adapters/mso-sdnc-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-sdnc-adapter</artifactId>
<packaging>war</packaging>
<name>mso-sdnc-adapter</name>
@@ -67,7 +67,7 @@
</build>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
@@ -91,12 +91,12 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java
index 97f30bea6b..55a2156c50 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/impl/SDNCRestClient.java
@@ -142,7 +142,7 @@ public class SDNCRestClient implements Runnable {
DataOutputStream out = null;
BufferedReader in = null;
SDNCResponse sdncResp = new SDNCResponse(rt.getReqId());
- StringBuffer response = new StringBuffer();
+ StringBuilder response = new StringBuilder();
msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", "");
msoLogger.debug("SDNC Request Body:\n" + sdncReqBody);
@@ -197,7 +197,7 @@ public class SDNCRestClient implements Runnable {
//default
sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
String respMsg = "Error processing request to SDNC. ";
- String sdncErrMsg = "";
+ StringBuilder sdncErrMsg = new StringBuilder();
if (e instanceof java.net.SocketTimeoutException )
{
@@ -229,7 +229,7 @@ public class SDNCRestClient implements Runnable {
String eType = null;
try {
eType = xpath.evaluate("error-type", error);
- sdncErrMsg = ". SDNC Returned-[error-type:" + eType;
+ sdncErrMsg = new StringBuilder(". SDNC Returned-[error-type:" + eType);
} catch (Exception e3) {
msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
}
@@ -237,7 +237,7 @@ public class SDNCRestClient implements Runnable {
String eTag = null;
try {
eTag = xpath.evaluate( "error-tag", error);
- sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag;
+ sdncErrMsg.append(", error-tag:").append(eTag);
} catch (Exception e3) {
msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
}
@@ -245,7 +245,7 @@ public class SDNCRestClient implements Runnable {
String eMsg = null;
try {
eMsg = xpath.evaluate("error-message", error);
- sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]";
+ sdncErrMsg.append(", error-message:").append(eMsg).append("]");
} catch (Exception e3) {
msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3);
}
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java
index 262d23bd09..fa257164cf 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/openecomp/mso/adapters/sdnc/sdncrest/SDNCConnector.java
@@ -154,12 +154,7 @@ public abstract class SDNCConnector {
LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", "");
return createResponseFromContent(statusCode, statusMessage, responseContent, rt);
- } catch (SocketTimeoutException e) {
- String errMsg = "Request to SDNC timed out";
- logError(errMsg, e);
- return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt);
-
- } catch (ConnectTimeoutException e) {
+ } catch (SocketTimeoutException | ConnectTimeoutException e) {
String errMsg = "Request to SDNC timed out";
logError(errMsg, e);
return createErrorResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg, rt);
@@ -257,7 +252,7 @@ public abstract class SDNCConnector {
// </error>
// </errors>
- String output = null;
+ StringBuilder output = null;
try {
XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -306,9 +301,9 @@ public abstract class SDNCConnector {
if (!info.isEmpty()) {
if (output == null) {
- output = "[" + info + "]";
+ output = new StringBuilder("[" + info + "]");
} else {
- output += " [" + info + "]";
+ output.append(" [").append(info).append("]");
}
}
}
@@ -317,6 +312,6 @@ public abstract class SDNCConnector {
MsoLogger.ErrorCode.DataError, "Exception while analyzing errors", e);
}
- return output;
+ return output.toString();
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
new file mode 100644
index 0000000000..fa96b7983e
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.sdnc;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest;
+import org.openecomp.mso.adapters.sdnc.RequestHeader;
+
+
+public class SDNCAdapterRequestTest {
+
+ static Object sd= new SDNCAdapterRequest();
+ static RequestHeader rh=new RequestHeader();
+
+ @BeforeClass
+ public static final void RHeader()
+ {
+ rh.setCallbackUrl("callback");
+ rh.setMsoAction ("action");
+ rh.setRequestId ("reqid");
+ rh.setSvcAction ("svcAction");
+ rh.setSvcInstanceId ("svcId");
+ rh.setSvcOperation ("op");
+ }
+ @Test
+ public final void testtoString(){
+ ((SDNCAdapterRequest) sd).setRequestData("data");
+ ((SDNCAdapterRequest) sd).setRequestHeader(rh);
+ assert (((SDNCAdapterRequest) sd).getRequestData()!= null) ;
+ assert(((SDNCAdapterRequest) sd).getRequestData().equals("data"));
+ assert(((SDNCAdapterRequest) sd).getRequestHeader().equals(rh));
+ }
+
+}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
new file mode 100644
index 0000000000..88d2b950b9
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
@@ -0,0 +1,47 @@
+/*
+* ============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.sdnc.client;
+
+import org.junit.Test;
+import org.openecomp.mso.adapters.sdnc.client.CallbackHeader;
+
+public class CallbackHeaderTest {
+
+ static CallbackHeader cb = new CallbackHeader();
+
+ @Test
+ public final void testCallbackHeader() {
+ cb.setRequestId("413658f4-7f42-482e-b834-23a5c15657da-1474471336781");
+ cb.setResponseCode("200");
+ cb.setResponseMessage("OK");
+ assert (cb.getRequestId() != null);
+ assert (cb.getResponseCode() != null);
+ assert (cb.getResponseMessage() != null);
+ assert (cb.getRequestId().equals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781"));
+ assert (cb.getResponseCode().equals("200"));
+ assert (cb.getResponseMessage().equals("OK"));
+ }
+
+ @Test
+ public void testtoString() {
+ assert (cb.toString() != null);
+ }
+}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
new file mode 100644
index 0000000000..63aa49cf54
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.sdnc.client;
+
+import org.junit.Test;
+import org.openecomp.mso.adapters.sdnc.client.CallbackHeader;
+import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest;
+
+public class SDNCAdapterCallbackRequestTest {
+
+ static SDNCAdapterCallbackRequest sdc = new SDNCAdapterCallbackRequest();
+ static CallbackHeader ch = new CallbackHeader("413658f4-7f42-482e-b834-23a5c15657da-1474471336781","200","OK");
+
+ @Test
+ public void testSDNCAdapterCallbackRequest()
+ {
+ sdc.setCallbackHeader(ch);
+ sdc.setRequestData("data");
+ assert(sdc.getCallbackHeader()!=null);
+ assert(sdc.getRequestData()!=null);
+ assert(sdc.getCallbackHeader().equals(ch));
+ assert(sdc.getRequestData().equals("data"));
+
+ }
+
+ @Test
+ public void testtoString()
+ {
+ assert(ch.toString()!=null);
+ }
+
+}
+
+
diff --git a/adapters/mso-tenant-adapter/pom.xml b/adapters/mso-tenant-adapter/pom.xml
index 1479b2865e..916c3a7afd 100644
--- a/adapters/mso-tenant-adapter/pom.xml
+++ b/adapters/mso-tenant-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-tenant-adapter</artifactId>
<packaging>war</packaging>
<name>mso-tenant-adapter</name>
@@ -72,7 +72,7 @@
<version>2.2.7</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
@@ -119,12 +119,12 @@
</build>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
@@ -147,7 +147,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java
index 5d0752a3af..2a33ebc50c 100644
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java
+++ b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java
@@ -39,11 +39,11 @@ public class TenantTest {
MsoTenantAdapter tenantAdapter = new MsoTenantAdapterImpl();
- Holder<String> tenantId = new Holder<String>();
- Holder<String> tenantName = new Holder<String>();
- Holder<Map<String,String>> tenantMetadata = new Holder<Map<String,String>>();
- Holder<Boolean> tenantDeleted = new Holder<Boolean>();
- Holder<TenantRollback> rollback = new Holder<TenantRollback>();
+ Holder<String> tenantId = new Holder<>();
+ Holder<String> tenantName = new Holder<>();
+ Holder<Map<String,String>> tenantMetadata = new Holder<>();
+ Holder<Boolean> tenantDeleted = new Holder<>();
+ Holder<TenantRollback> rollback = new Holder<>();
try {
tenantAdapter.queryTenant (cloudId, "934a4ac9c4bd4b8d9d8ab3ef900281b0", null, tenantId, tenantName, tenantMetadata);
diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml
index abd8ce4c29..e851edf72e 100644
--- a/adapters/mso-vfc-adapter/pom.xml
+++ b/adapters/mso-vfc-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vfc-adapter</artifactId>
<packaging>war</packaging>
<name>mso-vfc-adapter</name>
@@ -38,12 +38,12 @@
<version>2.0</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
@@ -72,12 +72,12 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
index 48da1aba71..5f779dd085 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
@@ -60,7 +60,7 @@ public class VfcAdapterRest {
/**
* Create a NS <br>
*
- * @param servletReq the http request
+ * @param data the http request
* @return
* @since ONAP Amsterdam Release
*/
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
index 61966d07f2..30d42ae387 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
@@ -39,7 +39,7 @@ public class ApplicationException extends Exception {
* </p>
*
* @param errorCode error status
- * @param errorDetail error detail
+ * @param errorMsg error detail
* @since ONAP Amsterdam Release 2017-9-6
*/
public ApplicationException(int errorCode, String errorMsg) {
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
index afee1bbfaa..fcbbf8515a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java
@@ -166,12 +166,7 @@ public class RestfulUtil {
method = null;
return createResponse(statusCode, responseContent);
- } catch(SocketTimeoutException e) {
- String errMsg = "Request to VFC timed out";
- logError(errMsg, e);
- return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);
-
- } catch(ConnectTimeoutException e) {
+ } catch(SocketTimeoutException | ConnectTimeoutException e) {
String errMsg = "Request to VFC timed out";
logError(errMsg, e);
return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg);
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
index c79d09e09a..13727bdc49 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
@@ -47,7 +47,7 @@ public class ValidateUtil {
* Assert String parameter.<br/>
*
* @param paramValue parameter data
- * @param name of parameter
+ * @param paramName parameter name
* @since ONAP Amsterdam Release 2017-9-6
*/
public static void assertStringNotNull(String paramValue, String paramName)
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
index 95d3bf610f..759ceedd0f 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
@@ -60,7 +60,7 @@ public class VfcAdapterTest {
/**
* mock get request body <br>
*
- * @param request
+ * @param fileName
* @return
* @since ONAP Amsterdam Release
*/
@@ -71,7 +71,6 @@ public class VfcAdapterTest {
/**
* Mock the request body form a file <br>
*
- * @param fileName
* @since ONAP Amsterdam Release
*/
private void mockRestfulUtil() {
diff --git a/adapters/mso-vnf-adapter-async-client/pom.xml b/adapters/mso-vnf-adapter-async-client/pom.xml
index 4a20257b4a..e6217fc1c0 100644
--- a/adapters/mso-vnf-adapter-async-client/pom.xml
+++ b/adapters/mso-vnf-adapter-async-client/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter-async-client</artifactId>
<packaging>jar</packaging>
<name>mso-vnf-adapter-async-client</name>
diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml
index 9116e57a11..9a290f4f00 100644
--- a/adapters/mso-vnf-adapter/pom.xml
+++ b/adapters/mso-vnf-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter</artifactId>
<packaging>war</packaging>
<name>mso-vnf-adapter</name>
@@ -56,7 +56,7 @@
</executions>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
@@ -107,17 +107,17 @@
</build>
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapter-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnf-adapter-async-client</artifactId>
<version>${project.version}</version>
</dependency>
@@ -140,7 +140,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
@@ -157,7 +157,7 @@
<scope>test</scope>
</dependency>
<!-- <dependency> -->
- <!-- <groupId>org.openecomp.so</groupId> -->
+ <!-- <groupId>org.onap.so</groupId> -->
<!-- <artifactId>mso-catalog-db</artifactId> -->
<!-- <version>${project.version}</version> -->
<!-- </dependency> -->
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
index 4842580d85..5c654298fb 100644
--- 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
@@ -371,8 +371,9 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
* @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
+ * @param notificationUrl the target URL for asynchronous response
*/
@Override
public void deleteVnfA (String cloudSiteId,
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
index 7fe09be2b6..9022c26ccd 100644
--- 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
@@ -295,7 +295,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
vnfExists.value = Boolean.FALSE;
status.value = VnfStatus.NOTFOUND;
vnfId.value = null;
- outputs.value = new HashMap <String, String> (); // Return as an empty map
+ outputs.value = new HashMap<>(); // Return as an empty map
LOGGER.debug ("VNF " + vnfName + " not found");
} else {
@@ -465,7 +465,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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;
+ long waitTimeMs = 10000L;
try {
String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId};
String[] envp = null;
@@ -508,7 +508,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
LOGGER.debug("Exception :",e);
outputString = "Unable to call toString() on the value for " + str;
}
- sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'");
+ sb.append("\t\nitem ").append(i++).append(": '").append(str).append("'='").append(outputString)
+ .append("'");
}
}
LOGGER.debug(sb.toString());
@@ -524,7 +525,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
sb.append("\tEMPTY");
} else {
for (String str : inputs.keySet()) {
- sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str));
+ sb.append("\titem ").append(i++).append(": ").append(str).append("=").append(inputs.get(str));
}
}
LOGGER.debug(sb.toString());
@@ -535,8 +536,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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(),jpe);
} catch (Exception e) {
LOGGER.debug("Error converting json to string " + e.getMessage(),e);
}
@@ -547,7 +546,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (objectMap == null) {
return null;
}
- Map<String, String> stringMap = new HashMap<String, String>();
+ Map<String, String> stringMap = new HashMap<>();
for (String key : objectMap.keySet()) {
if (!stringMap.containsKey(key)) {
Object obj = objectMap.get(key);
@@ -822,9 +821,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Ready to deploy the new VNF
- CatalogDatabase db = CatalogDatabase.getInstance();
-
- try {
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
// Retrieve the VF
VfModule vf = null;
VnfResource vnfResource = null;
@@ -838,10 +835,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//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;
+ 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);
+ "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());
@@ -852,7 +853,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} 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");
+ LOGGER.debug(
+ "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
}
}
}
@@ -911,12 +913,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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());
+ + vnfResource.toString());
}
// By here - we have either a vf or vnfResource
@@ -929,7 +932,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//vnfResource = db.getVnfResourceById(vnfResourceId);
vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ LOGGER.debug(
+ "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
}
}
}
@@ -940,7 +944,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = vnfResource.getAicVersionMin();
maxVersionVnf = vnfResource.getAicVersionMax();
} catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e);
+ LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e);
minVersionVnf = null;
maxVersionVnf = null;
}
@@ -973,17 +977,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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());
+ && (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");
+ 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);
}
@@ -995,7 +1008,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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.");
+ LOGGER.debug(
+ "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked.");
}
// End Version check 1607
@@ -1017,7 +1031,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
} else {
if (isVolumeRequest) {
- LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
+ LOGGER.debug(
+ "DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?");
/*
VnfComponent vnfComponent = null;
vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME");
@@ -1039,11 +1054,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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);
+ 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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
@@ -1051,11 +1069,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ "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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
}
LOGGER.debug("Got HEAT Template from DB");
@@ -1064,45 +1085,49 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String heatEnvironmentString = null;
if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) {
- LOGGER.debug ("about to call getHeatEnvironment with :" + 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);
+ + ", 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);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ 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);
+ 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);
+ LOGGER.debug("no environment parameter found for this Type " + vfModuleType);
}
// 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 <> ();
+ 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 ()) {
+ 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);
+ LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
+ nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
}
} else {
- LOGGER.debug ("No nested templates found - nothing to do here");
+ LOGGER.debug("No nested templates found - nothing to do here");
nestedTemplatesChecked = null; // just to make sure
}
@@ -1114,25 +1139,29 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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);
+ 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);
+ 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!");
+ 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="
+ LOGGER.debug(
+ "In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ vf.getModelUUID());
heatFiles = db
- .getHeatFilesForVfModule(vf.getModelUUID());
+ .getHeatFilesForVfModule(vf.getModelUUID());
}
if (heatFiles != null) {
// add these to stack - to be done in createStack
@@ -1146,19 +1175,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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;
+ 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);
+ 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);
+ 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);
+ + heatFileBody);
heatFilesObjects.put(heatFileNameChecked, heatFileBody);
}
} else {
@@ -1166,12 +1200,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
heatFilesObjects = null;
}
} else {
- LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
+ LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES");
}
// Check that required parameters have been supplied
- String missingParams = null;
- List <String> paramList = new ArrayList <> ();
+ 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.
@@ -1180,23 +1214,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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)) {
+ 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);
+ 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);
+ 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:")) {
+ 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");
mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
@@ -1224,7 +1258,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
int cntr = 0;
try {
for (HeatTemplateParam htp : heatTemplate.getParameters()) {
- sb.append("param[" + cntr++ + "]=" + htp.getParamName());
+ sb.append("param[").append(cntr++).append("]=").append(htp.getParamName());
parameterNames.add(htp.getParamName());
if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
aliasToParam.put(htp.getParamAlias(), htp.getParamName());
@@ -1234,7 +1268,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
LOGGER.debug(sb.toString());
} catch (Exception e) {
- LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),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
@@ -1248,42 +1282,45 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 ());
+ 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 ()))) {
+ 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");
+ 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");
+ 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 ());
+ LOGGER.debug("adding to missing parameters list: " + parm.getParamName());
if (missingParams == null) {
- missingParams = parm.getParamName ();
+ missingParams = new StringBuilder(parm.getParamName());
} else {
- missingParams += "," + parm.getParamName ();
+ missingParams.append("," + parm.getParamName());
}
}
}
- paramList.add (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, "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);
+ 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");
+ LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
}
} else {
- LOGGER.debug ("No missing parameters found - ok to proceed");
+ 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
@@ -1293,13 +1330,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate ();
- template = template.replaceAll ("\r\n", "\n");
+ 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 ();
+ long createStackStarttime = System.currentTimeMillis();
try {
// heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true,
// heatTemplate.getTimeoutMinutes());
@@ -1309,47 +1346,59 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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");
+ 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);
+ 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.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");
+ 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");
+ 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);
+ LOGGER.debug("unhandled exception in create VF", e);
throw new VnfException("Exception during create VF " + e.getMessage());
- } finally {
- // Make sure DB session is closed
- db.close ();
}
+ // Make sure DB session is closed
// Reach this point if createStack is successful.
// Populate remaining rollback info and response parameters.
@@ -1441,19 +1490,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName;
MsoLogger.setServiceName (serviceName);
- StringBuilder sbInit = new StringBuilder();
- sbInit.append("updateVfModule: \n");
- sbInit.append("cloudSiteId=" + cloudSiteId + "\n");
- sbInit.append("tenantId=" + tenantId + "\n");
- sbInit.append("vnfType=" + vnfType + "\n");
- sbInit.append("vnfVersion=" + vnfVersion + "\n");
- sbInit.append("vnfName=" + vnfName + "\n");
- sbInit.append("requestType=" + requestType + "\n");
- sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n");
- sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n");
- sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n");
- sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n");
- LOGGER.debug(sbInit.toString());
+ 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;
@@ -1634,10 +1681,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Ready to deploy the new VNF
// Get a handle to the Catalog Database
- CatalogDatabase db = CatalogDatabase.getInstance();
// Make sure DB session is closed
- try {
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
// Retrieve the VF definition
VnfResource vnfResource = null;
VfModule vf = null;
@@ -1652,20 +1698,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} else {
LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!");
}
- if (vf == null) {
+ 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.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 ());
+ 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("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
+ LOGGER.debug(
+ "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request");
}
}
@@ -1677,7 +1725,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//vnfResource = db.getVnfResourceById(vnfResourceId);
vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid);
if (vnfResource == null) {
- LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
+ LOGGER
+ .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now...");
}
}
String minVersionVnf = null;
@@ -1687,35 +1736,42 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
minVersionVnf = vnfResource.getAicVersionMin();
maxVersionVnf = vnfResource.getAicVersionMax();
} catch (Exception e) {
- LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",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());
+ && (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");
+ 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);
}
@@ -1741,11 +1797,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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);
+ 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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
} else {
heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid);
@@ -1753,90 +1813,97 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
if (heatTemplate == null) {
String error = "Update VNF: undefined Heat Template. VF="
- + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid;
+ + 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);
+ "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);
+ MsoAlarmLogger.CRITICAL, error);
throw new VnfException(error, MsoExceptionCategory.INTERNAL);
}
- LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ());
+ 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 + ":");
+ 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);
+ + ", 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);
+ alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error);
- throw new VnfException (error, MsoExceptionCategory.INTERNAL);
+ 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);
+ 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("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 <> ();
+ 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 ()) {
+ 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);
+ nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody);
+ LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody);
}
} else {
- LOGGER.debug ("No nested templates found - nothing to do here");
+ 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());
+ LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId="
+ + vf.getModelUUID());
- Map <String, HeatFiles> heatFiles = null;
+ Map<String, HeatFiles> heatFiles = null;
// Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ());
- Map <String, Object> heatFilesObjects = new HashMap <> ();
+ 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);
+ 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);
+ 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="
+ LOGGER.debug(
+ "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId="
+ vf.getModelUUID());
heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID());
@@ -1844,35 +1911,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// 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:");
+ LOGGER.debug("Contents of heatFiles - to be added to files: on stack:");
- for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) {
+ 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;
+ 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);
+ 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);
+ 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);
+ String heatFileBody = value.getFileBody();
+ LOGGER.debug(heatFileName + " -> " + heatFileBody);
+ heatFilesObjects.put(heatFileName, heatFileBody);
}
} else {
- LOGGER.debug ("No heat files found -nothing to do here");
+ LOGGER.debug("No heat files found -nothing to do here");
heatFilesObjects = null;
}
}
// Check that required parameters have been supplied
- String missingParams = null;
- List <String> paramList = new ArrayList <> ();
+ 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.
@@ -1882,23 +1953,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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)) {
+ 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);
+ 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);
+ 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:")) {
+ if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) {
LOGGER.debug("Enhanced environment checking enabled - 1604");
mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString);
StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n");
@@ -1920,12 +1991,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
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 ());
+ 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())) {
@@ -1933,7 +2004,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
JsonNode jsonNode = null;
if ("json".equalsIgnoreCase(parameterType) && inputs != null) {
- if (inputs.containsKey(parm.getParamName()) ) {
+ if (inputs.containsKey(parm.getParamName())) {
hasJson = true;
String jsonString = null;
try {
@@ -1943,12 +2014,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
//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);
+ 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);
+ LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e);
hasJson = false;
jsonNode = null;
}
@@ -1958,77 +2029,78 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
} else if (inputs.containsKey(parm.getParamAlias())) {
hasJson = true;
String jsonString = null;
- try {
+ 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);
+ 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);
+ 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);
- }
+ 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 ())) {
+ 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);
+ 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 ());
+ 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 ();
+ missingParams = new StringBuilder(parm.getParamName());
} else {
- missingParams += "," + parm.getParamName ();
+ missingParams.append("," + parm.getParamName());
}
}
}
- paramList.add (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, "OpenStack", "", MsoLogger.ErrorCode.DataError, error);
- LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error);
- throw new VnfException (error, MsoExceptionCategory.USERDATA);
+ 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");
+ LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block");
}
} else {
- LOGGER.debug ("No missing parameters found - ok to proceed");
+ LOGGER.debug("No missing parameters found - ok to proceed");
}
// Just submit the envt entry as received from the database
@@ -2039,13 +2111,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
// Remove any extraneous parameters (don't throw an error)
if (inputs != null) {
- List <String> extraParams = new ArrayList <> ();
- extraParams.addAll (inputs.keySet ());
+ 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);
+ 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
@@ -2064,54 +2137,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
}
// "Fix" the template if it has CR/LF (getting this from Oracle)
- String template = heatTemplate.getHeatTemplate ();
- template = template.replaceAll ("\r\n", "\n");
+ 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 ();
+ 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);
+ 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);
+ 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");
+ 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);
+ 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);
}
- } finally {
- // Make sure DB session is closed
- db.close ();
}
+ // Make sure DB session is closed
// Reach this point if updateStack is successful.
// Populate remaining rollback info and response parameters.
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
new file mode 100755
index 0000000000..6e06eed702
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduBlueprint.java
@@ -0,0 +1,90 @@
+/*-
+ * ============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=========================================================
+ */
+
+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
new file mode 100755
index 0000000000..3646b292c5
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java
@@ -0,0 +1,130 @@
+/*-
+ * ============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=========================================================
+ */
+
+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
new file mode 100755
index 0000000000..2118eec0a5
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java
@@ -0,0 +1,248 @@
+/*-
+ * ============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=========================================================
+ */
+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
new file mode 100755
index 0000000000..0f4611a2de
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduStatus.java
@@ -0,0 +1,37 @@
+/*-
+ * ============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=========================================================
+ */
+
+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/vnf/test/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java
index a045b00699..acde3153ab 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java
@@ -44,7 +44,7 @@ public class MsoVnfAdapterAsyncImplTest {
try {
instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, "messageId",
+ "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId",
null, "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/test/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java
index 6f01954db3..eec2257c7f 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java
@@ -48,8 +48,8 @@ public class MsoVnfAdapterImplTest {
try {
instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -67,8 +67,8 @@ public class MsoVnfAdapterImplTest {
try {
instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -82,7 +82,7 @@ public class MsoVnfAdapterImplTest {
msoRequest.setServiceInstanceId("12345");
try {
instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<Map<String, String>>());
+ new Holder<>());
} catch (Exception e) {
}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
index f6e79e12a0..d898a6547e 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java
@@ -55,10 +55,10 @@ public class QueryTest {
String cloudId = "MT";
String tenantId = "MSO_Test";
String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vnfId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+ 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);
@@ -82,10 +82,10 @@ public class QueryTest {
String cloudId = "MT";
String tenantId = "MSO_Test";
String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vnfId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+ 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);
@@ -101,10 +101,10 @@ public class QueryTest {
String cloudId = "MT";
String tenantId = "MSO_Test";
String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vnfId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
+ 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/test/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java
index 52e1797531..000ed8aef3 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java
@@ -42,16 +42,16 @@ public class VnfCreateTest {
String tenantName = "John_Test";
String vnfType = "ApacheDemo";
String vnfName = "AdapterTest";
- Map<String,String> inputs = new HashMap<String,String>();
+ 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<String>();
- Holder<Map<String,String>> outputs = new Holder<Map<String,String>>();
- Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>();
+ 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,
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java
index 84f2f2ff57..bbffddfd15 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java
@@ -39,10 +39,10 @@ public class VnfQueryTest {
String cloudId = "MT";
String tenantId = "MSO_Test";
String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<Boolean>();
- Holder<String> vnfId = new Holder<String>();
- Holder<VnfStatus> status = new Holder<VnfStatus>();
- Holder<Map<String,String>> outputs = new Holder<Map<String,String>>();
+ 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,
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
new file mode 100644
index 0000000000..019ae1e3f9
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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
new file mode 100644
index 0000000000..98a00033f7
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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-workflow-message-adapter/pom.xml b/adapters/mso-workflow-message-adapter/pom.xml
index 3501dd5571..46e4a2bc13 100644
--- a/adapters/mso-workflow-message-adapter/pom.xml
+++ b/adapters/mso-workflow-message-adapter/pom.xml
@@ -2,11 +2,11 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-workflow-message-adapter</artifactId>
<packaging>war</packaging>
<name>mso-workflow-message-adapter</name>
@@ -30,7 +30,7 @@
<dependencies>
<dependency>
- <groupId>org.openecomp.so.adapters</groupId>
+ <groupId>org.onap.so.adapters</groupId>
<artifactId>mso-adapters-rest-interface</artifactId>
<version>${project.version}</version>
</dependency>
@@ -58,7 +58,7 @@
<version>4.5.2</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/adapters/pom.xml b/adapters/pom.xml
index 97c2506bcc..6877d76ae3 100644
--- a/adapters/pom.xml
+++ b/adapters/pom.xml
@@ -2,12 +2,12 @@
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.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>adapters</artifactId>
<name>MSO Adapters</name>
<description>Adapters for MSO</description>