diff options
Diffstat (limited to 'adapters')
60 files changed, 448 insertions, 175 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 9042095e84..446c725e48 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -85,7 +85,7 @@ import org.onap.so.config.beans.PoConfig; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java index 576784ae3e..0a3c6acd84 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java @@ -37,7 +37,7 @@ import org.onap.so.config.beans.PoConfig; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index f06d2a2452..8207c7c589 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -52,7 +52,7 @@ import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.beans.HeatStatus; @@ -101,8 +101,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { private static final String CREATE_IN_PROGRESS = "CREATE_IN_PROGRESS"; - private static final String DELETE_STACK = "DeleteStack"; - protected static final String HEAT_ERROR = "HeatError"; protected static final String CREATE_STACK = "CreateStack"; @@ -115,14 +113,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { private Environment environment; @Autowired - RequestsDbClient requestDBClient; - - @Autowired StackStatusHandler statusHandler; @Autowired NovaClientImpl novaClient; + @Autowired + RequestsDbClient requestDBClient; + private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class); // Properties names and variables (with default values) @@ -182,6 +180,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { CreateStackParam createStack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, nestedTemplates, heatFiles); Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId); + boolean operationPerformed = false; if (currentStack != null) { logger.debug("Existing Stack found with Status: {} ", currentStack.getStackStatus()); if (CREATE_COMPLETE.equals(currentStack.getStackStatus())) { @@ -220,8 +219,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { currentStack = queryHeatStack(currentStack.getStackName() + "/" + currentStack.getId(), cloudSiteId, tenantId); } + operationPerformed = true; } - return new StackInfoMapper(currentStack).map(); + StackInfo stackInfo = new StackInfoMapper(currentStack).map(); + stackInfo.setOperationPerformed(operationPerformed); + return stackInfo; } /** @@ -497,14 +499,17 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { public StackInfo deleteStack(String tenantId, String cloudOwner, String cloudSiteId, String stackName, boolean pollForCompletion, int timeoutMinutes) throws MsoException { Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId); + StackInfo stackInfo = null; if (currentStack == null || DELETE_COMPLETE.equals(currentStack.getStackStatus())) { - return new StackInfo(stackName, HeatStatus.NOTFOUND); + stackInfo = new StackInfo(stackName, HeatStatus.NOTFOUND); + stackInfo.setOperationPerformed(false); } else { currentStack = deleteStack(currentStack, timeoutMinutes, cloudSiteId, tenantId); - StackInfo stackInfo = new StackInfoMapper(currentStack).map(); + stackInfo = new StackInfoMapper(currentStack).map(); stackInfo.setName(stackName); - return stackInfo; + stackInfo.setOperationPerformed(true); } + return stackInfo; } /** @@ -1182,4 +1187,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { } } + public void updateResourceStatus(String requestId, String resourceStatusMessage) { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId(requestId); + request.setResourceStatusMessage(resourceStatusMessage); + requestDBClient.patchInfraActiveRequests(request); + } + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java index 684fe98bf3..f001565baf 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index f74a3f5f53..b875c2c8bb 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -29,7 +29,7 @@ import java.util.Optional; import org.onap.so.cloud.authentication.AuthenticationMethodFactory; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoAdapterException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index ca0180ae4b..1df5fe36ab 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -43,7 +43,7 @@ import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.client.HttpClient; import org.onap.so.client.HttpClientFactory; import org.onap.so.client.RestClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; @@ -81,7 +81,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); private static final Integer DEFAULT_MSB_PORT = 80; private static final String DEFAULT_MSB_IP = "127.0.0.1"; + private static final String DEFAULT_MSB_SCHEME = "http"; private static final String ONAP_IP = "ONAP_IP"; + private static final String MSB_SCHEME = "MSB_SCHEME"; private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Autowired @@ -795,10 +797,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { msbIp = environment.getProperty("mso.msb-ip", DEFAULT_MSB_IP); } Integer msbPort = environment.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); + String msbScheme = System.getenv().get(MSB_SCHEME); + if (null == msbScheme || msbScheme.isEmpty()) { + msbScheme = environment.getProperty("mso.msb-scheme", DEFAULT_MSB_SCHEME); + } String path = "/api/multicloud/v1/" + cloudOwner + "/" + cloudSiteId + "/infra_workload"; - String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme("http").build().toString(); + String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme(msbScheme).build().toString(); if (workloadId != null) { String middlepart = null; if (isName) { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 44fc620b07..3e28e5c45a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -35,7 +35,7 @@ import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.NetworkInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml index 32a4db6b80..117d616cd4 100644 --- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml +++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml @@ -53,6 +53,7 @@ mso: logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java index 76d3667632..7e2071525d 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java @@ -7,9 +7,9 @@ * 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. @@ -26,7 +26,7 @@ import java.util.Map; /* * This Java bean class relays Heat stack status information to ActiveVOS processes. - * + * * This bean is returned by all Heat-specific adapter operations (create, query, delete) */ @@ -36,6 +36,7 @@ public class StackInfo { private String canonicalName = ""; private HeatStatus status = HeatStatus.UNKNOWN; private String statusMessage = ""; + private boolean operationPerformed; private Map<String, Object> outputs = new HashMap<>(); private Map<String, Object> parameters = new HashMap<>(); @@ -106,5 +107,15 @@ public class StackInfo { this.parameters = parameters; } + public boolean isOperationPerformed() { + return operationPerformed; + } + + public void setOperationPerformed(boolean operationPerformed) { + this.operationPerformed = operationPerformed; + } + + + } diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index b6b52ce7c5..3e9c2fe6d7 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -28,6 +28,7 @@ <artifactId>adapters</artifactId> <version>1.6.0-SNAPSHOT</version> </parent> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-nssmf-adapter</artifactId> <packaging>jar</packaging> <name>mso-nssmf-adapter</name> diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java index 3592d4f6a3..dcc6f5ba72 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java @@ -59,7 +59,7 @@ import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; -import static org.onap.so.logger.ErrorCode.AvailabilityError; +import static org.onap.logging.filter.base.ErrorCode.AvailabilityError; import static org.onap.so.logger.LoggingAnchor.FOUR; import static org.onap.so.logger.MessageEnum.RA_NS_EXC; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java index b0b84d822b..3a7c2f19df 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java @@ -25,7 +25,7 @@ import java.io.IOException; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.onap.so.logger.LoggingAnchor.THREE; import static org.onap.so.logger.MessageEnum.RA_NS_EXC; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java index 9d7eafbf82..214cebb338 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java @@ -26,7 +26,7 @@ package org.onap.so.adapters.network; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java index 25667efc71..ba4e93fa93 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HostRoute; import org.onap.so.openstack.beans.Pool; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java index e95e9a3a83..8d75212f4e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -46,7 +46,7 @@ import org.onap.so.adapters.network.async.client.QueryNetworkNotification; import org.onap.so.adapters.network.async.client.UpdateNetworkNotification; import org.onap.so.adapters.network.exceptions.NetworkException; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.NetworkRollback; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index ef04ee9c13..257374fdb2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -47,7 +47,7 @@ import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationReposi import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; @@ -92,6 +92,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static final String NEUTRON_MODE = "NEUTRON"; private static final String CLOUD_OWNER = "CloudOwner"; private static final String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}"; + private static final String NETWORK_EXIST_STATUS_MESSAGE = + "The network was found to already exist, thus no new network was created in the cloud via this request"; + private static final String NETWORK_CREATED_STATUS_MESSAGE = + "The new network was successfully created in the cloud"; + private static final String NETWORK_NOT_EXIST_STATUS_MESSAGE = + "The network as not found, thus no network was deleted in the cloud via this request"; + private static final String NETWORK_DELETED_STATUS_MESSAGE = "The network was successfully deleted in the cloud"; private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class); @@ -225,7 +232,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // See if the Network already exists (by name) NetworkInfo netInfo = null; - long queryNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId); } catch (MsoException me) { @@ -254,10 +260,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { logger.warn("{} {} Found Existing network, status={} for Neutron mode ", MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), netInfo.getStatus()); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } - long createNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.createNetwork(cloudSiteId, tenantId, neutronNetworkType, networkName, physicalNetworkName, vlans); @@ -360,6 +366,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(), networkName, cloudSiteId, tenantId); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } @@ -473,6 +480,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNetworkCreated(true); networkRollback.setNetworkType(networkType); + try { + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } + logger.debug("Network {} successfully created via HEAT", networkName); } @@ -1055,8 +1068,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } else { try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); - networkDeleted.value = true; + StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); + networkDeleted.value = stack.isOperationPerformed(); } catch (MsoException me) { me.addContext("DeleteNetwork"); logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, @@ -1064,6 +1077,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException(me); } } + try { + heat.updateResourceStatus(msoRequest.getRequestId(), + networkDeleted.value ? NETWORK_DELETED_STATUS_MESSAGE : NETWORK_NOT_EXIST_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } } /** diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index 0c37837880..09356d02c8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -62,7 +62,7 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.adapters.vnf.BpelRestClient; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.NetworkStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java index 04b90b444f..4b02595074 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java @@ -33,7 +33,7 @@ import org.onap.so.adapters.tenant.exceptions.TenantAlreadyExists; import org.onap.so.adapters.tenant.exceptions.TenantException; import org.onap.so.adapters.tenantrest.TenantRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 662ce33022..5b0370b25e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -37,7 +37,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java index e925e6037c..68d1bebc51 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -44,7 +44,7 @@ import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify; import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 65d5523709..32e88d8cad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -53,7 +53,7 @@ import org.onap.so.entity.MsoRequest; import org.onap.so.heatbridge.HeatBridgeApi; import org.onap.so.heatbridge.HeatBridgeException; import org.onap.so.heatbridge.HeatBridgeImpl; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; @@ -109,6 +109,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final String USER_ERROR = "USER ERROR"; private static final String VERSION_MIN = "VersionMin"; private static final String VERSION_MAX = "VersionMax"; + private static final String VF_EXIST_STATUS_MESSAGE = + "The vf module was found to already exist, thus no new vf module was created in the cloud via this request"; + private static final String VF_CREATED_STATUS_MESSAGE = "The new vf module was successfully created in the cloud"; + private static final String VF_NOT_EXIST_STATUS_MESSAGE = + "The vf module was not, thus no vf module was deleted in the cloud via this request"; + private static final String VF_DELETED_STATUS_MESSAGE = "The vf module was successfully deleted in the cloud"; @Autowired private VFModuleCustomizationRepository vfModuleCustomRepo; @@ -1046,6 +1052,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null, template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString, nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(), failIfExists); + + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + heatStack.isOperationPerformed() ? VF_EXIST_STATUS_MESSAGE : VF_CREATED_STATUS_MESSAGE); } else { throw new MsoHeatNotFoundException(); } @@ -1125,7 +1134,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } try { - msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + StackInfo stackInfo = + msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + stackInfo.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE); } catch (MsoException me) { me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index abaf881ba5..ba837a9718 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -52,7 +52,7 @@ import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.beans.VnfRollback; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index b1f4055b3b..0ecfd15dde 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -65,7 +65,7 @@ import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index 0fb11ebbf3..0836f69ba7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -56,7 +56,7 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index fcb570f3f5..18ed9872a0 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -55,7 +55,7 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java index c9e046ca43..7e12735e05 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java @@ -56,7 +56,7 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java index 2b7234aca6..cfddbba34e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java @@ -55,7 +55,7 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index e2022c9a6e..6d3b0ab680 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -76,7 +76,7 @@ import org.onap.so.heatbridge.helpers.AaiHelper; import org.onap.so.heatbridge.openstack.api.OpenstackClient; import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.openstack4j.model.compute.Server; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java index add1918748..284067a766 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java @@ -7,9 +7,9 @@ * 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. @@ -20,6 +20,9 @@ package org.onap.so.adapters.network; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteNeutronNetwork; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStack_200; @@ -52,6 +55,7 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.github.tomakehurst.wiremock.WireMockServer; public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @@ -112,6 +116,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json"); @@ -140,6 +146,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStack_404(wireMockServer, "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"); @@ -158,6 +166,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json"); @@ -236,6 +246,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkHeatModeSuccess() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json"); @@ -292,6 +304,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkNeureonMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); @@ -506,4 +520,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { String input = new String(Files.readAllBytes(Paths.get(JsonInput))); return input; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java index 727f18902a..00961a16b9 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java @@ -7,9 +7,9 @@ * 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. @@ -22,6 +22,7 @@ package org.onap.so.adapters.network; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile; @@ -41,6 +42,7 @@ import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.Subnet; import org.springframework.beans.factory.annotation.Autowired; +import com.github.tomakehurst.wiremock.WireMockServer; public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { @Autowired @@ -263,4 +265,5 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { false, new ArrayList<>(), new HashMap<String, String>(), "messageId", new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index a058378425..9fc2aba948 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vnf; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.mockito.Mockito.when; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; @@ -30,6 +31,7 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse; +import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -53,6 +55,7 @@ import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.utils.MsoHeatUtils; import org.springframework.beans.factory.annotation.Autowired; +import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.stubbing.Scenario; @@ -73,6 +76,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -88,6 +92,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_NullFailIfExists() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -117,6 +122,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { .inScenario("HeatStatusFailure").whenScenarioStateIs("HeatStackFailed") .willSetStateTo("HeatStackSuccess")); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); @@ -133,6 +140,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_HeatStatusCreated() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); @@ -516,5 +525,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { return vfModuleCustomization; } + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java index 5a8524fd73..9655e90e46 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java @@ -7,9 +7,9 @@ * 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. @@ -22,6 +22,8 @@ package org.onap.so.adapters.vnf; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.github.tomakehurst.wiremock.WireMockServer; +import org.apache.http.HttpStatus; import org.json.JSONException; import org.junit.Ignore; import org.junit.Test; @@ -49,6 +51,9 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -112,6 +117,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -208,6 +215,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -342,6 +351,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers); @@ -539,4 +549,9 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { return request; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java index 523a6903cc..c2e2b567f1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java @@ -7,9 +7,9 @@ * 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. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -50,6 +54,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon { @Test public void testCreateVNFVolumes() throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java index fb4bec69ed..6fd9f02cfe 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java @@ -7,9 +7,9 @@ * 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. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -52,6 +56,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 20fd812ab9..42955c35c9 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -61,11 +61,15 @@ ssl-enable: false tomcat: max-threads: 50 mso: + adapters: + requestDb: + endpoint: http://localhost:${wiremock.server.port} audit: lock-time: 240000 logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java index 24dab2fc5b..9f48144eb8 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java @@ -10,9 +10,9 @@ * 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. @@ -27,19 +27,15 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; -import org.onap.logging.filter.base.ONAPComponents; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.logging.filter.base.ScheduledLogging; +import org.onap.logging.filter.base.ScheduledTaskException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.PageRequest; @@ -56,8 +52,6 @@ public class ArchiveInfraRequestsScheduler { private InfraActiveRequestsRepository infraActiveRepo; @Autowired private ArchivedInfraRequestsRepository archivedInfraRepo; - @Autowired - private ScheduledTasksMDCSetup scheduledMDCSetup; @Value("${mso.infra-requests.archived.period}") @@ -65,11 +59,13 @@ public class ArchiveInfraRequestsScheduler { /** * Runs the scheduler nightly [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year] + * + * @throws ScheduledTaskException */ + @ScheduledLogging @Scheduled(cron = "0 0 1 * * ?") @SchedulerLock(name = "archiveInfraRequestsScheduler") - public void infraRequestsScheduledTask() { - scheduledMDCSetup.mdcSetup(ONAPComponents.REQUEST_DB, "infraRequestsScheduledTask"); + public void infraRequestsScheduledTask() throws ScheduledTaskException { logger.debug("Start of archiveInfraRequestsScheduler"); Date currentDate = new Date(); @@ -97,10 +93,9 @@ public class ArchiveInfraRequestsScheduler { } while (!requestsByStartTime.isEmpty()); logger.debug("End of archiveInfraRequestsScheduler"); - scheduledMDCSetup.exitAndClearMDC(); } - protected void archiveInfraRequests(List<InfraActiveRequests> requests) { + protected void archiveInfraRequests(List<InfraActiveRequests> requests) throws ScheduledTaskException { List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>(); List<InfraActiveRequests> oldInfraReqs = new ArrayList<>(); @@ -147,14 +142,12 @@ public class ArchiveInfraRequestsScheduler { archivedInfra.setVolumeGroupName(iar.getVolumeGroupName()); archivedInfra.setProductFamilyName(iar.getProductFamilyName()); archivedInfra.setTenantName(iar.getTenantName()); + archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage()); newArchivedReqs.add(archivedInfra); oldInfraReqs.add(iar); } catch (Exception e) { - scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, e.getMessage()); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.error(LoggingAnchor.TWO, MessageEnum.RA_GENERAL_EXCEPTION.toString(), - ErrorCode.UnknownError.getValue(), e); + throw new ScheduledTaskException(ErrorCode.UnknownError, e.getMessage(), e); } } diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 052a53bb1f..b262cb21cb 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -39,7 +39,7 @@ import org.onap.so.db.request.data.repository.OperationStatusRepository; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.onap.so.db.request.data.repository.SiteStatusRepository; import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.requestsdb.RequestsDbConstant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java index 27580977b8..e1e629008d 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java @@ -24,7 +24,7 @@ package org.onap.so.adapters.requestsdb.exceptions; import javax.xml.ws.WebFault; import org.onap.so.exceptions.MSOException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; /** * This class simply extends Exception (without addition additional functionality) to provide an identifier for diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql new file mode 100644 index 0000000000..f388a185f5 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql @@ -0,0 +1,4 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext; +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext;
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java index b96a564b1a..f8daf69965 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java @@ -31,7 +31,7 @@ import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java index 577b550be6..3de95b338b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java @@ -32,7 +32,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java index 87620743d7..978cd44b56 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -30,7 +30,7 @@ import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java index 294dccdb90..da0fcd3d04 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java @@ -42,6 +42,7 @@ public interface Constants { public static final String REQUEST_TUNABLES = "org.onap.so.adapters.sdnc"; public static final String MSO_ACTION_LCM = "lcm"; + public static final String MSO_ACTION_MDONS = "opticalservice"; public static final String LCM_API_VER = "2.00"; public static final int LCM_FLAGS_TTL = 65000; public static final String LCM_ORIGINATOR_ID = "MSO"; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java index b15831ff03..0535b3de2d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java @@ -24,7 +24,7 @@ package org.onap.so.adapters.sdnc.impl; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java index 2b023f4c15..7c35be02a4 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java @@ -29,7 +29,7 @@ import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.SDNCAdapterPortType; import org.onap.so.adapters.sdnc.SDNCAdapterRequest; import org.onap.so.adapters.sdnc.SDNCAdapterResponse; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index bcd1db7929..b8977f05d8 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -46,7 +46,7 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.utils.CryptoUtils; import org.onap.so.adapters.sdnc.SDNCAdapterRequest; import org.onap.so.adapters.sdnc.client.CallbackHeader; @@ -112,6 +112,8 @@ public class SDNCRestClient { Document reqDoc = node.getOwnerDocument(); if (Constants.MSO_ACTION_LCM.equals(msoAction)) { sdncReqBody = Utils.genSdncLcmReq(reqDoc, rt); + } else if (Constants.MSO_ACTION_MDONS.equals(msoAction)) { + sdncReqBody = Utils.genOpticalSdncReq(reqDoc, rt); } else { sdncReqBody = Utils.genSdncReq(reqDoc, rt); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java index 56c38f8891..f52ebcab9b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java @@ -34,7 +34,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,10 +42,13 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.json.XML; +import org.json.JSONObject; public class Utils { private static Logger logger = LoggerFactory.getLogger(Utils.class); + private static int MSOJsonIndentFactor = 3; private Utils() {} @@ -230,6 +233,85 @@ public class Utils { return null; } + public static String genOpticalSdncReq(Document reqDoc, RequestTunables rt) { + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + // NewDoc for output + // Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElementNS(rt.getNamespace(), "input"); + newdoc.appendChild(root); + // RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + String req = domToStr(newdoc); + String s = xml2json(req, true); + logger.debug("Formatted SdncReq:\n", s); + return s; + + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", + ErrorCode.BusinessProcessError.getValue(), "Exception in genOpticalSdncReq", e); + } + return null; + } + + /** + * Uses the JSONObject static method to convert a XML doc to JSON. + * + * @param xml String containing the XML doc + * @param pretty flag to determine if the output should be formatted + * @return String containing the JSON translation + */ + public static String xml2json(String xml, boolean pretty) { + try { + // name spaces cause problems, so just remove them + JSONObject jsonObj = XML.toJSONObject(removeNamespaces(xml)); + if (!pretty) { + return jsonObj.toString(); + } else { + // add an indent to make it 'pretty' + return jsonObj.toString(MSOJsonIndentFactor); + } + } catch (Exception e) { + logger.debug("xml2json(): unable to parse xml and convert to json. Exception was: {}", e.toString(), e); + return null; + } + } + + /** + * Removes namespaces and namespace declarations from an XML document. + * + * @param xml the XML document + * @return a possibly modified document + */ + public static String removeNamespaces(Object xml) { + if (xml == null) { + logger.debug("removeNamespaces input object is null , returning null"); + return null; + } + + String text = String.valueOf(xml); + + // remove xmlns declaration + text = text.replaceAll("xmlns.*?(\"|\').*?(\"|\')", ""); + // remove opening tag prefix + text = text.replaceAll("(<)(\\w+:)(.*?>)", "$1$3"); + // remove closing tags prefix + text = text.replaceAll("(</)(\\w+:)(.*?>)", "$1$3"); + // remove extra spaces left when xmlns declarations are removed + text = text.replaceAll("\\s+>", ">"); + + return text; + } + + public static String genMsoFailResp(SDNCResponse resp) { try { diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index 631be2f9ff..62f45f88b1 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -28,7 +28,7 @@ import java.net.URI; import javax.xml.bind.DatatypeConverter; import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java index 979238fe2f..776251a20b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java @@ -26,7 +26,7 @@ package org.onap.so.adapters.sdnc.sdncrest; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.exception.SDNCAdapterException; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java index e184bbd110..431e9db87b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java @@ -51,7 +51,7 @@ import org.apache.http.util.EntityUtils; import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.adapters.sdncrest.SDNCErrorCommon; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java index 50c8a089df..305abe2762 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java @@ -38,7 +38,7 @@ import org.onap.so.adapters.sdncrest.RequestInformation; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.onap.so.adapters.sdncrest.SDNCServiceError; import org.onap.so.adapters.sdncrest.SDNCServiceRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java index 5f80c20b97..9f7760a0d8 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java index 5b50f776cc..04109bd89d 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java @@ -27,7 +27,7 @@ import java.io.IOException; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.vfc.constant.HttpCode; import org.onap.so.adapters.vfc.exceptions.ApplicationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java index 984cdb8016..a708c2641c 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -47,7 +47,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.onap.so.adapters.vfc.model.RestfulResponse; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json index 1f4a8ac306..17d81f44c1 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json @@ -1187,8 +1187,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -2024,8 +2030,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -4572,16 +4584,31 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } } } }, @@ -4803,18 +4830,32 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" - } - } + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } + } } }, "callbackUri": { "description": "String formatted according to IETF RFC 3986.\n", diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java index 6d566c07ad..f32a9b0fa9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java @@ -21,16 +21,16 @@ package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; @@ -62,7 +62,7 @@ public class PkgmSubscriptionRequestConverter implements private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( - final SubscriptionsFilter sol003SubscriptionsFilter) { + final SubscriptionsFilter1 sol003SubscriptionsFilter) { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter(); @@ -81,21 +81,40 @@ public class PkgmSubscriptionRequestConverter implements etsiCatalogManagerFilters .setOperationalState(getOperationalState(sol003SubscriptionsFilter.getOperationalState())); - etsiCatalogManagerFilters.setUsageState(null); + etsiCatalogManagerFilters.setUsageState(getUsageState(sol003SubscriptionsFilter.getUsageState())); return etsiCatalogManagerFilters; } - // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI - // Catalog Manager Swagger - // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once - // swagger is updated. + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( + final List<UsageStateEnum> usageStates) { + if (usageStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = + new ArrayList<>(); + usageStates.stream().forEach(state -> { + etsiCatalogUsageStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum + .fromValue(state.getValue())); + }); + return etsiCatalogUsageStates; + } + return Collections.emptyList(); + } + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( - final OperationalStateEnum operationalState) { - if (operationalState != null) { - return Arrays.asList( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum - .fromValue(operationalState.getValue())); + final List<OperationalStateEnum> operationalStates) { + if (operationalStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = + new ArrayList<>(); + operationalStates.forEach(state -> { + etsiCatalogOperationalStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum + .fromValue(state.getValue())); + }); + + return etsiCatalogOperationalStates; } return Collections.emptyList(); } @@ -165,12 +184,12 @@ public class PkgmSubscriptionRequestConverter implements final List<NotificationTypesEnum> notificationTypes) { if (notificationTypes != null && !notificationTypes.isEmpty()) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogManagerNotificationTypes = + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = new ArrayList<>(); - notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add( + notificationTypes.forEach(type -> etsiCatalogNotificationTypes.add( org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum .fromValue(type.getValue()))); - return etsiCatalogManagerNotificationTypes; + return etsiCatalogNotificationTypes; } return Collections.emptyList(); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java index a4c52fd13d..a23eb6c3e3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java @@ -34,14 +34,14 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServic import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +80,7 @@ public class SubscriptionManager { this.msoKeyString = msoKeyString; } - public Optional<InlineResponse2002> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) + public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = @@ -97,14 +97,14 @@ public class SubscriptionManager { packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest); - final InlineResponse2002 response2002 = new InlineResponse2002(); - response2002.setId(subscriptionId); - response2002.setFilter(pkgmSubscriptionRequest.getFilter()); - response2002.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); - response2002.setLinks(new SubscriptionsLinks() + final InlineResponse201 response = new InlineResponse201(); + response.setId(subscriptionId); + response.setFilter(pkgmSubscriptionRequest.getFilter()); + response.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); + response.setLinks(new SubscriptionsLinks() .self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString()))); - return Optional.of(response2002); + return Optional.of(response); } throw new InternalServerErrorException( "Received empty response from POST to ETSI Catalog Manager Subscription Endpoint."); @@ -114,7 +114,7 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest); } - public Optional<InlineResponse2002> getSubscription(final String subscriptionId) { + public Optional<InlineResponse201> getSubscription(final String subscriptionId) { logger.debug("Checking if subscrition with id: {} exists in ETSI Catalog Manager", subscriptionId); final Optional<NsdmSubscription> etsiCatalogSubscriptionOption = @@ -137,12 +137,12 @@ public class SubscriptionManager { return Optional.empty(); } - public List<InlineResponse2002> getSubscriptions() { + public List<InlineResponse201> getSubscriptions() { final Map<String, PkgmSubscriptionRequest> subscriptions = packageManagementCacheServiceProvider.getSubscriptions(); - final List<InlineResponse2002> response = new ArrayList<>(); + final List<InlineResponse201> response = new ArrayList<>(); subscriptions.forEach((key, value) -> { - final Optional<InlineResponse2002> optional = getSubscription(key); + final Optional<InlineResponse201> optional = getSubscription(key); if (optional.isPresent()) { response.add(optional.get()); } @@ -175,8 +175,8 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscription(subscriptionId); } - private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { - return new InlineResponse2002().id(id).filter(subscription.getFilter()) + private InlineResponse201 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { + return new InlineResponse201().id(id).filter(subscription.getFilter()) .callbackUri(subscription.getCallbackUri()); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java index 6db3797f9b..515e317496 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Optional; import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager; import org.slf4j.Logger; @@ -92,15 +92,15 @@ public class Sol003PackageManagementSubscriptionController { } logger.debug("No duplicate Subscription exists, continuing with POST."); - final Optional<InlineResponse2002> optionalInlineResponse2002 = + final Optional<InlineResponse201> optionalInlineResponse = subscriptionManager.createSubscription(pkgmSubscriptionRequest); - if (optionalInlineResponse2002.isPresent()) { - InlineResponse2002 inlineResponse2002 = optionalInlineResponse2002.get(); - final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse2002.getId()); + if (optionalInlineResponse.isPresent()) { + InlineResponse201 inlineResponse = optionalInlineResponse.get(); + final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse.getId()); final HttpHeaders headers = createLocationHeader(subscriptionUri); logger.debug("Sending response with uri {} ", subscriptionUri); - return new ResponseEntity<>(inlineResponse2002, headers, HttpStatus.CREATED); + return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED); } final String errorMessage = "A null response was received during the postSubscriptionRequest call."; logger.error(errorMessage); @@ -113,9 +113,9 @@ public class Sol003PackageManagementSubscriptionController { * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK */ @GetMapping(value = "/subscriptions") - public ResponseEntity<List<InlineResponse2002>> getSubscriptions() { + public ResponseEntity<List<InlineResponse201>> getSubscriptions() { logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions."); - List<InlineResponse2002> subscriptionsList = subscriptionManager.getSubscriptions(); + List<InlineResponse201> subscriptionsList = subscriptionManager.getSubscriptions(); return new ResponseEntity<>(subscriptionsList, HttpStatus.OK); } @@ -128,7 +128,7 @@ public class Sol003PackageManagementSubscriptionController { @GetMapping(value = "/subscriptions/{subscriptionId}") public ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId) { logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId); - final Optional<InlineResponse2002> optional = subscriptionManager.getSubscription(subscriptionId); + final Optional<InlineResponse201> optional = subscriptionManager.getSubscription(subscriptionId); if (optional.isPresent()) { logger.debug("Return subscription with id {} and body {}", subscriptionId, optional); return new ResponseEntity<>(optional.get(), HttpStatus.OK); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java index 7466895d97..9016cad528 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java @@ -54,15 +54,16 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; @@ -132,8 +133,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { @Test public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException { final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest(); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri()); @@ -178,22 +179,22 @@ public class Sol003PackageManagementSubscriptionControllerTest { mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final String subscriptionId = response.getBody().getId(); - final ResponseEntity<InlineResponse2002> response2002 = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> responseEntity = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .getSubscription(subscriptionId); final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri()); assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter()); assertEquals(response.getHeaders(), headers); - assertEquals(HttpStatus.OK, response2002.getStatusCode()); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter()); // Ensure CallBackUri is set to new URI assertNotEquals(pkgmSubscriptionRequest.getCallbackUri(), response.getBody().getCallbackUri()); @@ -204,10 +205,9 @@ public class Sol003PackageManagementSubscriptionControllerTest { final String invalidId = "invalidSubscriptionId"; mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + invalidId)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController - .getSubscription(invalidId); + final ResponseEntity<?> response = sol003PackageManagementSubscriptionController.getSubscription(invalidId); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); + assertTrue(response.getBody() instanceof ProblemDetails); } @Test @@ -221,14 +221,14 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); sol003PackageManagementSubscriptionController.postSubscriptionRequest(pkgmSubscriptionRequest); - final ResponseEntity<List<InlineResponse2002>> response = + final ResponseEntity<List<InlineResponse201>> response = sol003PackageManagementSubscriptionController.getSubscriptions(); - final List<InlineResponse2002> subscriptionsList = response.getBody(); + final List<InlineResponse201> subscriptionsList = response.getBody(); assertEquals(Objects.requireNonNull(response.getBody()).get(0).getFilter(), pkgmSubscriptionRequest.getFilter()); - assert (subscriptionsList != null); + assertNotNull(subscriptionsList != null); assertNotEquals('0', subscriptionsList.size()); assertEquals(HttpStatus.OK, response.getStatusCode()); } @@ -310,13 +310,13 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(buildPkgmSubscription()), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> responseEntity = testRestTemplate.postForEntity( + final ResponseEntity<InlineResponse201> responseEntity = testRestTemplate.postForEntity( LOCALHOST_URL + port + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", request, - InlineResponse2002.class); + InlineResponse201.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertTrue(responseEntity.hasBody()); - final InlineResponse2002 actual = responseEntity.getBody(); + final InlineResponse201 actual = responseEntity.getBody(); assertEquals(ID, actual.getId()); @@ -340,7 +340,7 @@ public class Sol003PackageManagementSubscriptionControllerTest { private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() { final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest(); - final SubscriptionsFilter sub = buildSubscriptionsFilter(); + final SubscriptionsFilter1 sub = buildSubscriptionsFilter(); final SubscriptionsAuthentication auth = new SubscriptionsAuthentication(); pkgmSubscriptionRequest.setFilter(sub); pkgmSubscriptionRequest.setCallbackUri(msbEndpoint.toString()); @@ -348,11 +348,11 @@ public class Sol003PackageManagementSubscriptionControllerTest { return pkgmSubscriptionRequest; } - private SubscriptionsFilter buildSubscriptionsFilter() { - final SubscriptionsFilter sub = new SubscriptionsFilter(); + private SubscriptionsFilter1 buildSubscriptionsFilter() { + final SubscriptionsFilter1 sub = new SubscriptionsFilter1(); final List<String> vnfdIdList = new ArrayList<>(); final List<String> vnfPkgIdList = new ArrayList<>(); - final List<NotificationTypesEnum> notificationTypes = new ArrayList<>(); + final List<SubscriptionsFilter1.NotificationTypesEnum> notificationTypes = new ArrayList<>(); final SubscriptionsFilterVnfProductsFromProviders subscriptionsFilterVnfProductsFromProviders = new SubscriptionsFilterVnfProductsFromProviders(); final List<SubscriptionsFilterVnfProductsFromProviders> vnfProductsFromProviders = new ArrayList<>(); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json index 85ffb99d8d..c38466f8e5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json @@ -28,7 +28,7 @@ "vnfPkgId": [ "VNFPKGID" ], - "operationalState": "ENABLED" + "operationalState": ["ENABLED"] }, "callbackUri": "http://so-vnfm-adapter:9093/api/vnfpkgm/v1/subscriptions", "authentication": |