diff options
29 files changed, 223 insertions, 1248 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java index a7bca73fdd..abfacebf05 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java @@ -34,8 +34,6 @@ import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.transport.servlet.CXFServlet; import org.onap.so.adapters.cloudregion.CloudRegionRestV1; import org.onap.so.adapters.network.MsoNetworkAdapterImpl; -import org.onap.so.adapters.tenant.MsoTenantAdapterImpl; -import org.onap.so.adapters.tenant.TenantAdapterRest; import org.onap.so.adapters.vnf.MsoVnfAdapterAsyncImpl; import org.onap.so.adapters.vnf.MsoVnfAdapterImpl; import org.onap.so.client.policy.JettisonStyleMapperProvider; @@ -53,12 +51,8 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @Configuration public class CXFConfiguration { @Autowired - private TenantAdapterRest tenantAdapterRest; - @Autowired private MsoNetworkAdapterImpl networkAdapterImpl; @Autowired - private MsoTenantAdapterImpl tenantAdapterImpl; - @Autowired private MsoVnfAdapterImpl vnfAdapterImpl; @Autowired private MsoVnfAdapterAsyncImpl vnfAdapterAsyncImpl; @@ -99,20 +93,6 @@ public class CXFConfiguration { } /* - * tenant adapter endpoint - */ - @Bean - public Endpoint tenantAdapterEndpoint() { - EndpointImpl endpoint = new EndpointImpl(springBus(), tenantAdapterImpl); - endpoint.publish("/TenantAdapter"); - endpoint.setWsdlLocation("TenantAdapter.wsdl"); - endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor()); - endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor()); - endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor()); - return endpoint; - } - - /* * vnfAdapterEndpoint VnfAsyncAdapterEndpoint VnfCloudAdapterEndpoint */ @Bean @@ -137,19 +117,6 @@ public class CXFConfiguration { return endpoint; } - // Uses Jettson Style marshalling semantics - @Bean - public Server rsServer() { - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); - endpoint.setBus(springBus()); - endpoint.setServiceBeans(Arrays.<Object>asList(tenantAdapterRest)); - endpoint.setAddress("/rest"); - endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature())); - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(jettisonStyleObjectMapper.getMapper()), - soAuditLogContainerFilter)); - return endpoint.create(); - } - // Uses normal Jackson marshalling semantics @Bean public Server rsServerApi() { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java deleted file mode 100644 index 68f7558add..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant; - - -import java.util.Map; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebParam.Mode; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.ws.Holder; -import org.onap.so.adapters.tenant.exceptions.TenantException; -import org.onap.so.adapters.tenantrest.TenantRollback; -import org.onap.so.entity.MsoRequest; - -@WebService(name = "TenantAdapter", targetNamespace = "http://org.onap.so/tenant") -public interface MsoTenantAdapter { - /** - * This is the "Create Tenant" Web Service Endpoint definition. - */ - @WebMethod - public void createTenant(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantName") @XmlElement(required = true) String tenantName, - @WebParam(name = "metadata") Map<String, String> metadata, - @WebParam(name = "failIfExists") Boolean failIfExists, @WebParam(name = "backout") Boolean backout, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "tenantId", mode = Mode.OUT) Holder<String> tenantId, - @WebParam(name = "rollback", mode = Mode.OUT) Holder<TenantRollback> rollback) throws TenantException; - - @WebMethod - public void queryTenant(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantNameOrId") @XmlElement(required = true) String tenantNameOrId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "tenantId", mode = Mode.OUT) Holder<String> tenantId, - @WebParam(name = "tenantName", mode = Mode.OUT) Holder<String> tenantName, - @WebParam(name = "metadata", mode = Mode.OUT) Holder<Map<String, String>> metadata) throws TenantException; - - @WebMethod - public void deleteTenant(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "tenantDeleted", mode = Mode.OUT) Holder<Boolean> tenantDeleted) throws TenantException; - - @WebMethod - public void rollbackTenant(@WebParam(name = "rollback") @XmlElement(required = true) TenantRollback rollback) - throws TenantException; - - @WebMethod - public void healthCheck(); -} 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 deleted file mode 100644 index 4b02595074..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant; - - -import java.util.Map; -import javax.annotation.Resource; -import javax.jws.WebService; -import javax.xml.ws.Holder; -import javax.xml.ws.WebServiceContext; -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.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.MsoTenant; -import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.utils.MsoTenantUtils; -import org.onap.so.openstack.utils.MsoTenantUtilsFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@WebService(serviceName = "TenantAdapter", endpointInterface = "org.onap.so.adapters.tenant.MsoTenantAdapter", - targetNamespace = "http://org.onap.so/tenant") -@Component -public class MsoTenantAdapterImpl implements MsoTenantAdapter { - public static final String CREATE_TENANT = "createTenant"; - public static final String OPENSTACK = "OpenStack"; - public static final String QUERY_TENANT = "QueryTenant"; - public static final String DELETE_TENANT = "DeleteTenant"; - public static final String ROLLBACK_TENANT = "RollbackTenant"; - private static final String OPENSTACK_COMMUNICATE_EXCEPTION_MSG = - "{} {} Exception while communicate with Open Stack "; - @Resource - private WebServiceContext wsContext; - - @Autowired - private MsoTenantUtilsFactory tFactory; - private static Logger logger = LoggerFactory.getLogger(MsoTenantAdapterImpl.class); - - /** - * Health Check web method. Does nothing but return to show the adapter is deployed. - */ - @Override - public void healthCheck() { - logger.debug("Health check call in Tenant Adapter"); - } - - /** - * This is the "Create Tenant" web service implementation. It will create a new Tenant in the specified cloud. If - * the tenant already exists, this can be considered a success or failure, depending on the value of the - * 'failIfExists' parameter. - * - * The method returns the tenantId (the Openstack ID), and a TenantRollback object. This last object can be passed - * as-is to the rollbackTenant method to undo what (if anything) was created. This is useful if a Tenant is - * successfully created but the orchestrator fails on a subsequent operation. - */ - @Override - public void createTenant(String cloudSiteId, String tenantName, Map<String, String> metadata, Boolean failIfExists, - Boolean backout, MsoRequest msoRequest, Holder<String> tenantId, Holder<TenantRollback> rollback) - throws TenantException { - - logger.debug("Call to MSO createTenant adapter. Creating Tenant: {} in {}", tenantName, cloudSiteId); - - // Start building up rollback object - TenantRollback tenantRollback = new TenantRollback(); - tenantRollback.setCloudId(cloudSiteId); - tenantRollback.setMsoRequest(msoRequest); - - MsoTenantUtils tUtils; - try { - tUtils = tFactory.getTenantUtils(cloudSiteId); - } catch (MsoCloudSiteNotFound me) { - logger.error("{} {} no implementation found for {}: ", MessageEnum.RA_CREATE_TENANT_ERR, - ErrorCode.DataError.getValue(), cloudSiteId, me); - throw new TenantException(me); - } - - MsoTenant newTenant = null; - String newTenantId; - try { - newTenant = tUtils.queryTenantByName(tenantName, cloudSiteId); - } catch (MsoException me) { - logger.error(OPENSTACK_COMMUNICATE_EXCEPTION_MSG, MessageEnum.RA_CREATE_TENANT_ERR, - ErrorCode.DataError.getValue(), me); - throw new TenantException(me); - } - if (newTenant == null) { - if (backout == null) - backout = true; - try { - newTenantId = tUtils.createTenant(tenantName, cloudSiteId, metadata, backout.booleanValue()); - } catch (MsoException me) { - logger.error(OPENSTACK_COMMUNICATE_EXCEPTION_MSG, MessageEnum.RA_CREATE_TENANT_ERR, - ErrorCode.DataError.getValue(), me); - throw new TenantException(me); - } - tenantRollback.setTenantId(newTenantId); - tenantRollback.setTenantCreated(true); - logger.debug("Tenant {} successfully created with ID {}", tenantName, newTenantId); - } else { - if (failIfExists != null && failIfExists) { - logger.error("{} {} CreateTenant: Tenant {} already exists in {} ", MessageEnum.RA_TENANT_ALREADY_EXIST, - ErrorCode.DataError.getValue(), tenantName, cloudSiteId); - throw new TenantAlreadyExists(tenantName, cloudSiteId, newTenant.getTenantId()); - } - - newTenantId = newTenant.getTenantId(); - tenantRollback.setTenantCreated(false); - logger.debug("Tenant {} already exists with ID {}", tenantName, newTenantId); - } - - - tenantId.value = newTenantId; - rollback.value = tenantRollback; - return; - } - - @Override - public void queryTenant(String cloudSiteId, String tenantNameOrId, MsoRequest msoRequest, Holder<String> tenantId, - Holder<String> tenantName, Holder<Map<String, String>> metadata) throws TenantException { - - logger.debug("Querying Tenant {} in {}", tenantNameOrId, cloudSiteId); - - MsoTenantUtils tUtils; - try { - tUtils = tFactory.getTenantUtils(cloudSiteId); - } catch (MsoCloudSiteNotFound me) { - logger.error("{} {} no implementation found for {}: ", MessageEnum.RA_CREATE_TENANT_ERR, - ErrorCode.DataError.getValue(), cloudSiteId, me); - throw new TenantException(me); - } - - MsoTenant qTenant = null; - try { - qTenant = tUtils.queryTenant(tenantNameOrId, cloudSiteId); - if (qTenant == null) { - // Not found by ID, Try by name. - qTenant = tUtils.queryTenantByName(tenantNameOrId, cloudSiteId); - } - - if (qTenant == null) { - logger.debug("QueryTenant: Tenant {} not found", tenantNameOrId); - tenantId.value = null; - tenantName.value = null; - metadata.value = null; - } else { - logger.debug("QueryTenant: Tenant {} found with ID {}", tenantNameOrId, qTenant.getTenantId()); - tenantId.value = qTenant.getTenantId(); - tenantName.value = qTenant.getTenantName(); - metadata.value = qTenant.getMetadata(); - } - } catch (MsoException me) { - logger.error("Exception in queryTenant for {}: ", MessageEnum.RA_GENERAL_EXCEPTION, - ErrorCode.DataError.getValue(), tenantNameOrId, me); - throw new TenantException(me); - } - return; - } - - @Override - public void deleteTenant(String cloudSiteId, String tenantId, MsoRequest msoRequest, Holder<Boolean> tenantDeleted) - throws TenantException { - - logger.debug("Deleting Tenant {} in {}", tenantId, cloudSiteId); - - // Delete the Tenant. - try { - - MsoTenantUtils tUtils = tFactory.getTenantUtils(cloudSiteId); - boolean deleted = tUtils.deleteTenant(tenantId, cloudSiteId); - tenantDeleted.value = deleted; - } catch (MsoException me) { - logger.error("{} {} Exception - DeleteTenant {}: ", MessageEnum.RA_DELETE_TEMAMT_ERR, - ErrorCode.DataError.getValue(), tenantId, me); - throw new TenantException(me); - } - - // On success, nothing is returned. - return; - } - - /** - * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the - * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation - * to undo the creation. - * - * The rollback includes removing the VNF and deleting the tenant if the tenant did not exist prior to the VNF - * creation. - */ - @Override - public void rollbackTenant(TenantRollback rollback) throws TenantException { - // rollback may be null (e.g. if stack already existed when Create was called) - if (rollback == null) { - logger.warn("{} {} rollbackTenant, rollback is null", MessageEnum.RA_ROLLBACK_NULL, - ErrorCode.DataError.getValue()); - return; - } - - // Get the elements of the VnfRollback object for easier access - String cloudSiteId = rollback.getCloudId(); - String tenantId = rollback.getTenantId(); - - logger.debug("Rolling Back Tenant {} in {}", rollback.getTenantId(), cloudSiteId); - - if (rollback.getTenantCreated()) { - try { - - MsoTenantUtils tUtils = tFactory.getTenantUtils(cloudSiteId); - tUtils.deleteTenant(tenantId, cloudSiteId); - } catch (MsoException me) { - me.addContext(ROLLBACK_TENANT); - // Failed to delete the tenant. - logger.error("{} {} Exception - rollbackTenant {}: ", MessageEnum.RA_ROLLBACK_TENANT_ERR, - ErrorCode.DataError.getValue(), tenantId, me); - throw new TenantException(me); - } - } - return; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java deleted file mode 100644 index c782adec64..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/TenantAdapterRest.java +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import java.util.Map; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.onap.so.adapters.tenant.exceptions.TenantAlreadyExists; -import org.onap.so.adapters.tenant.exceptions.TenantException; -import org.onap.so.adapters.tenantrest.CreateTenantError; -import org.onap.so.adapters.tenantrest.CreateTenantRequest; -import org.onap.so.adapters.tenantrest.CreateTenantResponse; -import org.onap.so.adapters.tenantrest.DeleteTenantError; -import org.onap.so.adapters.tenantrest.DeleteTenantRequest; -import org.onap.so.adapters.tenantrest.DeleteTenantResponse; -import org.onap.so.adapters.tenantrest.QueryTenantError; -import org.onap.so.adapters.tenantrest.QueryTenantResponse; -import org.onap.so.adapters.tenantrest.RollbackTenantError; -import org.onap.so.adapters.tenantrest.RollbackTenantRequest; -import org.onap.so.adapters.tenantrest.RollbackTenantResponse; -import org.onap.so.adapters.tenantrest.TenantRollback; -import org.onap.so.openstack.beans.MsoTenant; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * This class services calls to the REST interface for Tenants (http://host:port/vnfs/rest/v1/tenants) Both XML and JSON - * can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. - */ -@Path("/v1/tenants") -@Api(value = "/v1/tenants", description = "root of tenant adapters restful web service") -@Component -public class TenantAdapterRest { - - private static Logger logger = LoggerFactory.getLogger(TenantAdapterRest.class); - private static final String EXCEPTION = "Exception :"; - // RAA? No logging in wrappers - @Autowired - private MsoTenantAdapterImpl tenantImpl; - - - - /* - * URL: EP: http://host:8080/tenants/rest Resource: v1/tenants REQ - metadata? { "cloudSiteId": "DAN", "tenantName": - * "RAA_1", "failIfExists": true, "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1" }} RESP- { - * "cloudSiteId": "DAN", "tenantId": "128e10b9996d43a7874f19bbc4eb6749", "tenantCreated": true, "tenantRollback": { - * "tenantId": "128e10b9996d43a7874f19bbc4eb6749", "cloudId": "DAN", // RAA? cloudId instead of cloudSiteId - * "tenantCreated": true, "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1" } } } - */ - @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateTenant", response = Response.class, - notes = "Creates a new tenant, CreateTenantRequest data is required") - @ApiResponses({@ApiResponse(code = 200, message = "tenant has been successfully created"), - @ApiResponse(code = 500, message = "create tenant failed")}) - public Response createTenant( - @ApiParam(value = "details of tenant being created", required = true) CreateTenantRequest req) { - logger.debug("createTenant enter: {}", req.toJsonString()); - - String newTenantId = null; - TenantRollback tenantRollback; - - try { - Holder<String> htenant = new Holder<>(); - Holder<TenantRollback> hrollback = new Holder<>(); - MsoTenantAdapter impl = tenantImpl; - impl.createTenant(req.getCloudSiteId(), req.getTenantName(), req.getMetadata(), req.getFailIfExists(), - req.getBackout(), req.getMsoRequest(), htenant, hrollback); - newTenantId = htenant.value; - tenantRollback = hrollback.value; - - } catch (TenantAlreadyExists tae) { - logger.debug(EXCEPTION, tae); - CreateTenantError exc = - new CreateTenantError(tae.getMessage(), tae.getFaultInfo().getCategory(), Boolean.TRUE); - return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).entity(exc).build(); - } catch (TenantException te) { - logger.debug(EXCEPTION, te); - CreateTenantError exc = new CreateTenantError(te.getFaultInfo().getMessage(), - te.getFaultInfo().getCategory(), Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } catch (Exception e) { - logger.debug(EXCEPTION, e); - CreateTenantError exc = new CreateTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } - - CreateTenantResponse resp = new CreateTenantResponse(req.getCloudSiteId(), newTenantId, - tenantRollback.getTenantCreated(), tenantRollback); - return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); - } - - /* - * URL: http://host:8080/tenants/rest Resource: v1/tenant/tennatId REQ: {"cloudSiteId": "DAN", "tenantId": - * "ca84cd3d3df44272845da554656b3ace", "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1" } } RESP: - * {"tenantDeleted": true} - */ - @DELETE - @Path("{tenantId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteTenant", response = Response.class, notes = "Delete an existing tenant") - @ApiResponses({@ApiResponse(code = 200, message = "tenant has been successfully deleted"), - @ApiResponse(code = 500, message = "delete tenant failed")}) - public Response deleteTenant( - @ApiParam(value = "tenantId of tenant being deleted", - required = true) @PathParam("tenantId") String tenantId, - @ApiParam(value = "DeleteTenantRequest object containing additional information of tenant being deleted", - required = false) DeleteTenantRequest req) { - boolean tenantDeleted = false; - - try { - Holder<Boolean> deleted = new Holder<>(); - MsoTenantAdapter impl = tenantImpl; - impl.deleteTenant(req.getCloudSiteId(), req.getTenantId(), req.getMsoRequest(), deleted); - tenantDeleted = deleted.value; - } catch (TenantException te) { - logger.debug(EXCEPTION, te); - DeleteTenantError exc = new DeleteTenantError(te.getFaultInfo().getMessage(), - te.getFaultInfo().getCategory(), Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } catch (Exception e) { - logger.debug(EXCEPTION, e); - DeleteTenantError exc = new DeleteTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } - DeleteTenantResponse resp = new DeleteTenantResponse(); - resp.setTenantDeleted(tenantDeleted); - return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); - } - - /* - * URL EP://http://host:8080/tenants/rest Resource: /v1/tenants Params:?tenantNameOrId=RAA_1&cloudSiteId=DAN RESP { - * "tenantId": "214b428a1f554c02935e66330f6a5409", "tenantName": "RAA_1", "metadata": {} } - */ - @GET - @Path("{tenantId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryTenant", response = Response.class, notes = "Query an existing tenant") - @ApiResponses({@ApiResponse(code = 200, message = "tenant has been successfully queried"), - @ApiResponse(code = 500, message = "query tenant failed")}) - public Response queryTenant(@ApiParam(value = "tenantId", required = true) @PathParam("tenantId") String tenantId, - // @QueryParam("tenantNameOrId") String tenantNameOrId, //RAA? diff from doc - @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "msoRequest.requestId", - required = true) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) { - MsoTenant tenant = null; - try { - Holder<String> htenant = new Holder<>(); - Holder<String> tenantName = new Holder<>(); - Holder<Map<String, String>> metadata = new Holder<>(); - MsoTenantAdapter impl = tenantImpl; - impl.queryTenant(cloudSiteId, tenantId, null, htenant, tenantName, metadata); - tenant = new MsoTenant(htenant.value, tenantName.value, metadata.value); - - } catch (TenantException te) { - logger.debug(EXCEPTION, te); - QueryTenantError exc = - new QueryTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory()); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } catch (Exception e) { - logger.debug(EXCEPTION, e); - QueryTenantError exc = new QueryTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } - QueryTenantResponse resp = - new QueryTenantResponse(tenant.getTenantId(), tenant.getTenantName(), tenant.getMetadata()); - return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); - } - - /* - * URL EP: //http://host:8080/tenants/rest Resource: /v1/tenants/rollback REQ {"cloudSiteId": "DAN", "tenantId": - * "f58abb05041d4ff384d4d22d1ccd2a6c", "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1" } } RESP: - * {"tenantDeleted": true} - */ - @DELETE - @Path("") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackTenant", response = Response.class, notes = "Rollback an existing tenant") - @ApiResponses({@ApiResponse(code = 200, message = "tenant has been successfully rolledback"), - @ApiResponse(code = 500, message = "rollback tenant failed")}) - public Response rollbackTenant( - @ApiParam(value = "rollback, command action", required = true) @QueryParam("rollback") String action, - @ApiParam(value = "RollbackTenantRequest", required = true) RollbackTenantRequest req) { - try { - MsoTenantAdapter impl = tenantImpl; - impl.rollbackTenant(req.getTenantRollback()); - } catch (TenantException te) { - logger.debug(EXCEPTION, te); - RollbackTenantError exc = new RollbackTenantError(te.getFaultInfo().getMessage(), - te.getFaultInfo().getCategory(), Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } catch (Exception e) { - logger.debug(EXCEPTION, e); - RollbackTenantError exc = - new RollbackTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE); - return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build(); - } - - RollbackTenantResponse resp = new RollbackTenantResponse(); - resp.setTenantRolledback(req != null); - return Response.status(HttpServletResponse.SC_OK).entity(resp).build(); - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExists.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExists.java deleted file mode 100644 index 8955eb50c6..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExists.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - - - -import javax.xml.ws.WebFault; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - - -/** - * This class reports an exception when trying to create a VNF when another VNF of the same name already exists in the - * target cloud/tenant. Note that the createVnf method suppresses this exception by default. - * - * - */ -@WebFault(name = "TenantAlreadyExists", faultBean = "org.onap.so.adapters.tenant.exceptions.TenantExceptionBean", - targetNamespace = "http://org.onap.so/tenant") -public class TenantAlreadyExists extends TenantException { - - private static final long serialVersionUID = 1L; - - public TenantAlreadyExists(String name, String cloudId, String tenantId) { - super("Tenant " + name + " already exists in " + cloudId + " with ID " + tenantId, - MsoExceptionCategory.USERDATA); - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantException.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantException.java deleted file mode 100644 index 998da98c8d..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantException.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - - - -import javax.xml.ws.WebFault; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * This class simply extends Exception (without addition additional functionality) to provide an identifier for Tenant - * related exceptions on create, delete, query. - * - * - */ -@WebFault(name = "TenantException", faultBean = "org.onap.so.adapters.tenant.exceptions.TenantExceptionBean", - targetNamespace = "http://org.onap.so/tenant") -public class TenantException extends Exception { - - private static final long serialVersionUID = 1L; - - private TenantExceptionBean faultInfo; - - public TenantException(String msg) { - super(msg); - faultInfo = new TenantExceptionBean(msg); - } - - public TenantException(String msg, Throwable e) { - super(msg, e); - faultInfo = new TenantExceptionBean(msg); - } - - public TenantException(String msg, MsoExceptionCategory category) { - super(msg); - faultInfo = new TenantExceptionBean(msg, category); - } - - public TenantException(String msg, MsoExceptionCategory category, Throwable e) { - super(msg, e); - faultInfo = new TenantExceptionBean(msg, category); - } - - public TenantException(MsoException e) { - super(e); - faultInfo = new TenantExceptionBean(e.getContextMessage(), e.getCategory()); - } - - public TenantExceptionBean getFaultInfo() { - return faultInfo; - } - - public void setFaultInfo(TenantExceptionBean faultInfo) { - this.faultInfo = faultInfo; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBean.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBean.java deleted file mode 100644 index 2d9260615a..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBean.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - - -import java.io.Serializable; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; - -/** - * Jax-WS Fault Bean for Network Exceptions - */ -public class TenantExceptionBean implements Serializable { - - private static final long serialVersionUID = -9062290006520066109L; - - private String message; - private MsoExceptionCategory category; - - public TenantExceptionBean() {} - - public TenantExceptionBean(String message) { - this.message = message; - } - - public TenantExceptionBean(String message, MsoExceptionCategory category) { - this.message = message; - this.category = category; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public MsoExceptionCategory getCategory() { - return category; - } - - public void setCategory(MsoExceptionCategory category) { - this.category = category; - } -} 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 0512912b9f..04c6ea4ff7 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 @@ -488,7 +488,13 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (Pserver pserver : serverHostnames.values()) { AAIResourceUri uri = AAIUriFactory .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserver.getHostname())); - resourcesClient.createIfNotExists(uri, Optional.of(pserver)); + if (resourcesClient.exists(uri)) { + Pserver updatePserver = new Pserver(); + updatePserver.setPserverId(pserver.getPserverId()); + resourcesClient.update(uri, updatePserver); + } else { + resourcesClient.create(uri, pserver); + } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 1f6c0df90f..bbdd05bddc 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -247,8 +247,8 @@ public class AaiHelper { Pserver pserver = new Pserver(); pserver.setInMaint(false); pserver.setHostname(server.getHypervisorHostname()); - if (server.getId() != null) { - pserver.setPserverId(server.getId()); + if (server.getHostId() != null) { + pserver.setPserverId(server.getHostId()); } if (server.getHost() != null) { pserver.setPserverName2(server.getHost()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java deleted file mode 100644 index b695a538bb..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/MsoTenantAdapterImplTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.tenant; - -import java.util.HashMap; -import javax.xml.ws.Holder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.adapters.tenantrest.TenantRollback; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.entity.MsoRequest; - -@RunWith(MockitoJUnitRunner.class) -public class MsoTenantAdapterImplTest { - - @Mock - private CloudConfig cloudConfig; - - @Spy - @InjectMocks - private MsoTenantAdapterImpl msoTenantAdapter; - - @Test - public void healthCheck() throws Exception { - msoTenantAdapter.healthCheck(); - } - - @Test(expected = NullPointerException.class) - public void createTenant() throws Exception { - msoTenantAdapter.createTenant("site", "tenant", new HashMap<>(), true, true, new MsoRequest(), - new Holder<String>(), new Holder<TenantRollback>()); - } - - @Test(expected = NullPointerException.class) - public void queryTenant() throws Exception { - msoTenantAdapter.queryTenant("site", "tenant", new MsoRequest(), new Holder<>(), new Holder<>(), - new Holder<>()); - } - - @Test(expected = NullPointerException.class) - public void deleteTenant() throws Exception { - msoTenantAdapter.deleteTenant("cloud", "tenant", new MsoRequest(), new Holder<Boolean>()); - } - - @Test - public void rollbackTenant() throws Exception { - msoTenantAdapter.rollbackTenant(new TenantRollback()); - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java deleted file mode 100644 index 1a44934187..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java +++ /dev/null @@ -1,240 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteTenantById_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetMetadata_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetRoles_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantById_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantById_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantByName_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetTenantByName_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetUser_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostMetadata_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostTenantWithBodyFile_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostTenant_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutRolesAdmin_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessAdmin; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.so.adapters.tenantrest.CreateTenantRequest; -import org.onap.so.adapters.tenantrest.CreateTenantResponse; -import org.onap.so.adapters.tenantrest.DeleteTenantRequest; -import org.onap.so.adapters.tenantrest.DeleteTenantResponse; -import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.entity.MsoRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public class TenantAdapterRestTest extends BaseRestTestUtils { - - @Autowired - private JettisonStyleMapperProvider jettisonTypeObjectMapper; - - @Test - public void testCreateTenantCreated() throws JsonParseException, JsonMappingException, IOException { - - CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; - String requestId = "62265093-277d-4388-9ba6-449838ade586"; - String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - String tenantName = "testingTenantName"; - boolean failIfExists = true; - boolean backout = true; - Map<String, String> metaData = new HashMap<>(); - metaData.put("key1", "value2"); - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setMsoRequest(msoReq); - request.setTenantName(tenantName); - request.setMetadata(metaData); - request.setBackout(backout); - request.setFailIfExists(failIfExists); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantByName_404(wireMockServer, tenantName); - - mockOpenStackPostTenantWithBodyFile_200(wireMockServer); - - mockOpenStackGetUser_200(wireMockServer, "m93945"); - - mockOpenStackGetRoles_200(wireMockServer, "OS-KSADM"); - - mockOpenStackPutRolesAdmin_200(wireMockServer, "OS-KSADM"); - - mockOpenStackPostMetadata_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateTenantRequest> entity = new HttpEntity<CreateTenantRequest>(request, headers); - - ResponseEntity<CreateTenantResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/tenants"), HttpMethod.POST, entity, CreateTenantResponse.class); - - CreateTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateTenantResponse_Created.json"), CreateTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateTenantExists() throws JsonParseException, JsonMappingException, IOException { - - CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; - String requestId = "62265093-277d-4388-9ba6-449838ade586"; - String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - String tenantName = "testingTenantName"; - boolean failIfExists = false; - boolean backout = true; - Map<String, String> metadata = new HashMap<>(); - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setMsoRequest(msoReq); - request.setTenantName(tenantName); - request.setMetadata(metadata); - request.setBackout(backout); - request.setFailIfExists(failIfExists); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantByName_200(wireMockServer, tenantName); - - mockOpenStackPostTenant_200(wireMockServer); - - mockOpenStackGetMetadata_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateTenantRequest> entity = new HttpEntity<CreateTenantRequest>(request, headers); - - ResponseEntity<CreateTenantResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/tenants"), HttpMethod.POST, entity, CreateTenantResponse.class); - - CreateTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateTenantResponse_Exists.json"), CreateTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testDeleteTenant() throws IOException { - - DeleteTenantRequest request = new DeleteTenantRequest(); - String cloudSiteId = "mtn13"; - String tenantId = "tenantId"; - String requestId = "ra1"; - String serviceInstanceId = "sa1"; - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setTenantId(tenantId); - request.setMsoRequest(msoReq); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantById_200(wireMockServer, tenantId); - - mockOpenStackDeleteTenantById_200(wireMockServer, tenantId); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<DeleteTenantRequest> entity = new HttpEntity<DeleteTenantRequest>(request, headers); - - ResponseEntity<DeleteTenantResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/tenants/tenantId"), HttpMethod.DELETE, - entity, DeleteTenantResponse.class); - - DeleteTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteTenantResponse_Success.json"), DeleteTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - // @Ignore - @Test - public void testDeleteTenantFails() throws IOException { - - DeleteTenantRequest request = new DeleteTenantRequest(); - String cloudSiteId = "mtn13"; - String tenantId = "tenantId"; - String requestId = "ra1"; - String serviceInstanceId = "sa1"; - - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(requestId); - msoReq.setServiceInstanceId(serviceInstanceId); - - request.setCloudSiteId(cloudSiteId); - request.setTenantId(tenantId); - request.setMsoRequest(msoReq); - - mockOpenStackResponseAccessAdmin(wireMockServer, wireMockPort); - - mockOpenStackGetTenantById_404(wireMockServer, tenantId); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<DeleteTenantRequest> entity = new HttpEntity<DeleteTenantRequest>(request, headers); - - ResponseEntity<DeleteTenantResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/tenants/tenantId"), HttpMethod.DELETE, - entity, DeleteTenantResponse.class); - - DeleteTenantResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteTenantResponse_Failed.json"), DeleteTenantResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Ignore - @Test - public void testQuaryTenant() { - - - - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java deleted file mode 100644 index 106a96a091..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantAlreadyExistsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ Licensed under the Apache License, - * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class TenantAlreadyExistsTest { - - @Test - public void test() { - TenantAlreadyExists tar = new TenantAlreadyExists("name", "cloudId", "tenantId"); - assert (tar != null); - assertNotNull(tar); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java deleted file mode 100644 index ece92b4ac0..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionBeanTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ Licensed under the Apache License, - * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import static org.junit.Assert.*; - -public class TenantExceptionBeanTest { - - @Mock - private MsoExceptionCategory mec; - - @InjectMocks - private TenantExceptionBean teb; - - @Test - public void test() { - teb = new TenantExceptionBean("message", mec); - teb.setMessage("message"); - teb.setCategory(MsoExceptionCategory.INTERNAL); - teb.setCategory(MsoExceptionCategory.IO); - teb.setCategory(MsoExceptionCategory.OPENSTACK); - teb.setCategory(MsoExceptionCategory.USERDATA); - assert (teb.getMessage().equals("message")); - assert (teb.getCategory() != null); - assertNotNull(teb); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java deleted file mode 100644 index 1ce4c664ac..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/exceptions/TenantExceptionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 TechMahindra - * ================================================================================ Licensed under the Apache License, - * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.tenant.exceptions; - -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import static org.junit.Assert.*; - -public class TenantExceptionTest { - - @Mock - private TenantExceptionBean teb; - - @Mock - private MsoExceptionCategory mec; - - @InjectMocks - private TenantException te; - - @Test - public void test() { - teb = new TenantExceptionBean("message"); - teb.setMessage("message"); - teb.setCategory(MsoExceptionCategory.INTERNAL); - te = new TenantException("message", mec); - te.setFaultInfo(teb); - assert (te.getFaultInfo() != null); - assert (te.getFaultInfo().equals(teb)); - assertNotNull(teb); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java index c02afc3327..054cc378ef 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -41,13 +41,18 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); - protected List<FlowManipulator> flowManipulators; + protected List<PreFlowManipulator> flowManipulators; + + protected List<PostFlowManipulator> postflowManipulators; @PostConstruct protected void init() { flowManipulators = new ArrayList<>( - Optional.ofNullable(context.getBeansOfType(FlowManipulator.class)).orElse(new HashMap<>()).values()); + Optional.ofNullable(context.getBeansOfType(PreFlowManipulator.class)).orElse(new HashMap<>()).values()); + + postflowManipulators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostFlowManipulator.class)) + .orElse(new HashMap<>()).values()); } @@ -56,11 +61,26 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { do { sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); - List<FlowManipulator> filtered = filterListeners(flowManipulators, + List<PreFlowManipulator> filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); + + logger.info("Running pre flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + } while (isBuildingBlockSkipped(sequenceBeforeFlowManipulator, execution)); + } + + public void postModifyFlows(List<ExecuteBuildingBlock> flowsToExecute, BuildingBlockExecution execution) { + int sequenceBeforeFlowManipulator; + do { + sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence() - 1); + List<PostFlowManipulator> filtered = filterListeners(postflowManipulators, (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), execution.getCurrentSequence() == 0, execution))); - logger.info("Running flow manipulators:\n{}", + logger.info("Running post flow manipulators:\n{}", filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); } while (isBuildingBlockSkipped(sequenceBeforeFlowManipulator, execution)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java new file mode 100644 index 0000000000..b0e259b801 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PostFlowManipulator.java @@ -0,0 +1,5 @@ +package org.onap.so.bpmn.common.listener.flowmanipulator; + +public interface PostFlowManipulator extends FlowManipulator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java new file mode 100644 index 0000000000..1020f65695 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/PreFlowManipulator.java @@ -0,0 +1,5 @@ +package org.onap.so.bpmn.common.listener.flowmanipulator; + +public interface PreFlowManipulator extends FlowManipulator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 7c283ab153..5cbadd6b75 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -410,15 +410,7 @@ public class BBInputSetup implements JavaDelegate { parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, parameter.getResourceId()); this.populateVolumeGroup(parameter); } else if (modelType.equals(ModelType.vfModule)) { - if (parameter.getBbName().contains("Configuration")) { - parameter.setResourceId(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID)); - parameter.getModelInfo().setModelCustomizationUuid(parameter.getConfigurationKey()); - populateConfiguration(parameter); - } else { - parameter.getLookupKeyMap().put(ResourceKey.VF_MODULE_ID, parameter.getResourceId()); - parameter.setCloudConfiguration(parameter.getRequestDetails().getCloudConfiguration()); - this.populateVfModule(parameter); - } + populateVfModuleOnAssignAndCreateFlows(parameter); } else if (modelType.equals(ModelType.instanceGroup)) { parameter.getLookupKeyMap().put(ResourceKey.INSTANCE_GROUP_ID, parameter.getResourceId()); this.populateInstanceGroup(parameter); @@ -435,6 +427,18 @@ public class BBInputSetup implements JavaDelegate { parameter.getServiceInstance().getInstanceGroups().add(instanceGroup); } + protected void populateVfModuleOnAssignAndCreateFlows(BBInputSetupParameter parameter) throws Exception { + if (parameter.getBbName().contains("Configuration")) { + parameter.setResourceId(parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID)); + parameter.getModelInfo().setModelCustomizationUuid(parameter.getConfigurationKey()); + populateConfiguration(parameter); + } else { + parameter.getLookupKeyMap().put(ResourceKey.VF_MODULE_ID, parameter.getResourceId()); + parameter.setCloudConfiguration(parameter.getRequestDetails().getCloudConfiguration()); + this.populateVfModule(parameter); + } + } + protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { // @TODO: this will populate the instanceGroup model info. // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index f5955d6c7d..d1da38f2d9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -204,8 +204,10 @@ public class WorkflowAction { } // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, // enable it. - List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); - if (sIRequest.getRequestDetails().getRequestParameters() != null && userParams != null) { + if (sIRequest.getRequestDetails().getRequestParameters() != null + && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { + List<Map<String, Object>> userParams = + sIRequest.getRequestDetails().getRequestParameters().getUserParams(); for (Map<String, Object> params : userParams) { if (params.containsKey(HOMINGSOLUTION)) { execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION))); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index b756772188..ec2ca74fa7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -420,15 +420,24 @@ public class WorkflowActionBBTasks { } public void postProcessingExecuteBB(DelegateExecution execution) { - List<ExecuteBuildingBlock> flowsToExecute = - (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - String handlingCode = (String) execution.getVariable(HANDLINGCODE); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); - String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); - if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) { - postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); + try { + List<ExecuteBuildingBlock> flowsToExecute = + (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + String handlingCode = (String) execution.getVariable(HANDLINGCODE); + final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); + logger.debug("Current Sequence: {}", currentSequence); + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); + String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); + if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte + && "Success".equalsIgnoreCase(handlingCode)) { + postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); + } + + flowManipulatorListenerRunner.postModifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); + } catch (Exception ex) { + logger.error("Exception in postProcessingExecuteBB", ex); + workflowAction.buildAndThrowException(execution, "Failed to post process Execute BB"); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java index bc32489944..b90844a733 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java @@ -22,12 +22,12 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; import java.util.List; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.springframework.stereotype.Component; @Component -public class HomingListener implements FlowManipulator { +public class HomingListener implements PreFlowManipulator { @Override diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java index 4cde9c1fc8..08e877956d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -26,7 +26,7 @@ import java.util.Optional; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class MultiStageSkipListener implements FlowManipulator, PostCompletionRequestsDbListener { +public class MultiStageSkipListener implements PreFlowManipulator, PostCompletionRequestsDbListener { @Autowired protected BBInputSetupUtils bbInputSetupUtils; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index 564ee91fb2..3af839fbec 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -27,7 +27,7 @@ import java.util.Set; import org.apache.logging.log4j.util.Strings; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; @@ -38,7 +38,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @Component -public class SkipCDSBuildingBlockListener implements FlowManipulator { +public class SkipCDSBuildingBlockListener implements PreFlowManipulator { @Autowired private CatalogDbClient catalogDbClient; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java index 83f61e3a4f..5ffba455b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -3,7 +3,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; import java.util.List; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.common.listener.flowmanipulator.PreFlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class SkipConfigVnfListener implements FlowManipulator { +public class SkipConfigVnfListener implements PreFlowManipulator { private final CatalogDbClient catalogDbClient; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 100c32f1c2..d0cd4b0b46 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -111,6 +111,7 @@ public class WorkflowActionTest extends BaseTaskTest { private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json"; private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json"; private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json"; + private static final String VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON = "VfModuleCreateWithFabricNoParams.json"; private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON = "VfModuleReplaceRebuildVolumeGroups.json"; private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; @@ -1493,6 +1494,27 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void selectExecutionListALaCarteNoRequestParametersTest() throws Exception { + String gAction = "createInstance"; + String resource = "VfModule"; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_NO_PARAMS_JSON); + initExecution(gAction, bpmnRequest, true); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB"); + } + + @Test public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; ObjectMapper mapper = new ObjectMapper(); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json new file mode 100644 index 0000000000..33b7eeee4a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabricNoParams.json @@ -0,0 +1,62 @@ +{ + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "model-cust-name", + "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelType": "vfModule", + "modelName": "test-model-name", + "modelVersion": "1", + "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelInstanceName": "test-model-instance-name" + }, + "requestInfo": { + "source": "VID", + "instanceName": "instanceName", + "suppressRollback": false, + "requestorId": "user" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de", + "modelInfo": { + "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f", + "modelType": "service", + "modelName": "model-name", + "modelVersion": "1.0", + "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f" + } + } + }, + { + "relatedInstance": { + "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", + "modelInfo": { + "modelCustomizationName": "modle-cust-name", + "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelType": "vnf", + "modelName": "modle-name", + "modelVersion": "1.0", + "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelInstanceName": "model-inst-name" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "872f331350c54e59991a8de2cbffb40c", + "cloudOwner": "my-custom-cloud-owner", + "lcpCloudRegionId": "cloud-region" + } + } +}
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index d1b4c2b900..0df378db66 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -248,7 +248,7 @@ public abstract class RestClient { return e.getCause() instanceof ConnectException; }); result.add(e -> { - return e.getCause() instanceof ResponseProcessingException; + return e instanceof ResponseProcessingException; }); return result; } diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index 3bf4ccf127..b5efa17216 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -34,9 +34,11 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Optional; +import javax.net.ssl.SSLException; import javax.ws.rs.NotFoundException; import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; +import javax.ws.rs.client.ResponseProcessingException; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; @@ -81,6 +83,20 @@ public class RestClientTest { } @Test + public void retryOnChunkedNetworkIssue() throws Exception { + RestClient spy = buildSpy(); + doThrow(new ResponseProcessingException(null, "something something", new SSLException("wow"))).when(spy) + .buildRequest(any(String.class), ArgumentMatchers.isNull()); + try { + spy.get(); + } catch (Exception e) { + // ignore this exception for this test + } + verify(spy, times(3)).buildRequest(any(String.class), ArgumentMatchers.isNull()); + + } + + @Test public void exceptionDoNotRetry() throws Exception { RestClient spy = buildSpy(); doThrow(new WebApplicationException(new NotFoundException())).when(spy).buildRequest(any(String.class), diff --git a/releases/1.8.0.yaml b/releases/1.8.0.yaml new file mode 100644 index 0000000000..99bf277e47 --- /dev/null +++ b/releases/1.8.0.yaml @@ -0,0 +1,36 @@ + +--- +distribution_type: 'container' +container_release_tag: '1.8.0' +project: 'so' +log_dir: 'so-maven-docker-stage-master/635/' +ref: '31aba9aba28d7be2417a99ba7e862a7a8c68005b' +containers: + - name: 'so/vnfm-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/catalog-db-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/request-db-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/openstack-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/sdnc-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/vfc-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/sdc-controller' + version: '1.8.0-20210215T1458' + - name: 'so/bpmn-infra' + version: '1.8.0-20210215T1458' + - name: 'so/so-monitoring' + version: '1.8.0-20210215T1458' + - name: 'so/api-handler-infra' + version: '1.8.0-20210215T1458' + - name: 'so/nssmf-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/mso-cnf-adapter' + version: '1.8.0-20210210T0420' + - name: 'so/so-oof-adapter' + version: '1.8.0-20210215T1458' + - name: 'so/so-etsi-nfvo-ns-lcm' + version: '1.8.0-20210215T1458' |