diff options
45 files changed, 1086 insertions, 1767 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-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy index eabe58488e..7e30d79152 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -35,6 +35,7 @@ class ActivateSliceSubnet extends AbstractServiceTaskProcessor { String Prefix="ActivateSliceSubnet_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + AnNssmfUtils anNssmfUtils = new AnNssmfUtils() RequestDBUtil requestDBUtil = new RequestDBUtil() private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) @@ -136,16 +137,19 @@ class ActivateSliceSubnet extends AbstractServiceTaskProcessor { def prepareInitOperationStatus = { DelegateExecution execution -> logger.debug(Prefix + "prepareInitOperationStatus Start") - String serviceId = execution.getVariable("serviceInstanceID") + String nssiId = execution.getVariable("serviceInstanceID") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") String operationType = execution.getVariable("operationType") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + String modelUuid = anNssmfUtils.getModelUuid(execution, nssiId) + logger.debug("Generated new job for Service Instance serviceId:" + nsiId + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) + + initStatus.setServiceId(nsiId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(modelUuid) + initStatus.setResourceInstanceID(nssiId) initStatus.setOperType(operationType) requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) @@ -153,7 +157,6 @@ class ActivateSliceSubnet extends AbstractServiceTaskProcessor { } - /** * return sync response */ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index 75006365f2..5d952b6b8d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -450,4 +450,22 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe return json.toString() } + + public String getModelUuid(DelegateExecution execution, String instanceId) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + ServiceInstance serviceInstance = new ServiceInstance() + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) + if (!client.exists(uri)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") + } + AAIResultWrapper wrapper = client.get(uri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + + if(si.isPresent()) { + serviceInstance = si.get() + } + return serviceInstance.getModelVersionId() + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy index 897cdfcd7b..1d75cf5216 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy @@ -63,6 +63,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { RequestDBUtil requestDBUtil = new RequestDBUtil() JsonUtils jsonUtil = new JsonUtils() ObjectMapper objectMapper = new ObjectMapper() + AnNssmfUtils anNssmfUtils = new AnNssmfUtils() private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) private static final Logger logger = LoggerFactory.getLogger(DoActivateAccessNSSI.class) @@ -197,15 +198,11 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { callbackURL.append("/").append(messageType).append("/").append(reqId) JsonObject input = new JsonObject() + String sliceProfileId = execution.getVariable("anNfSPId") + input.addProperty("sliceProfileId",sliceProfileId) input.addProperty("RANNFNSSIId", anNfNssiId) input.addProperty("callbackURL", callbackURL.toString()) - input.addProperty("s-NSSAI", sNssai.toString()) - - JsonObject Payload = new JsonObject() - Payload.addProperty("version", "1.0") - Payload.addProperty("rpc-name", "activateRANSlice") - Payload.addProperty("correlation-id", reqId) - Payload.addProperty("type", "request") + input.addProperty("sNSSAI", sNssai.toString()) JsonObject wrapinput = new JsonObject() wrapinput.addProperty("Action", action) @@ -220,11 +217,16 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { body.add("input", wrapinput) JsonObject sdnrRequest = new JsonObject() - Payload.addProperty("input", input.toString()) - wrapinput.add("Payload", Payload) + JsonObject payload = new JsonObject() + payload.add("input", input) + wrapinput.addProperty("Payload", payload.toString()) wrapinput.add("CommonHeader", CommonHeader) body.add("input", wrapinput) sdnrRequest.add("body", body) + sdnrRequest.addProperty("version", "1.0") + sdnrRequest.addProperty("rpc-name", "activateRANSlice") + sdnrRequest.addProperty("correlation-id", reqId) + sdnrRequest.addProperty("type", "request") String json = sdnrRequest.toString() execution.setVariable("sdnrRequest", json) @@ -395,27 +397,29 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType(networkType) - esrInfo.setVendor(VENDOR_ONAP) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", networkType) + esrInfo.addProperty("vendor", VENDOR_ONAP) - ServiceInfo serviceInfo = new ServiceInfo() - serviceInfo.setNssiId(instanceId) - serviceInfo.setNsiId(execution.getVariable("nsiId")) - serviceInfo.setGlobalSubscriberId(globalSubscriberId) - serviceInfo.setSubscriptionServiceType(subscriptionServiceType) + JsonObject serviceInfo = new JsonObject() + serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) + serviceInfo.addProperty("nssiId", instanceId) + serviceInfo.addProperty("globalSubscriberId", globalSubscriberId) + serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType) - execution.setVariable("${networkType}_esrInfo", esrInfo) + execution.setVariable("${networkType}_esrInfo", esrInfo.toString()) execution.setVariable("${networkType}_responseId", responseId) - execution.setVariable("${networkType}_serviceInfo", serviceInfo) + execution.setVariable("${networkType}_serviceInfo", serviceInfo.toString()) } void validateJobStatus(DelegateExecution execution,String responseDescriptor) { logger.debug("validateJobStatus ${responseDescriptor}") - String status = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.status") - String statusDescription = jsonUtil.getJsonValue(responseDescriptor, "responseDescriptor.statusDescription") - if("finished".equalsIgnoreCase(status)) { + String jobResponse = execution.getVariable("tn_responseDescriptor") + logger.debug("Job status response "+jobResponse) + String status = jsonUtil.getJsonValue(jobResponse, "status") + String statusDescription = jsonUtil.getJsonValue(jobResponse, "statusDescription") + if("finished".equalsIgnoreCase(status)) { execution.setVariable("isSuccess", true) }else { execution.setVariable("isSuccess", false) @@ -458,15 +462,18 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { void prepareUpdateJobStatus(DelegateExecution execution,String status,String progress,String statusDescription) { logger.debug("${Prefix} Start prepareUpdateJobStatus : ${statusDescription}") - String serviceId = execution.getVariable("anNssiId") + String nssiId = execution.getVariable("anNssiId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") + //String modelUuid = execution.getVariable("modelUuid") + String modelUuid = anNssmfUtils.getModelUuid(execution, nssiId) String operationType = execution.getVariable("operationType") ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) + roStatus.setServiceId(nsiId) roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceTemplateUUID(modelUuid) + roStatus.setResourceInstanceID(nssiId) roStatus.setOperType(operationType) roStatus.setProgress(progress) roStatus.setStatus(status) @@ -562,7 +569,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { String subscriptionServiceType = execution.getVariable("subscriptionServiceType") Map<String, ServiceInstance> relatedNssis = execution.getVariable("relatedNssis") - String anNssiId = execution.getVariable("anNssiId") + String nsiId = execution.getVariable("nsiId") List<String> sNssaiList = execution.getVariable("sNssaiList") ServiceInstance tnNssi = relatedNssis.get(serviceFunction) @@ -572,11 +579,11 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { ActDeActNssi actDeactNssi = new ActDeActNssi() actDeactNssi.setNssiId(nssiId) - actDeactNssi.setNsiId(anNssiId) + actDeactNssi.setNsiId(nsiId) actDeactNssi.setSliceProfileId(relatedSPs.get(serviceFunction).getServiceInstanceId()) actDeactNssi.setSnssaiList(sNssaiList) - JsonObject esrInfo = new JsonObject() + JsonObject esrInfo = new JsonObject() esrInfo.addProperty("networkType", "tn") esrInfo.addProperty("vendor", VENDOR_ONAP) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy index 5e50b9d52d..2d18108acd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -78,30 +78,19 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String operationType = execution.getVariable("operationType") String oStatus= "" - if(operationType.equals("activateInstance")) { oStatus ="activated" } else { oStatus ="deactivated" } - execution.setVariable("oStatus", oStatus) String sNssaiListAsString = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "snssaiList") - - logger.debug("sNssaiListAsString "+sNssaiListAsString) - List<String> sNssaiList = jsonUtil.StringArrayToList(sNssaiListAsString) - - logger.debug("sNssaiList "+sNssaiList) - - String sNssai = sNssaiList.get(0) execution.setVariable("sNssai", sNssai) - - logger.debug("sNssai: "+sNssai) - String serviceType = execution.getVariable("subscriptionServiceType") execution.setVariable("serviceType", serviceType) + logger.debug("operationType: {} , sNssai: {}, serviceType: {}.",operationType, sNssai, serviceType) logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: preProcessRequest ****") } @@ -117,31 +106,30 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { if(nsi.isPresent()) { List<Relationship> relationshipList = nsi.get().getRelationshipList()?.getRelationship() List spiWithsNssaiAndOrchStatusList = new ArrayList<>() - for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "service-instance") { + if (("service-instance").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + if (("service-instance.service-instance-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("networkServiceInstanceId", relationshipData.getRelationshipValue()) } } for (RelatedToProperty relatedToProperty : relatedToPropertyList) { - if (relatedToProperty.getPropertyKey() == "service-instance.service-instance-name") { + if (("service-instance.service-instance-name").equals(relatedToProperty.getPropertyKey())) { execution.setVariable("networkServiceInstanceName", relatedToProperty.getPropertyValue()) } } } //If related to is allotted-Resource - if (relatedTo == "allotted-resource") { + if (("allotted-resource").equals(relatedTo)) { //get slice Profile Instance Id from allotted resource in list by nssi List<String> sliceProfileInstanceIdList = new ArrayList<>() List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") { + if (relationshipData.getRelationshipKey().equals("service-instance.service-instance-id")) { sliceProfileInstanceIdList.add(relationshipData.getRelationshipValue()) } } @@ -153,13 +141,13 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) if (sliceProfileServiceInstance.isPresent()) { String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() - String sNssai = sliceProfileServiceInstance.get().getSliceProfiles().getSliceProfile().get(0).getSNssai() - if(sNssai.equals(execution.getVariable("sNssai"))) { + String sNssai = sliceProfileServiceInstance.get().getEnvironmentContext() + String sNssaiValueFromRequest = execution.getVariable("sNssai") + if(sNssai.equals(sNssaiValueFromRequest)) { orchestrationStatus = execution.getVariable("oStatus") //Slice Profile Service Instance to be updated in AAI - execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance) + execution.setVariable("sliceProfileServiceInstance", sliceProfileServiceInstance.get()) } - Map<String, Object> spiWithsNssaiAndOrchStatus = new LinkedHashMap<>() spiWithsNssaiAndOrchStatus.put("snssai", sNssai) spiWithsNssaiAndOrchStatus.put("status", orchestrationStatus) @@ -185,18 +173,13 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { Map<String, Object> nSsai= new LinkedHashMap<>() nSsai.put("sNssai", instanceParamsvalues) String supportedsNssaiJson = mapper.writeValueAsString(nSsai) - //SupportedNssai - Map<String, Object> supportedNssai= new LinkedHashMap<>() - supportedNssai.put("supportedNssai", supportedsNssaiJson) - logger.debug("**** supportedsNssaiJson**** "+supportedNssai) - logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") - return supportedNssai + logger.debug(Prefix+" **** Exit DoActivateCoreNSSI ::: prepareVnfInstanceParamsJson ****") + return supportedsNssaiJson } private void getServiceInstanceRelationships(DelegateExecution execution) { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getServiceInstanceRelationships ****") String serviceInstanceId = execution.getVariable("networkServiceInstanceId") - logger.debug("**** serviceInstanceId :: getServiceInstanceRelationships :: "+serviceInstanceId) String errorMsg = "query Network Service Instance from AAI failed" AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) @@ -207,29 +190,33 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship() for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "owning-entity") { + if (("owning-entity").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "owning-entity.owning-entity-id") { + if (("owning-entity.owning-entity-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("owningEntityId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "generic-vnf") { + } else if (("generic-vnf").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToProperty() //Get VnfId for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "generic-vnf.vnf-id") { + if (("generic-vnf.vnf-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("vnfId", relationshipData.getRelationshipValue()) - String vnfId = relationshipData.getRelationshipValue() - logger.debug("vnfId :"+vnfId) } } - } else if (relatedTo == "project") { + //Get Vnf Name Check If necessary + for (RelatedToProperty relatedToProperty : relatedToPropertyList) { + if (("generic-vnf.vnf-name").equals(relatedToProperty.getPropertyKey())) { + execution.setVariable("vnfName", relatedToProperty.getPropertyValue()) + } + } + } else if (("project").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "project.project-name") { + if (("project.project-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("projectName", relationshipData.getRelationshipValue()) } } @@ -254,34 +241,34 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { List<Relationship> relationshipList = vnf.get().getRelationshipList()?.getRelationship() for (Relationship relationship : relationshipList) { String relatedTo = relationship.getRelatedTo() - if (relatedTo == "tenant") { + if (("tenant").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "tenant.tenant-id") { + if (("tenant.tenant-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("tenantId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "cloud-region") { + } else if (("cloud-region").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "cloud-region.cloud-owner") { + if (("cloud-region.cloud-owner").equals(relationshipData.getRelationshipKey())) { execution.setVariable("cloudOwner", relationshipData.getRelationshipValue()) - } else if (relationshipData.getRelationshipKey() == "cloud-region.cloud-region-id") { + } else if (("cloud-region.cloud-region-id").equals(relationshipData.getRelationshipKey())) { execution.setVariable("lcpCloudRegionId", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "platform") { + } else if (("platform").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "platform.platform-name") { + if (("platform.platform-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("platformName", relationshipData.getRelationshipValue()) } } - } else if (relatedTo == "line-of-business") { + } else if (("line-of-business").equals(relatedTo)) { List<RelationshipData> relationshipDataList = relationship.getRelationshipData() for (RelationshipData relationshipData : relationshipDataList) { - if (relationshipData.getRelationshipKey() == "line-of-business.line-of-business-name") { + if (("line-of-business.line-of-business-name").equals(relationshipData.getRelationshipKey())) { execution.setVariable("lineOfBusinessName", relationshipData.getRelationshipValue()) } } @@ -334,11 +321,9 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String serviceVnfs = jsonUtil.getJsonValue(json, "serviceResources.serviceVnfs") ?: "" String serviceModelInfo = jsonUtil.getJsonValue(json, "serviceResources.modelInfo") ?: "" - - execution.setVariable("serviceVnfs",serviceVnfs) execution.setVariable("serviceModelInfo", serviceModelInfo) - logger.debug(Prefix +" ***** serviceVnfs is: "+ serviceVnfs) + logger.debug(Prefix +" ***** serviceVnfs : "+ serviceVnfs) }catch(BpmnError e){ throw e } catch (Exception ex){ @@ -352,9 +337,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { public void prepareSOMacroRequestPayLoad(DelegateExecution execution) { logger.debug("**** Enter DoActivateCoreNSSI ::: prepareSOMacroRequestPayLoad ****") String json = execution.getVariable("serviceVnfs") - logger.debug(">>>> json "+json) List<Object> vnfList = mapper.readValue(json, List.class); - logger.debug("vnfList: "+vnfList) Map<String,Object> serviceMap = mapper.readValue(execution.getVariable("serviceModelInfo"), Map.class); ModelInfo serviceModelInfo = new ModelInfo() serviceModelInfo.setModelType(ModelType.service) @@ -362,18 +345,12 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { serviceModelInfo.setModelVersionId(serviceMap.get("modelUuid")) serviceModelInfo.setModelName(serviceMap.get("modelName")) serviceModelInfo.setModelVersion(serviceMap.get("modelVersion")) - - logger.debug("serviceModelInfo: "+serviceModelInfo) //List of Vnfs List<Object> vnfModelInfoList = new ArrayList<>() Map vnfMap = vnfList.get(0) - ModelInfo vnfModelInfo = vnfMap.get("modelInfo") - logger.debug("vnfModelInfo "+vnfModelInfo) - //List of VFModules List<Map<String, Object>> vfModuleList = vnfMap.get("vfModules") - logger.debug("vfModuleList "+vfModuleList) //List of VfModules List<ModelInfo> vfModelInfoList = new ArrayList<>() @@ -381,17 +358,19 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { //Traverse VFModules List and add in vfModelInfoList for (vfModule in vfModuleList) { ModelInfo vfModelInfo = vfModule.get("modelInfo") - logger.debug("vfModelInfo "+vfModelInfo) + vfModelInfo.setModelCustomizationId(vfModelInfo.getModelCustomizationUuid()) + vfModelInfo.setModelVersionId(vfModelInfo.getModelId()) vfModelInfoList.add(vfModelInfo) } + String networkServiceInstanceName = execution.getVariable("networkServiceInstanceName") //RequestInfo RequestInfo requestInfo = new RequestInfo() //Dummy Product FamilyId requestInfo.setProductFamilyId("test1234") requestInfo.setSource("VID") - requestInfo.setInstanceName(execution.getVariable("networkServiceInstanceName")) + requestInfo.setInstanceName(networkServiceInstanceName) requestInfo.setSuppressRollback(false) requestInfo.setRequestorId("NBI") @@ -401,10 +380,13 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { serviceParams.add(serviceParamsValues) //Cloud Configuration + String lcpCloudRegionId = execution.getVariable("lcpCloudRegionId") + String tenantId = execution.getVariable("tenantId") + String cloudOwner = execution.getVariable("cloudOwner") CloudConfiguration cloudConfiguration = new CloudConfiguration() - cloudConfiguration.setLcpCloudRegionId(execution.getVariable("lcpCloudRegionId")) - cloudConfiguration.setTenantId(execution.getVariable("tenantId")) - cloudConfiguration.setCloudOwner(execution.getVariable("cloudOwner")) + cloudConfiguration.setLcpCloudRegionId(lcpCloudRegionId) + cloudConfiguration.setTenantId(tenantId) + cloudConfiguration.setCloudOwner(cloudOwner) //VFModules List List<Map<String, Object>> vfModules = new ArrayList<>() @@ -412,26 +394,33 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { //Individual VFModule List Map<String, Object> vfModuleValues = new LinkedHashMap<>() vfModuleValues.put("modelInfo", vfModuleModelInfo) - vfModuleValues.put("instanceName", vfModuleModelInfo.getModelInstanceName()) + vfModuleValues.put("instanceName", vfModuleModelInfo.getModelName()) //VFModule InstanceParams should be empty or this field should not be there? List<Map<String, Object>> vfModuleInstanceParams = new ArrayList<>() vfModuleValues.put("instanceParams", vfModuleInstanceParams) + vfModules.add(vfModuleValues) } //Vnf intsanceParams - ObjectMapper objectMapper = new ObjectMapper(); - Map<String, Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class); - - List vnfInstanceParamsList = new ArrayList<>() + List<Map<String, Object>> vnfInstanceParamsList = new ArrayList<>() String supportedsNssaiJson= prepareVnfInstanceParamsJson(execution) - vnfInstanceParamsList.add(supportedsNssaiJson) + + Map<String, Object> supportedNssai= new LinkedHashMap<>() + supportedNssai.put("supportedsNssai", supportedsNssaiJson) + vnfInstanceParamsList.add(supportedNssai) Platform platform = new Platform() - platform.setPlatformName(execution.getVariable("platform")) + String platformName = execution.getVariable("platformName") + platform.setPlatformName(platformName) LineOfBusiness lineOfbusiness = new LineOfBusiness() - lineOfbusiness.setLineOfBusinessName(execution.getVariable("lineOfBusiness")) + String lineOfBusinessName = execution.getVariable("lineOfBusinessName") + lineOfbusiness.setLineOfBusinessName(lineOfBusinessName) + + ModelInfo vnfModelInfo = vnfMap.get("modelInfo") + vnfModelInfo.setModelCustomizationId(vnfModelInfo.getModelCustomizationUuid()) + vnfModelInfo.setModelVersionId(vnfModelInfo.getModelId()) //Vnf Values Map<String, Object> vnfValues = new LinkedHashMap<>() @@ -441,7 +430,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { vnfValues.put("cloudConfiguration", cloudConfiguration) vnfValues.put("vfModules", vfModules) vnfValues.put("modelInfo", vnfModelInfo) - vnfValues.put("instanceName", execution.getVariable("vnfInstanceName")) + vnfValues.put("instanceName", vnfModelInfo.getModelInstanceName()) vnfValues.put("instanceParams",vnfInstanceParamsList) vnfModelInfoList.add(vnfValues) @@ -450,9 +439,10 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { serviceResources.put("vnfs", vnfModelInfoList) //Service Values + String serviceInstanceName = execution.getVariable("networkServiceInstanceName") Map<String, Object> serviceValues = new LinkedHashMap<>() serviceValues.put("modelInfo", serviceModelInfo) - serviceValues.put("instanceName", execution.getVariable("networkServiceInstanceName")) + serviceValues.put("instanceName", serviceInstanceName) serviceValues.put("resources", serviceResources) serviceValues.put("instanceParams", serviceParams) @@ -470,22 +460,26 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { userParams.add(userParamsValues) //Request Parameters + String serviceType = execution.getVariable("serviceType") RequestParameters requestParameters = new RequestParameters() requestParameters.setaLaCarte(false) - requestParameters.setSubscriptionServiceType(execution.getVariable("serviceType")) + requestParameters.setSubscriptionServiceType(serviceType) requestParameters.setUserParams(userParams) //SubscriberInfo + String globalSubscriberId = execution.getVariable("globalSubscriberId") SubscriberInfo subscriberInfo = new SubscriberInfo() - subscriberInfo.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + subscriberInfo.setGlobalSubscriberId(globalSubscriberId) //Owning Entity + String owningEntityId = execution.getVariable("owningEntityId") OwningEntity owningEntity = new OwningEntity() - owningEntity.setOwningEntityId(execution.getVariable("owningEntityId")) + owningEntity.setOwningEntityId(owningEntityId) //Project + String projectName = execution.getVariable("projectName") Project project = new Project() - project.setProjectName(execution.getVariable("projectName")) + project.setProjectName(projectName) RequestDetails requestDetails = new RequestDetails() requestDetails.setModelInfo(serviceModelInfo) @@ -498,8 +492,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { Map<String, Object> requestDetailsMap = new LinkedHashMap<>() requestDetailsMap.put("requestDetails", requestDetails) - String requestPayload = objectMapper.writeValueAsString(requestDetailsMap) - + String requestPayload = mapper.writeValueAsString(requestDetailsMap) logger.debug("requestDetails "+requestPayload) execution.setVariable("requestPayload", requestPayload) @@ -511,23 +504,23 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: sendPutRequestToSOMacro ****") try { String msoEndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) - String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+execution.getVariable("networkServiceInstanceId")+"/vnfs/"+execution.getVariable("vnfId") + String networkServiceInstanceId = execution.getVariable("networkServiceInstanceId") + String vnfId = execution.getVariable("vnfId") + String url = msoEndpoint+"/serviceInstantiation/v7/serviceInstances/"+networkServiceInstanceId+"/vnfs/"+vnfId String requestBody = execution.getVariable("requestPayload") String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) - String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) - String basicAuthValue = utils.encrypt(basicAuth, msoKey) - String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) - + String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + String encodeString = utils.getBasicAuth(basicAuth, msoKey) + logger.debug("msoEndpoint: "+msoEndpoint +" "+ "url: "+url +" requestBody: "+requestBody +" "+ "encodeString: "+encodeString) HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", encodeString) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.put(requestBody) handleSOResponse(httpResponse, execution) - } catch (BpmnError e) { throw e } catch (any) { - String msg = "Exception in DoActivateCoreNSSSI " + any.getCause() + String msg = Prefix+" Exception in DoActivateCoreNSSI " + any.getCause() logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -546,15 +539,15 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { String soResponse = httpResponse.readEntity(String.class) - String operationId = execution.getVariable("operationId") - def macroOperationId = jsonUtil.getJsonValue(soResponse, "operationId") + logger.debug("soResponse: "+soResponse) + String macroOperationId = jsonUtil.getJsonValue(soResponse, "requestReferences.requestId") + String requestSelfLink = jsonUtil.getJsonValue(soResponse, "requestReferences.requestSelfLink") execution.setVariable("macroOperationId", macroOperationId) + execution.setVariable("requestSelfLink", requestSelfLink) execution.setVariable("isSOTimeOut", "no") execution.setVariable("isSOResponseSucceed","yes") } - else - { - String serviceName = execution.getVariable("serviceInstanceName") + else { execution.setVariable("isSOResponseSucceed","no") prepareFailedOperationStatusUpdate(execution) } @@ -562,37 +555,58 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: handleSOResponse ****") } - /** - * prepare to call sub process CheckProcessStatus - * @param execution - */ - void prepareCallCheckProcessStatus(DelegateExecution execution){ - logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") - def successConditions = new ArrayList<>() - successConditions.add("finished") - execution.setVariable("successConditions", successConditions) - def errorConditions = new ArrayList<>() - errorConditions.add("error") - execution.setVariable("errorConditions", errorConditions) - execution.setVariable("processServiceType", "Network service") - execution.setVariable("subOperationType", "PUT") - execution.setVariable("initProgress", 20) - execution.setVariable("endProgress",90) - execution.setVariable("timeOut", TIMEOUT) - logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareCallCheckProcessStatus ****") + public void getSOPUTProgress(DelegateExecution execution) { + logger.debug(Prefix+ " **** Enter DoActivateCoreNSSI ::: getSOPUTProgress ****") + String url= execution.getVariable("requestSelfLink") + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + String encodeString = utils.getBasicAuth(basicAuth, msoKey) + httpClient.addAdditionalHeader("Authorization", encodeString) + httpClient.addAdditionalHeader("Accept", "application/json") + Response httpResponse = httpClient.get() + logger.debug("httpResponse "+httpResponse) + int soResponseCode = httpResponse.getStatus() + logger.debug("soResponseCode : "+soResponseCode) + if (soResponseCode >= 200 && soResponseCode < 204 && httpResponse.hasEntity()) { + String soResponse = httpResponse.readEntity(String.class) + logger.debug("soResponse: "+soResponse) + String requestState= jsonUtil.getJsonValue(soResponse, "request.requestStatus.requestState") + logger.debug("requestState: "+requestState) + execution.setVariable("requestState", requestState) + } else { + execution.setVariable("isSOResponseSucceed","no") + prepareFailedOperationStatusUpdate(execution) + } + logger.debug(Prefix+ " **** Exit DoActivateCoreNSSI ::: getSOPUTProgress ****") } + public void timeDelay() { + try { + logger.debug(Prefix+ " **** DoActivateCoreNSSI ::: timeDelay going to sleep for 5 sec") + Thread.sleep(5000) + logger.debug("**** DoActivateCoreNSSI ::: timeDelay wakeup after 5 sec") + } catch(InterruptedException e) { + logger.error(Prefix+ " **** DoActivateCoreNSSI ::: timeDelay exception" + e) + } + } + void prepareUpdateResourceOperationStatus(DelegateExecution execution) { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") - String nssiOperationId = execution.getVariable("nssiOperationId") - execution.setVariable("operationId", nssiOperationId) + String soRequestState = execution.getVariable("requestState") //Prepare Update Status for PUT failure and success - if(execution.getVariable("isTimeOut").equals("YES")) { - logger.debug("TIMEOUT - SO PUT Failure") + if("COMPLETE".equalsIgnoreCase(soRequestState)) { + execution.setVariable("progress", "100") + execution.setVariable("status", "finished") + execution.setVariable("operationContent", "AllocteCoreNSSI successful.") + logger.debug("Success ,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}") + } else { + logger.debug("SO PUT Failure with State: "+soRequestState) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "SO PUT Failure") } + setResourceOperationStatus(execution) logger.debug(Prefix +" **** Exit DoActivateCoreNSSI ::: prepareUpdateResourceOperationStatus ****") } @@ -610,14 +624,8 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstanceId)) try { - - Response response = getAAIClient().update(uri, si) - - if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) { - exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI failed to update sliceProlie service Instance orchestration status") - } else { - setResourceOperationStatus(execution) - } + getAAIClient().update(uri, si) + setResourceOperationStatus(execution) } catch (Exception e) { logger.info("Update OrchestrationStatus in AAI failed") String msg = "Update OrchestrationStatus in AAI failed, " + e.getMessage() @@ -636,14 +644,17 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: setResourceOperationStatus ****") - String serviceId = execution.getVariable("nssiId") + String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("serviceInstanceID") + String modelUuid= execution.getVariable("modelUuid") String operationType = execution.getVariable("operationType") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setStatus("finished") resourceOperationStatus.setProgress("100") @@ -656,17 +667,20 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { void prepareFailedOperationStatusUpdate(DelegateExecution execution){ logger.debug(Prefix + " **** Enter DoActivateCoreNSSI ::: prepareFailedOperationStatusUpdate ****") - String serviceId = execution.getVariable("nssiId") + String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("serviceInstanceID") String operationType = execution.getVariable("operationType") + String modelUuid= execution.getVariable("modelUuid") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceInstanceID(nssiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) - resourceOperationStatus.setProgress(0) + resourceOperationStatus.setProgress("0") resourceOperationStatus.setStatus("failed") resourceOperationStatus.setStatusDescription("Core NSSI Activation Failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, resourceOperationStatus) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index ff7b0a3b6d..515990ac1a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -37,6 +37,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNACT_" @@ -63,7 +66,9 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -83,7 +88,13 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String actionType = operationType.equals("activateInstance") ? "activate" : "deactivate" execution.setVariable("actionType", actionType) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy index 91599700ef..a1afe9ae95 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -368,7 +368,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String nssiId = execution.getVariable("nssiServiceInstanceId") String globalCustId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("subscriptionServiceType") - logger.debug("networkServiceInstanceId: "+networkServiceInstanceId +" nssiId: "+nssiId +" globalCustId: "+globalCustId+ " serviceType: "+serviceType) + logger.debug("networkServiceInstanceId: {}, nssiId: {}, globalCustId: {}, serviceType: {}", networkServiceInstanceId, nssiId, globalCustId, serviceType) try{ //Update NSSI orchestration status nssiServiceInstance ServiceInstance si = execution.getVariable("nssiServiceInstance") @@ -424,7 +424,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId") String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo") NetworkRoute bh_ep = new NetworkRoute() - logger.debug("bh_endpoint: "+bh_endpoint +" "+ "bh_routeId: "+bh_routeId +" "+ "cnIpAddress: "+cnIpAddress +" "+ "role: "+role +" "+ "cnIpAddress: "+cnIpAddress +" "+ "LogicalLinkId: "+LogicalLinkId +" "+ "nextHopInfo: "+nextHopInfo +" "+ "bh_ep: "+bh_ep) + logger.debug("bh_endpoint: {}, bh_routeId: {}, cnIpAddress: {}, role: {}, LogicalLinkId: {}, nextHopInfo: {}, bh_ep: {}", bh_endpoint, bh_routeId, cnIpAddress, role, LogicalLinkId, nextHopInfo, bh_ep) bh_ep.setRouteId(bh_routeId) bh_ep.setFunction(function) bh_ep.setRole(role) @@ -448,7 +448,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { relationship.setRelatedLink(relatedLink) relationship.setRelatedTo("network-route") relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") - logger.debug("networkRouteUri: "+networkRouteUri+"relationship: "+relationship) + logger.debug("networkRouteUri: {}, relationship: {}",networkRouteUri,relationship) try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(coreNssi)).relationshipAPI() logger.debug("uri: "+uri) @@ -473,13 +473,14 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+ " **** Enter DoAllocateCoreNonSharedSlice ::: setResourceOperationStatus ****") String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") String nssiId = execution.getVariable("nssiServiceInstanceId") String operationType = "ALLOCATE" + String modelUuid= execution.getVariable("modelUuid") ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) + resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setStatus(execution.getVariable("status")) @@ -493,17 +494,15 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix + " **** Enter DoAllocateCoreNonSharedSlice ::: prepareFailedOperationStatusUpdate ****") String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") String nssiId = execution.getVariable("nssiServiceInstanceId") String operationType = "ALLOCATE" //modelUuid String modelUuid= execution.getVariable("modelUuid") - logger.debug("serviceId: "+serviceId +" "+ "jobId: "+jobId +" "+ "nsiId: "+nsiId +" "+ "nssiId: "+nssiId +" "+ "operationType: "+operationType) + logger.debug("serviceId: {}, jobId: {}, nssiId: {}, operationType: {}.", serviceId, jobId, nssiId, operationType) ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) - resourceOperationStatus.setResourceTemplateUUID(nsiId) resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 04f07b66d4..78c6a084ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -35,11 +35,11 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isNotBlank class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger(DoCreateTnNssiInstance.class); - final String AAI_VERSION = "v21" JsonUtils jsonUtil = new JsonUtils() TnNssmfUtils tnNssmfUtils = new TnNssmfUtils() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -63,7 +63,9 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + if (isBlank(execution.getVariable("enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.trace("Exit preProcessRequest") } @@ -110,6 +112,12 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String sliceProfileStr = execution.getVariable("sliceProfile") try { + if (sliceProfileStr == null || sliceProfileStr.isEmpty()) { + String msg = "ERROR: createServiceInstance: sliceProfile is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() ss.setServiceInstanceId(ssInstanceId) String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") @@ -125,12 +133,18 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String modelUuid = execution.getVariable("modelUuid") ss.setModelInvariantId(modelInvariantUuid) ss.setModelVersionId(modelUuid) - String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) - ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String serviceInstanceLocationId = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) + ss.setServiceInstanceLocationId(serviceInstanceLocationId) String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) //ss.setEnvironmentContext(snssai) ss.setEnvironmentContext("tn") ss.setServiceRole(serviceRole) + + String domainTypeStr = jsonUtil.getJsonValue(sliceProfileStr, "domainType") + if (isNotBlank(domainTypeStr)) { + ss.setWorkloadContext(domainTypeStr) + } + AAIResourcesClient client = getAAIClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() @@ -211,7 +225,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { if (bwStr != null && !bwStr.isEmpty()) { networkPolicy.setMaxBandwidth(Integer.parseInt(bwStr)) } else { - log.debug("ERROR: createNetworkPolicy: maxBandwidth is null") + logger.debug("ERROR: createNetworkPolicy: maxBandwidth is null") } //networkPolicy.setReliability(new Object()) @@ -249,7 +263,9 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String networkPolicyId = UUID.randomUUID().toString() createNetworkPolicy(execution, ssInstanceId, networkPolicyId) - tnNssmfUtils.attachNetworkPolicyToAllottedResource(execution, AAI_VERSION, allottedResourceUri, networkPolicyId); + tnNssmfUtils.attachNetworkPolicyToAllottedResource(execution, tnNssmfUtils.AAI_VERSION, + allottedResourceUri, + networkPolicyId); } catch (BpmnError e) { throw e @@ -280,14 +296,19 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) for (String linkStr : linkStrList) { - String logicalLinkId = UUID.randomUUID().toString() + String linkId = jsonUtil.getJsonValue(linkStr, "id") + if (isBlank(linkId)) { + linkId = "tn-nssmf-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinksForAllocatedResource: linkId=" + linkId) + String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() - resource.setLinkId(logicalLinkId) + resource.setLinkId(linkId) resource.setLinkName(epA) resource.setLinkName2(epB) resource.setLinkType("TsciConnectionLink") @@ -298,7 +319,8 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) getAAIClient().create(logicalLinkUri, resource) - tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, AAI_VERSION, allottedResourceUri, epA); + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, tnNssmfUtils.AAI_VERSION, + allottedResourceUri, epA); } } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index a715e7799d..b09161d5cd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -38,6 +38,9 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.isEmpty + class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNDEALLOC_" @@ -68,10 +71,11 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { String sliceServiceInstanceName = execution.getVariable("servicename") execution.setVariable("sliceServiceInstanceName", sliceServiceInstanceName) - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -81,7 +85,13 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - tnNssmfUtils.setEnableSdncConfig(execution) + String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr) || + isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, + additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } logger.debug("Finish preProcessRequest") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 4ff15a58c5..9440b42124 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -24,9 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.SliceProfile -import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aai.domain.yang.* import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory @@ -40,7 +38,7 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import static org.apache.commons.lang3.StringUtils.isBlank +import static org.apache.commons.lang3.StringUtils.* public class DoModifyTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNMOD_" @@ -70,8 +68,18 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { logger.debug("SDNC Callback URL: " + execution.getVariable("sdncCallbackUrl")) String additionalPropJsonStr = execution.getVariable("sliceParams") + if (isBlank(additionalPropJsonStr)) { + msg = "ERROR: additionalPropJsonStr is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } String sliceServiceInstanceId = execution.getVariable("serviceInstanceID") + if (isBlank(sliceServiceInstanceId)) { + msg = "ERROR: sliceServiceInstanceId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } execution.setVariable("sliceServiceInstanceId", sliceServiceInstanceId) String sliceServiceInstanceName = execution.getVariable("servicename") @@ -82,7 +90,10 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. + if (isEmpty(modelUuid)) { + modelUuid = tnNssmfUtils.getModelUuidFromServiceInstance(execution.getVariable("serviceInstanceID")) + } + def isDebugLogEnabled = true execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) String serviceModelInfo = """{ @@ -92,33 +103,19 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { }""" execution.setVariable("serviceModelInfo", serviceModelInfo) - //additional properties - String sliceProfile = jsonUtil.getJsonValue(additionalPropJsonStr, "sliceProfile") - if (isBlank(sliceProfile)) { - msg = "Input sliceProfile is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("sliceProfile", sliceProfile) - } + tnNssmfUtils.setExecVarFromJsonStr(execution, additionalPropJsonStr, + "sliceProfile", "sliceProfile", true) - String transportSliceNetworks = jsonUtil.getJsonValue(additionalPropJsonStr, "transportSliceNetworks") - if (isBlank(transportSliceNetworks)) { - msg = "Input transportSliceNetworks is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("transportSliceNetworks", transportSliceNetworks) - } - logger.debug("transportSliceNetworks: " + transportSliceNetworks) + tnNssmfUtils.setExecVarFromJsonStr(execution, additionalPropJsonStr, + "transportSliceNetworks", "transportSliceNetworks", true) + logger.debug("transportSliceNetworks: " + execution.getVariable("transportSliceNetworks")) - String nsiInfo = jsonUtil.getJsonValue(additionalPropJsonStr, "nsiInfo") - if (isBlank(nsiInfo)) { - msg = "Input nsiInfo is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("nsiInfo", nsiInfo) + tnNssmfUtils.setExecVarFromJsonStr(execution, additionalPropJsonStr, + "nsiInfo", "nsiInfo", true) + + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) } } catch (BpmnError e) { throw e @@ -147,27 +144,32 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { void getExistingServiceInstance(DelegateExecution execution) { - String serviceInstanceId = execution.getVariable("serviceInstanceID") + String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") AAIResourcesClient resourceClient = getAAIClient() AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) try { if (resourceClient.exists(ssServiceuri)) { - execution.setVariable("ssi_resourceLink", ssServiceuri.build().toString()) - org.onap.aai.domain.yang.ServiceInstance ss = - resourceClient.get(org.onap.aai.domain.yang.ServiceInstance.class, ssServiceuri) - org.onap.aai.domain.yang.SliceProfile sliceProfile = ss.getSliceProfiles().getSliceProfile().get(0) - execution.setVariable("sliceProfileId", sliceProfile.getProfileId()) - - org.onap.aai.domain.yang.AllottedResources ars = ss.getAllottedResources() - List<org.onap.aai.domain.yang.AllottedResource> arList = ars.getAllottedResource() + ServiceInstance ss = resourceClient.get(ServiceInstance.class, ssServiceuri) + + AllottedResources ars = ss.getAllottedResources() + List<AllottedResource> arList = ars.getAllottedResource() List<String> arIdList = new ArrayList<>() - for (org.onap.aai.domain.yang.AllottedResource ar : arList) { + Map<String, String> policyMap = new HashMap<>() + Map<String, List<String>> logicalLinksMap = new HashMap<>() + for (AllottedResource ar : arList) { String arId = ar.getId() arIdList.add(arId) + String policyId = tnNssmfUtils.getPolicyIdFromAr(execution, serviceInstanceId, arId, true) + policyMap.put(arId, policyId) + List<String> logicalLinkList = tnNssmfUtils.getLogicalLinkNamesFromAr(execution, + serviceInstanceId, arId, true) + logicalLinksMap.put(arId, logicalLinkList) } execution.setVariable("arIdList", arIdList) + execution.setVariable("arPolicyMap", policyMap) + execution.setVariable("arLogicalLinkMap", logicalLinksMap) } else { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + "associate allotted resource for service :" + serviceInstanceId) @@ -179,41 +181,26 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - } - public void updateTnNssiInAAI(DelegateExecution execution) { + void updateTnNssiInAAI(DelegateExecution execution) { getExistingServiceInstance(execution) - - updateServiceInstance(execution) - updateSliceProfile(execution) - updateAllottedResource(execution) + updateTsciNetworks(execution) } void updateServiceInstance(DelegateExecution execution) { - String serviceRole = "TN" - String serviceType = execution.getVariable("subscriptionServiceType") - String sliceProfileStr = execution.getVariable("sliceProfile") String ssInstanceId = execution.getVariable("sliceServiceInstanceId") try { - org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() - ss.setServiceInstanceId(ssInstanceId) - String sliceInstanceName = execution.getVariable("sliceServiceInstanceName") - ss.setServiceInstanceName(sliceInstanceName) - ss.setServiceType(serviceType) + ServiceInstance ss = new ServiceInstance() + //ss.setServiceInstanceId(ssInstanceId) String serviceStatus = "modified" ss.setOrchestrationStatus(serviceStatus) - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") - String modelUuid = execution.getVariable("modelUuid") - ss.setModelInvariantId(modelInvariantUuid) - ss.setModelVersionId(modelUuid) - String serviceInstanceLocationid = tnNssmfUtils.getFirstPlmnIdFromSliceProfile(sliceProfileStr) - ss.setServiceInstanceLocationId(serviceInstanceLocationid) - String snssai = tnNssmfUtils.getFirstSnssaiFromSliceProfile(sliceProfileStr) - ss.setEnvironmentContext(snssai) - ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(ssInstanceId)) client.update(uri, ss) } catch (BpmnError e) { throw e @@ -254,70 +241,180 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { } } - void updateAllottedResource(DelegateExecution execution) { - String serviceInstanceId = execution.getVariable('serviceInstanceID') - + String getValidArId(DelegateExecution execution, String arIdStr) { List<String> arIdList = execution.getVariable("arIdList") + /* + * If arId is not specified by the caller, then we assume the caller + * wants to modify the first network (i.e., allotted resource) in the TSCi tree. + */ + String arId = isBlank(arIdStr) ? arIdList.get(0) : arIdStr + + return arId + } + + void updateLogicalLinksInAr(DelegateExecution execution, String arId, String linkArrayJsonStr) { try { - for (String arId : arIdList) { - AAIResourceUri arUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(serviceInstanceId).allottedResource(arId)) + String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') + + /* + * Each TSCi connection-link in linkArrayJsonStr is considered as an "ADD" new + * link to allotted-resource. So, if the link already exists under AR, then do + * nothing. Otherwise, create logical-link. + */ + List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayJsonStr) + for (String linkStr : linkStrList) { + if (logicalLinkExists(execution, arId, linkStr)) { + continue + } - getAAIClient().delete(arUri) + createLogicalLinkForAllocatedResource(execution, linkStr, serviceInstanceId, arId) } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in updateLogicalLinksInAr" + ex.getMessage()) + } + } - List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) + void updateLogicalLinksInNetwork(DelegateExecution execution, String networkJsonStr) { + try { + String arId = getValidArId(jsonUtil.getJsonValue(networkJsonStr, "id")) + String linkArrayStr = jsonUtil.getJsonValue(networkJsonStr, "connectionLinks") + updateLogicalLinksInAr(execution, arId, linkArrayStr) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in updateLogicalLinksInNetwork" + ex.getMessage()) + } + } + void updateTsciNetworks(DelegateExecution execution) { + try { + List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) for (String networkStr : networkStrList) { - String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) - execution.setVariable("allottedResourceUri", allottedResourceUri) - String modelInvariantId = execution.getVariable("modelInvariantUuid") - String modelVersionId = execution.getVariable("modelUuid") - - org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource() - resource.setId(allottedResourceId) - resource.setType("TsciNetwork") - resource.setAllottedResourceName("network_" + execution.getVariable("sliceServiceInstanceName")) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) - getAAIClient().create(allottedResourceUri, resource) - - String linkArrayStr = jsonUtil.getJsonValue(networkStr, "connectionLinks") - createLogicalLinksForAllocatedResource(execution, linkArrayStr, serviceInstanceId, allottedResourceId) + updateLogicalLinksInNetwork(execution, networkStr) + updateNetworkPolicy(execution, networkStr) } + } catch (BpmnError e) { + throw e } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in updateTsciNetworks" + ex.getMessage()) } } - void createLogicalLinksForAllocatedResource(DelegateExecution execution, - String linkArrayStr, String serviceInstanceId, - String allottedResourceId) { + int getMaxBw(DelegateExecution execution) { + int maxBw = 0 + try { + String sliceProfileStr = execution.getVariable("sliceProfile") + if (isBlank(sliceProfileStr)) { + String msg = "ERROR: getMaxBw: sliceProfile is null" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String bwStr = jsonUtil.getJsonValue(sliceProfileStr, "maxBandwidth") + if (isNotBlank(bwStr)) { + maxBw = Integer.parseInt(bwStr) + } else { + logger.error("ERROR: getMaxBw: maxBandwidth is null") + } + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, + "Exception in getMaxBw" + ex.getMessage()) + } + + return maxBw + } + void updatePolicyMaxBandwidthInAAI(DelegateExecution execution, String policyId, int maxBw) { try { - List<String> linkStrList = jsonUtil.StringArrayToList(linkArrayStr) + NetworkPolicy networkPolicy = new NetworkPolicy() + networkPolicy.setMaxBandwidth(maxBw) + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(policyId)) + getAAIClient().update(networkPolicyUri, networkPolicy) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateTnNssiInstance.createServiceInstance. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } - for (String linkStr : linkStrList) { - String logicalLinkId = UUID.randomUUID().toString() - String epA = jsonUtil.getJsonValue(linkStr, "transportEndpointA") - String epB = jsonUtil.getJsonValue(linkStr, "transportEndpointB") - String modelInvariantId = execution.getVariable("modelInvariantUuid") - String modelVersionId = execution.getVariable("modelUuid") - - org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() - resource.setLinkId(logicalLinkId) - resource.setLinkName(epA) - resource.setLinkName2(epB) - resource.setModelInvariantId(modelInvariantId) - resource.setModelVersionId(modelVersionId) - - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) - getAAIClient().create(logicalLinkUri, resource) + void updateNetworkPolicy(DelegateExecution execution, String networkJsonStr) { + try { + int maxBw = getMaxBw(execution) + + String arId = getValidArId(jsonUtil.getJsonValue(networkJsonStr, "id")) + Map<String, String> policyMap = execution.getVariable("arPolicyMap") + String policyId = policyMap.get(arId) + if (isBlank(policyId)) { + String msg = String.format("ERROR: updateNetworkPolicy: policyId not found. arId=%s", arId) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } + + updatePolicyMaxBandwidthInAAI(execution, policyId, maxBw) + + } catch (BpmnError e) { + throw e } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, - "Exception in createLogicalLinksForAllocatedResource" + ex.getMessage()) + "Exception in updateNetworkPolicy" + ex.getMessage()) + } + } + + + void createLogicalLinkForAllocatedResource(DelegateExecution execution, + String linkJsonStr, String ssInstanceId, + String allottedResourceId) { + try { + AAIResourceUri allottedResourceUri = tnNssmfUtils.buildAllottedResourceUri(execution, + ssInstanceId, allottedResourceId) + + if (!getAAIClient().exists(allottedResourceUri)) { + logger.info("ERROR: createLogicalLinksForAllocatedResource: allottedResource not exist: uri={}", + allottedResourceUri) + return + } + + String linkId = jsonUtil.getJsonValue(linkJsonStr, "id") + if (isBlank(linkId)) { + linkId = "tn-nssmf-" + UUID.randomUUID().toString() + } + logger.debug("createLogicalLinkForAllocatedResource: linkId=" + linkId) + + String epA = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointA") + String epB = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointB") + String modelInvariantId = execution.getVariable("modelInvariantUuid") + String modelVersionId = execution.getVariable("modelUuid") + + org.onap.aai.domain.yang.LogicalLink resource = new org.onap.aai.domain.yang.LogicalLink() + resource.setLinkId(linkId) + resource.setLinkName(epA) + resource.setLinkName2(epB) + resource.setLinkType("TsciConnectionLink") + resource.setInMaint(false) + + //epA is link-name + AAIResourceUri logicalLinkUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(epA)) + getAAIClient().create(logicalLinkUri, resource) + + tnNssmfUtils.attachLogicalLinkToAllottedResource(execution, tnNssmfUtils.AAI_VERSION, + allottedResourceUri, epA); + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateTnNssiInstance.createLogicalLinksForAllocatedResource: " + ex.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } @@ -329,13 +426,15 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { logger.trace('Entered ' + method) try { - String serviceInstanceId = execution.getVariable("serviceInstanceID") + String serviceInstanceId = execution.getVariable("sliceServiceInstanceId") String sdncRequest = tnNssmfUtils.buildSDNCRequest(execution, serviceInstanceId, "modify") execution.setVariable("TNNSSMF_SDNCRequest", sdncRequest) logger.debug("Outgoing SDNCRequest is: \n" + sdncRequest) + } catch (BpmnError e) { + throw e } catch (Exception e) { logger.debug("Exception Occured Processing preprocessSdncModifyTnNssiRequest. Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) @@ -375,20 +474,47 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("serviceInstanceID") + String ssInstanceId = execution.getVariable("sliceServiceInstanceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") + String operType = "MODIFY" + + ResourceOperationStatus roStatus = tnNssmfUtils.buildRoStatus(modelUuid, ssInstanceId, + jobId, nsiId, operType, status, progress, statusDescription) - ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) - roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) - roStatus.setOperType("Modify") - roStatus.setProgress(progress) - roStatus.setStatus(status) - roStatus.setStatusDescription(statusDescription) requestDBUtil.prepareUpdateResourceOperationStatus(execution, roStatus) } + boolean logicalLinkExists(DelegateExecution execution, String arIdStr, String linkJsonStr) { + if (isBlank(arIdStr)) { + logger.error("ERROR: logicalLinkExists: arIdStr is empty") + return false + } + if (isBlank(linkJsonStr)) { + logger.error("ERROR: logicalLinkExists: linkJsonStr is empty") + return false + } + + Map<String, List<String>> logicalLinksMap = execution.getVariable("arLogicalLinkMap") + if (logicalLinksMap == null) { + logger.error("ERROR: logicalLinkExists: logicalLinksMap is null") + return false + } + + List<String> logicalLinkNameList = logicalLinksMap.get(arIdStr) + if (logicalLinksMap == null) { + logger.error("ERROR: logicalLinkExists: logicalLinkNameList is null. arIdStr=" + arIdStr) + return false + } + + String linkName = jsonUtil.getJsonValue(linkJsonStr, "transportEndpointA") + if (isBlank(linkName)) { + logger.error("ERROR: logicalLinkExists: epA is empty") + return false + } + + return logicalLinkNameList.contains(linkName) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index deeec94b74..019e836514 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -116,10 +116,10 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { execution.setVariable("nsiInfo", nsiInfoStr) } - //nsiId is passed in from caller bpmn - //String nsiIdStr = jsonUtil.getJsonValue(nsiInfo, "nsiId") - //execution.setVariable("nsiId", nsiIdStr) - + if (isBlank(tnNssmfUtils.setExecVarFromJsonIfExists(execution, additionalPropJsonStr, + "enableSdnc", "enableSdnc"))) { + tnNssmfUtils.setEnableSdncConfig(execution) + } } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy index 009b0a1941..4624cdafe9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnNssmfUtils.groovy @@ -22,9 +22,17 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.LogicalLink +import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.Activities import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -39,6 +47,7 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class TnNssmfUtils { + static final String AAI_VERSION = "v23" private static final Logger logger = LoggerFactory.getLogger(TnNssmfUtils.class); @@ -368,4 +377,173 @@ class TnNssmfUtils { execution.setVariable("enableSdnc", enableSdnc) } -} + + String setExecVarFromJsonIfExists(DelegateExecution execution, + String jsonStr, String jsonKey, String varName) { + return setExecVarFromJsonStr(execution, jsonStr, jsonKey, varName, false) + } + + String setExecVarFromJsonStr(DelegateExecution execution, + String jsonStr, String jsonKey, String varName, + boolean exceptionOnErr) { + String msg = "" + String valueStr = jsonUtil.getJsonValue(jsonStr, jsonKey) + if (isBlank(valueStr)) { + if (exceptionOnErr) { + msg = "cannot find " + jsonKey + " in " + jsonStr + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } else { + execution.setVariable(varName, valueStr) + } + + return valueStr + } + + ServiceInstance getServiceInstanceFromAai(String serviceInstanceId) { + if (isBlank(serviceInstanceId)) { + logger.error("ERROR: getServiceInstanceFromAai: serviceInstanceId is blank") + return null + } + + ServiceInstance nssi = null + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.Types.SERVICE_INSTANCE + .getFragment(serviceInstanceId)) + Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, uri) + + if (nssiOpt.isPresent()) { + nssi = nssiOpt.get() + return nssi + } else { + String msg = String.format("ERROR: getServiceInstanceFromAai: NSSI %s not found in AAI", serviceInstanceId) + logger.error(msg) + } + + return nssi; + } + + String getModelUuidFromServiceInstance(String serviceInstanceId) { + ServiceInstance si = getServiceInstanceFromAai(serviceInstanceId) + if (si == null) { + String msg = String.format("ERROR: getModelUuidFromServiceInstance: getServiceInstanceFromAai() failed. " + + "serviceInstanceId=%s", serviceInstanceId) + logger.error(msg) + return null + } + + return si.modelVersionId() + } + + AAIResourceUri buildNetworkPolicyUri(String networkPolicyId) { + AAIResourceUri networkPolicyUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) + + return networkPolicyUri + } + + AAIResourceUri buildAllottedResourceUri(DelegateExecution execution, String serviceInstanceId, + String allottedResourceId) { + + AAIResourceUri allottedResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(serviceInstanceId) + .allottedResource(allottedResourceId)) + + return allottedResourceUri + } + + + String getPolicyIdFromAr(DelegateExecution execution, String serviceInstanceId, + String arId, boolean exceptionOnErr) { + String res + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId) + List<AAIResourceUri> logicalLinkUriList = getRelationshipUriListInAai(execution, arUri, + AAIFluentTypeBuilder.Types.NETWORK_POLICY, exceptionOnErr) + for (AAIResourceUri logicalLinkUri : logicalLinkUriList) { + Optional<NetworkPolicy> policyOpt = client.get(NetworkPolicy.class, logicalLinkUri) + if (policyOpt.isPresent()) { + NetworkPolicy policy = policyOpt.get() + return policy.getNetworkPolicyId() + } else { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: logicalLinkUri=%s", logicalLinkUri) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } + + + List<AAIResourceUri> getRelationshipUriListInAai(DelegateExecution execution, + AAIResourceUri uri, Activities.Info info, + boolean exceptionOnErr) { + AAIResourcesClient client = new AAIResourcesClient() + AAIResultWrapper wrapper = client.get(uri); + Optional<Relationships> relationships = wrapper.getRelationships() + if (relationships.isPresent()) { + return relationships.get().getRelatedUris(info) + } else { + if (exceptionOnErr) { + String msg = "ERROR: getRelationshipUriListInAai: No relationship found" + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return null + } + + List<String> getLogicalLinkNamesFromAr(DelegateExecution execution, String serviceInstanceId, + String arId, boolean exceptionOnErr) { + List<String> res = new ArrayList<>() + try { + AAIResourcesClient client = new AAIResourcesClient() + + AAIResourceUri arUri = buildAllottedResourceUri(execution, serviceInstanceId, arId) + List<AAIResourceUri> logicalLinkUriList = getRelationshipUriListInAai(execution, arUri, + AAIFluentTypeBuilder.Types.LOGICAL_LINK, exceptionOnErr) + for (AAIResourceUri logicalLinkUri : logicalLinkUriList) { + Optional<LogicalLink> logicalLinkOpt = client.get(LogicalLink.class, logicalLinkUri) + if (logicalLinkOpt.isPresent()) { + LogicalLink logicalLink = logicalLinkOpt.get() + res.add(logicalLink.getLinkName()) + } else { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: logicalLinkUri=%s", logicalLinkUri) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + if (exceptionOnErr) { + throw e; + } + } catch (Exception ex) { + if (exceptionOnErr) { + String msg = String.format("ERROR: getLogicalLinkNamesFromAr: %s", ex.getMessage()) + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + return res + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy index 69780939ef..e4c6fe5f60 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -184,10 +184,9 @@ class DoActivateCoreNSSITest extends MsoGroovyTest { when(mockExecution.getVariable("snssaiAndOrchStatusList")).thenReturn(snssaiList) String returnedJsonAsString= doActivate.prepareVnfInstanceParamsJson(mockExecution) - - String expectedJsonAsString = """{supportedNssai={"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}}""" + String expectedJsonAsString = """{"sNssai":[{"snssai":"01-5C83F071","status":"activated"},{"snssai":"01-5B179BD4","status":"activated"}]}""" assertEquals(expectedJsonAsString, returnedJsonAsString) - } + } String mockQueryNS() { diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn index 2301b47639..841a23b3eb 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateAccessNSSI.bpmn @@ -284,7 +284,7 @@ String jobId = execution.getVariable("TN_FH_jobId") String networkType="tn" String nssiid=execution.getVariable("tnFhNssiId") -def def activator = new DoActivateAccessNSSI() +def activator = new DoActivateAccessNSSI() activator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_03hbxfi" name="QueryJobStatus" calledElement="QueryJobStatus"> @@ -385,7 +385,7 @@ String jobId = execution.getVariable("TN_MH_jobId") String networkType="tn" String nssiid=execution.getVariable("tnMhNssiId") -def def activator = new DoActivateAccessNSSI() +def activator = new DoActivateAccessNSSI() activator.prepareQueryJobStatus(execution, jobId,networkType, nssiid)</bpmn:script> </bpmn:scriptTask> <bpmn:callActivity id="Activity_09jt4b0" name="QueryJobStatus" calledElement="QueryJobStatus"> @@ -466,13 +466,13 @@ activator.prepareUpdateJobStatus(execution,"processing","80","TN MH NSSI activat def activator = new DoActivateAccessNSSI() activator.updateTNFHStatus(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="Activity_0xmezab" name="Update TN FH SP and NSSI Orch Status" scriptFormat="groovy"> + <bpmn:scriptTask id="Activity_0xmezab" name="Update TN MH SP and NSSI Orch Status" scriptFormat="groovy"> <bpmn:incoming>Flow_1i4cc7e</bpmn:incoming> <bpmn:outgoing>Flow_0k5cyz7</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def activator = new DoActivateAccessNSSI() -activator.updateTNFHStatus(execution)</bpmn:script> +activator.updateTNMHStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0k5cyz7" sourceRef="Activity_0xmezab" targetRef="Activity_0ftm8b6" /> <bpmn:scriptTask id="Activity_1j0xkqc" name="Check Orch status for AN NSSI activation" scriptFormat="groovy"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn index b422545e84..9ce25ed174 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoActivateCoreNSSI.bpmn @@ -4,7 +4,7 @@ <bpmn:startEvent id="StartEvent_0lgslwq" name="Start"> <bpmn:outgoing>SequenceFlow_0wwo1lh</bpmn:outgoing> </bpmn:startEvent> - <bpmn:scriptTask id="ScriptTask_1x13jc1" name="Pre-process  request Check operationType" scriptFormat="groovy"> + <bpmn:scriptTask id="ScriptTask_1x13jc1" name="Pre-process  request Check operationType" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0wwo1lh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_139ejmn</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* @@ -25,8 +25,8 @@ activateNssi.getServiceVNFAndVFsFromCatalogDB(execution)</bpmn:script> def activateNssi = new DoActivateCoreNSSI() activateNssi.prepareSOMacroRequestPayLoad(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_0lxbaxd" name="Call AAI update sliceProlie service Instance status" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1e20i9g</bpmn:incoming> + <bpmn:scriptTask id="ScriptTask_0lxbaxd" name="Call AAI update sliceProlie service Instance status" scriptFormat="groovy"> + <bpmn:incoming>Flow_09eevay</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0j0egoi</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def activateNssi = new DoActivateCoreNSSI() @@ -46,38 +46,9 @@ activateNssi.getNetworkInstanceWithSPInstanceAssociatedWithNssiId(execution)</bp def activateNssi = new DoActivateCoreNSSI() activateNssi.sendPutRequestToSOMacro(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_1frasll" name="Prepare Call CheckServiceProcessStatus" scriptFormat="groovy"> - <bpmn:incoming>Flow_039sx2v</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_18x9gdi</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def activateNssi = new DoActivateCoreNSSI() -activateNssi.prepareCallCheckProcessStatus(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:callActivity id="CallActivity_11hntoj" name="CallCheckServiceProcessStatus" calledElement="CheckServiceProcessStatus"> - <bpmn:extensionElements> - <camunda:in source="networkServiceInstanceId" target="serviceInstanceId" /> - <camunda:in source="macroOperationId" target="operationId" /> - <camunda:in source="successConditions" target="successConditions" /> - <camunda:in source="errorConditions" target="errorConditions" /> - <camunda:in source="processServiceType" target="processServiceType" /> - <camunda:in source="timeOut" target="timeOut" /> - <camunda:out source="operationStatus" target="result" /> - <camunda:out source="operationContent" target="reason" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="isTimeOut" target="isTimeOut" /> - <camunda:in source="subOperationType" target="operationType" /> - <camunda:in source="initProgress" target="initProgress" /> - <camunda:in source="endProgress" target="endProgress" /> - <camunda:in source="serviceInstanceID" target="parentServiceInstanceId" /> - <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> - <camunda:in source="operationId" target="parentOperationId" /> - </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_18x9gdi</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1l9ry0a</bpmn:outgoing> - </bpmn:callActivity> - <bpmn:scriptTask id="ScriptTask_1sfn88d" name="Prepare update Service operation status " scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1l9ry0a</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0wx21io</bpmn:outgoing> + <bpmn:scriptTask id="ScriptTask_1sfn88d" name="Prepare update Service operation status " scriptFormat="groovy"> + <bpmn:incoming>Flow_1a7o8s7</bpmn:incoming> + <bpmn:outgoing>Flow_09eevay</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def activateNssi = new DoActivateCoreNSSI() activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> @@ -86,7 +57,6 @@ activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_139ejmn" sourceRef="ScriptTask_1x13jc1" targetRef="ScriptTask_1rjha8r" /> <bpmn:sequenceFlow id="SequenceFlow_1654pt0" sourceRef="ScriptTask_1rjha8r" targetRef="ScriptTask_0usuysi" /> <bpmn:sequenceFlow id="SequenceFlow_09nihof" sourceRef="ScriptTask_0usuysi" targetRef="ScriptTask_1t06mlw" /> - <bpmn:sequenceFlow id="SequenceFlow_1l9ry0a" sourceRef="CallActivity_11hntoj" targetRef="ScriptTask_1sfn88d" /> <bpmn:sequenceFlow id="SequenceFlow_0fbr356" sourceRef="ScriptTask_1t06mlw" targetRef="IntermediateThrowEvent_0gueutz" /> <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0gueutz" name="Call SO macro api"> <bpmn:incoming>SequenceFlow_0fbr356</bpmn:incoming> @@ -98,25 +68,15 @@ activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> <bpmn:linkEventDefinition name="CallSO" /> </bpmn:intermediateCatchEvent> <bpmn:sequenceFlow id="SequenceFlow_0rjd7tg" sourceRef="ScriptTask_1tfpgcs" targetRef="Gateway_03lo8jx" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_02nqn2k" name="is TimeOut?" default="SequenceFlow_07u1gfw"> - <bpmn:incoming>SequenceFlow_0wx21io</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1e20i9g</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_07u1gfw</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0wx21io" sourceRef="ScriptTask_1sfn88d" targetRef="ExclusiveGateway_02nqn2k" /> - <bpmn:sequenceFlow id="SequenceFlow_1e20i9g" name="No" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ScriptTask_0lxbaxd"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isTimeOut") == "NO")}</bpmn:conditionExpression> - </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_1061mty" name="End"> <bpmn:incoming>SequenceFlow_0v0dntm</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_18x9gdi" sourceRef="ScriptTask_1frasll" targetRef="CallActivity_11hntoj" /> <bpmn:exclusiveGateway id="Gateway_03lo8jx" name="is SO Response OK?" default="Flow_1jchhgj"> <bpmn:incoming>SequenceFlow_0rjd7tg</bpmn:incoming> <bpmn:outgoing>Flow_039sx2v</bpmn:outgoing> <bpmn:outgoing>Flow_1jchhgj</bpmn:outgoing> </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="Flow_039sx2v" name="Yes" sourceRef="Gateway_03lo8jx" targetRef="ScriptTask_1frasll"> + <bpmn:sequenceFlow id="Flow_039sx2v" name="Yes" sourceRef="Gateway_03lo8jx" targetRef="Activity_14jev2r"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSOResponseSucceed" ) == "yes")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="ServiceTask_02x7eqy" name="Update Service Operation Status"> @@ -130,7 +90,7 @@ activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> </camunda:map> </camunda:inputParameter> - <camunda:inputParameter name="payload">${updateOperationStatus}</camunda:inputParameter> + <camunda:inputParameter name="payload">${updateResourceOperationStatus}</camunda:inputParameter> <camunda:inputParameter name="method">POST</camunda:inputParameter> <camunda:outputParameter name="NSSMF_dbResponseCode">${statusCode}</camunda:outputParameter> <camunda:outputParameter name="NSSMF_dbResponse">${response}</camunda:outputParameter> @@ -140,13 +100,11 @@ activateNssi.prepareUpdateResourceOperationStatus(execution)</bpmn:script> </bpmn:extensionElements> <bpmn:incoming>Flow_1jchhgj</bpmn:incoming> <bpmn:incoming>SequenceFlow_0j0egoi</bpmn:incoming> - <bpmn:incoming>SequenceFlow_07u1gfw</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0v0dntm</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0v0dntm" sourceRef="ServiceTask_02x7eqy" targetRef="EndEvent_1061mty" /> <bpmn:sequenceFlow id="Flow_1jchhgj" name="No" sourceRef="Gateway_03lo8jx" targetRef="ServiceTask_02x7eqy" /> <bpmn:sequenceFlow id="SequenceFlow_0j0egoi" sourceRef="ScriptTask_0lxbaxd" targetRef="ServiceTask_02x7eqy" /> - <bpmn:sequenceFlow id="SequenceFlow_07u1gfw" name="Yes" sourceRef="ExclusiveGateway_02nqn2k" targetRef="ServiceTask_02x7eqy" /> <bpmn:subProcess id="Activity_1tmdw60" name="Sub-process for FalloutHandler and Rollback" triggeredByEvent="true"> <bpmn:startEvent id="Event_159txw2"> <bpmn:outgoing>Flow_149oqyp</bpmn:outgoing> @@ -196,225 +154,236 @@ activateNssi.prepareFailedOperationStatusUpdate(execution)</bpmn:script> <bpmn:sequenceFlow id="Flow_149oqyp" sourceRef="Event_159txw2" targetRef="Activity_0u4a0ry" /> <bpmn:sequenceFlow id="Flow_1qooaff" sourceRef="Activity_0u3yna7" targetRef="Event_0c1ec2y" /> </bpmn:subProcess> + <bpmn:scriptTask id="Activity_14jev2r" name="Call Get SO PUT progress" scriptFormat="groovy"> + <bpmn:incoming>Flow_0q5mlhf</bpmn:incoming> + <bpmn:incoming>Flow_039sx2v</bpmn:incoming> + <bpmn:outgoing>Flow_1mtsx52</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.getSOPUTProgress(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="Gateway_0fdseyg" default="Flow_1a7o8s7"> + <bpmn:incoming>Flow_1mtsx52</bpmn:incoming> + <bpmn:outgoing>Flow_1ocji6k</bpmn:outgoing> + <bpmn:outgoing>Flow_1a7o8s7</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="Activity_0fbp09r" name="Time Delay 5s" scriptFormat="groovy"> + <bpmn:incoming>Flow_1ocji6k</bpmn:incoming> + <bpmn:outgoing>Flow_0q5mlhf</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def activateNssi = new DoActivateCoreNSSI() +activateNssi.timeDelay()</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="Flow_0q5mlhf" sourceRef="Activity_0fbp09r" targetRef="Activity_14jev2r" /> + <bpmn:sequenceFlow id="Flow_1ocji6k" name="requestState=IN_PROGRESS" sourceRef="Gateway_0fdseyg" targetRef="Activity_0fbp09r"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("requestState" ) == "IN_PROGRESS")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_1mtsx52" sourceRef="Activity_14jev2r" targetRef="Gateway_0fdseyg" /> + <bpmn:sequenceFlow id="Flow_1a7o8s7" sourceRef="Gateway_0fdseyg" targetRef="ScriptTask_1sfn88d" /> + <bpmn:sequenceFlow id="Flow_09eevay" sourceRef="ScriptTask_1sfn88d" targetRef="ScriptTask_0lxbaxd" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoActivateCoreNSSI"> - <bpmndi:BPMNEdge id="SequenceFlow_07u1gfw_di" bpmnElement="SequenceFlow_07u1gfw"> - <di:waypoint x="976" y="319" /> - <di:waypoint x="1123" y="319" /> + <bpmndi:BPMNEdge id="Flow_09eevay_di" bpmnElement="Flow_09eevay"> + <di:waypoint x="1020" y="319" /> + <di:waypoint x="1090" y="319" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1a7o8s7_di" bpmnElement="Flow_1a7o8s7"> + <di:waypoint x="845" y="319" /> + <di:waypoint x="920" y="319" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1mtsx52_di" bpmnElement="Flow_1mtsx52"> + <di:waypoint x="690" y="319" /> + <di:waypoint x="795" y="319" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1ocji6k_di" bpmnElement="Flow_1ocji6k"> + <di:waypoint x="820" y="344" /> + <di:waypoint x="820" y="378" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1041" y="301" width="18" height="14" /> + <dc:Bounds x="743" y="342" width="78" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_0q5mlhf_di" bpmnElement="Flow_0q5mlhf"> + <di:waypoint x="770" y="418" /> + <di:waypoint x="640" y="418" /> + <di:waypoint x="640" y="359" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0j0egoi_di" bpmnElement="SequenceFlow_0j0egoi"> - <di:waypoint x="1099" y="258" /> - <di:waypoint x="1173" y="258" /> - <di:waypoint x="1173" y="279" /> + <di:waypoint x="1190" y="319" /> + <di:waypoint x="1253" y="319" /> <bpmndi:BPMNLabel> <dc:Bounds x="376" y="387" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1jchhgj_di" bpmnElement="Flow_1jchhgj"> - <di:waypoint x="400" y="344" /> - <di:waypoint x="400" y="450" /> - <di:waypoint x="1190" y="450" /> - <di:waypoint x="1190" y="360" /> + <di:waypoint x="460" y="344" /> + <di:waypoint x="460" y="480" /> + <di:waypoint x="1320" y="480" /> + <di:waypoint x="1320" y="359" /> <bpmndi:BPMNLabel> - <dc:Bounds x="788" y="432" width="15" height="14" /> + <dc:Bounds x="883" y="462" width="15" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0v0dntm_di" bpmnElement="SequenceFlow_0v0dntm"> - <di:waypoint x="1223" y="319" /> - <di:waypoint x="1263" y="319" /> + <di:waypoint x="1353" y="319" /> + <di:waypoint x="1393" y="319" /> <bpmndi:BPMNLabel> <dc:Bounds x="483" y="448" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_039sx2v_di" bpmnElement="Flow_039sx2v"> - <di:waypoint x="425" y="319" /> - <di:waypoint x="470" y="319" /> + <di:waypoint x="485" y="319" /> + <di:waypoint x="590" y="319" /> <bpmndi:BPMNLabel> - <dc:Bounds x="439" y="301" width="18" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_18x9gdi_di" bpmnElement="SequenceFlow_18x9gdi"> - <di:waypoint x="570" y="319" /> - <di:waypoint x="610" y="319" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="-180.5" y="448" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1e20i9g_di" bpmnElement="SequenceFlow_1e20i9g"> - <di:waypoint x="951" y="294" /> - <di:waypoint x="951" y="258" /> - <di:waypoint x="999" y="258" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="959" y="273" width="15" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0wx21io_di" bpmnElement="SequenceFlow_0wx21io"> - <di:waypoint x="868" y="319" /> - <di:waypoint x="926" y="319" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="137" y="448" width="0" height="12" /> + <dc:Bounds x="532" y="301" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0rjd7tg_di" bpmnElement="SequenceFlow_0rjd7tg"> - <di:waypoint x="330" y="319" /> - <di:waypoint x="375" y="319" /> + <di:waypoint x="380" y="319" /> + <di:waypoint x="435" y="319" /> <bpmndi:BPMNLabel> <dc:Bounds x="-336" y="448" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1mi4waj_di" bpmnElement="SequenceFlow_1mi4waj"> - <di:waypoint x="178" y="319" /> - <di:waypoint x="230" y="319" /> + <di:waypoint x="218" y="319" /> + <di:waypoint x="280" y="319" /> <bpmndi:BPMNLabel> <dc:Bounds x="-489.5" y="448" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0fbr356_di" bpmnElement="SequenceFlow_0fbr356"> - <di:waypoint x="1020" y="120" /> - <di:waypoint x="1132" y="120" /> + <di:waypoint x="1150" y="120" /> + <di:waypoint x="1262" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="384" y="249" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1l9ry0a_di" bpmnElement="SequenceFlow_1l9ry0a"> - <di:waypoint x="710" y="319" /> - <di:waypoint x="768" y="319" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="-21" y="448" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09nihof_di" bpmnElement="SequenceFlow_09nihof"> - <di:waypoint x="820" y="120" /> - <di:waypoint x="920" y="120" /> + <di:waypoint x="950" y="120" /> + <di:waypoint x="1050" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-460" y="189" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1654pt0_di" bpmnElement="SequenceFlow_1654pt0"> - <di:waypoint x="610" y="120" /> - <di:waypoint x="720" y="120" /> + <di:waypoint x="740" y="120" /> + <di:waypoint x="850" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-910" y="189" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_139ejmn_di" bpmnElement="SequenceFlow_139ejmn"> - <di:waypoint x="430" y="120" /> - <di:waypoint x="510" y="120" /> + <di:waypoint x="560" y="120" /> + <di:waypoint x="640" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-381" y="245" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0wwo1lh_di" bpmnElement="SequenceFlow_0wwo1lh"> - <di:waypoint x="242" y="120" /> - <di:waypoint x="330" y="120" /> + <di:waypoint x="372" y="120" /> + <di:waypoint x="460" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-489.5" y="249" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_0lgslwq_di" bpmnElement="StartEvent_0lgslwq"> - <dc:Bounds x="206" y="102" width="36" height="36" /> + <dc:Bounds x="336" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="211" y="142" width="25" height="14" /> + <dc:Bounds x="341" y="142" width="25" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1x13jc1_di" bpmnElement="ScriptTask_1x13jc1"> - <dc:Bounds x="330" y="80" width="100" height="80" /> + <dc:Bounds x="460" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0usuysi_di" bpmnElement="ScriptTask_0usuysi"> - <dc:Bounds x="720" y="80" width="100" height="80" /> + <dc:Bounds x="850" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1t06mlw_di" bpmnElement="ScriptTask_1t06mlw"> - <dc:Bounds x="920" y="80" width="100" height="80" /> + <dc:Bounds x="1050" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0lxbaxd_di" bpmnElement="ScriptTask_0lxbaxd"> - <dc:Bounds x="999" y="218" width="100" height="80" /> + <dc:Bounds x="1090" y="279" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1rjha8r_di" bpmnElement="ScriptTask_1rjha8r"> - <dc:Bounds x="510" y="80" width="100" height="80" /> + <dc:Bounds x="640" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1tfpgcs_di" bpmnElement="ScriptTask_1tfpgcs"> - <dc:Bounds x="230" y="279" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1frasll_di" bpmnElement="ScriptTask_1frasll"> - <dc:Bounds x="470" y="279" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_11hntoj_di" bpmnElement="CallActivity_11hntoj"> - <dc:Bounds x="610" y="279" width="100" height="80" /> + <dc:Bounds x="280" y="279" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1sfn88d_di" bpmnElement="ScriptTask_1sfn88d"> - <dc:Bounds x="768" y="279" width="100" height="80" /> + <dc:Bounds x="920" y="279" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_1808y0j_di" bpmnElement="IntermediateThrowEvent_0gueutz"> - <dc:Bounds x="1132" y="102" width="36" height="36" /> + <dc:Bounds x="1262" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1106" y="142" width="90" height="14" /> + <dc:Bounds x="1236" y="142" width="90" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_11m7660_di" bpmnElement="IntermediateThrowEvent_150o0dl"> - <dc:Bounds x="142" y="301" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="115" y="341" width="90" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_02nqn2k_di" bpmnElement="ExclusiveGateway_02nqn2k" isMarkerVisible="true"> - <dc:Bounds x="926" y="294" width="50" height="50" /> + <dc:Bounds x="182" y="301" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="922" y="354" width="59" height="14" /> + <dc:Bounds x="155" y="341" width="90" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1061mty_di" bpmnElement="EndEvent_1061mty"> - <dc:Bounds x="1263" y="301" width="36" height="36" /> + <dc:Bounds x="1393" y="301" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1271" y="344" width="20" height="14" /> + <dc:Bounds x="1401" y="344" width="20" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Gateway_03lo8jx_di" bpmnElement="Gateway_03lo8jx" isMarkerVisible="true"> - <dc:Bounds x="375" y="294" width="50" height="50" /> + <dc:Bounds x="435" y="294" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="360" y="264" width="80" height="27" /> + <dc:Bounds x="420" y="256.5" width="80" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_02x7eqy_di" bpmnElement="ServiceTask_02x7eqy"> - <dc:Bounds x="1123" y="279" width="100" height="80" /> + <dc:Bounds x="1253" y="279" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1tmdw60_di" bpmnElement="Activity_1tmdw60" isExpanded="true"> - <dc:Bounds x="400" y="560" width="781" height="196" /> + <dc:Bounds x="530" y="560" width="781" height="196" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Flow_1qooaff_di" bpmnElement="Flow_1qooaff"> - <di:waypoint x="960" y="664" /> - <di:waypoint x="1068" y="664" /> + <di:waypoint x="1090" y="664" /> + <di:waypoint x="1198" y="664" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_149oqyp_di" bpmnElement="Flow_149oqyp"> - <di:waypoint x="466" y="664" /> - <di:waypoint x="530" y="664" /> + <di:waypoint x="596" y="664" /> + <di:waypoint x="660" y="664" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1dh5sht_di" bpmnElement="Flow_1dh5sht"> - <di:waypoint x="630" y="664" /> - <di:waypoint x="690" y="664" /> + <di:waypoint x="760" y="664" /> + <di:waypoint x="820" y="664" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1iqw69c_di" bpmnElement="Flow_1iqw69c"> - <di:waypoint x="790" y="664" /> - <di:waypoint x="860" y="664" /> + <di:waypoint x="920" y="664" /> + <di:waypoint x="990" y="664" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_159txw2_di" bpmnElement="Event_159txw2"> - <dc:Bounds x="430" y="646" width="36" height="36" /> + <dc:Bounds x="560" y="646" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_0c1ec2y_di" bpmnElement="Event_0c1ec2y"> - <dc:Bounds x="1068" y="646" width="36" height="36" /> + <dc:Bounds x="1198" y="646" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0u3yna7_di" bpmnElement="Activity_0u3yna7"> - <dc:Bounds x="860" y="624" width="100" height="80" /> + <dc:Bounds x="990" y="624" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0u4a0ry_di" bpmnElement="Activity_0u4a0ry"> - <dc:Bounds x="530" y="624" width="100" height="80" /> + <dc:Bounds x="660" y="624" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_11422x1_di" bpmnElement="Activity_11422x1"> - <dc:Bounds x="690" y="624" width="100" height="80" /> + <dc:Bounds x="820" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_14jev2r_di" bpmnElement="Activity_14jev2r"> + <dc:Bounds x="590" y="279" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Gateway_0fdseyg_di" bpmnElement="Gateway_0fdseyg" isMarkerVisible="true"> + <dc:Bounds x="795" y="294" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_0fbp09r_di" bpmnElement="Activity_0fbp09r"> + <dc:Bounds x="770" y="378" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn index 124b75cbe8..82efc97e92 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateTransportNSSI.bpmn @@ -131,6 +131,7 @@ css.prepareOofSelection(execution)</bpmn:script> <camunda:in source="operationId" target="operationId" /> <camunda:in source="sliceProfile" target="sliceProfile" /> <camunda:in source="transportSliceNetworks" target="transportSliceNetworks" /> + <camunda:in source="enableSdnc" target="enableSdnc" /> <camunda:in source="nsiInfo" target="nsiInfo" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:out source="rollbackData" target="rollbackData" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn index 2b122fb5e2..dcfd31beac 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoModifyTransportNSSI.bpmn @@ -36,6 +36,7 @@ runScript.prepareUpdateJobStatus(execution,"FINISHED","100","Modified TN NSSI su <bpmn:sequenceFlow id="SequenceFlow_1qv8qw1" sourceRef="ScriptTask_1ssh2l9" targetRef="Activity_0ziz3ti" /> <bpmn:scriptTask id="ScriptTask_19uxoi8" name="Update AAI Status" scriptFormat="groovy"> <bpmn:incoming>Flow_0h5rwlh</bpmn:incoming> + <bpmn:incoming>Flow_0b3rxne</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0kixzdj</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* execution.setVariable("orchestrationStatus", "modified") @@ -51,7 +52,7 @@ runScript.updateAAIOrchStatus(execution)</bpmn:script> def runScript = new DoModifyTnNssi() runScript.updateTnNssiInAAI(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Activity_0h1vr2l" /> + <bpmn:sequenceFlow id="SequenceFlow_1jdb2oq" sourceRef="Activity_0phv8e5" targetRef="Gateway_1o68a9z" /> <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_03s744c</bpmn:incoming> <bpmn:outgoing>SequenceFlow_07e12rt</bpmn:outgoing> @@ -61,7 +62,7 @@ runScript.preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_07e12rt" sourceRef="ScriptTask_1tc44ge" targetRef="Activity_0phv8e5" /> <bpmn:scriptTask id="Activity_0h1vr2l" name="PreProcess SDNC Modify TN NSSI Request" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:incoming>Flow_0cm9i4m</bpmn:incoming> <bpmn:outgoing>Flow_1dvo5ih</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def runScript = new DoModifyTnNssi() @@ -116,106 +117,135 @@ runScript.validateSDNCResponse(execution, response, "modify")</bpmn:script> <bpmn:outgoing>Flow_1akxvak</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="Flow_1akxvak" sourceRef="Activity_0ziz3ti" targetRef="EndEvent_05h01gx" /> + <bpmn:exclusiveGateway id="Gateway_1o68a9z" name="Enable SDNC?"> + <bpmn:incoming>SequenceFlow_1jdb2oq</bpmn:incoming> + <bpmn:outgoing>Flow_0cm9i4m</bpmn:outgoing> + <bpmn:outgoing>Flow_0b3rxne</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="Flow_0cm9i4m" name="Yes" sourceRef="Gateway_1o68a9z" targetRef="Activity_0h1vr2l"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("enableSdnc" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="Flow_0b3rxne" name="No" sourceRef="Gateway_1o68a9z" targetRef="ScriptTask_19uxoi8" /> </bpmn:process> <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoModifyTransportNSSI"> + <bpmndi:BPMNEdge id="Flow_1akxvak_di" bpmnElement="Flow_1akxvak"> + <di:waypoint x="1230" y="400" /> + <di:waypoint x="1372" y="400" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0h5rwlh_di" bpmnElement="Flow_0h5rwlh"> - <di:waypoint x="1240" y="121" /> - <di:waypoint x="1380" y="121" /> - <di:waypoint x="1380" y="210" /> - <di:waypoint x="335" y="210" /> - <di:waypoint x="335" y="310" /> + <di:waypoint x="1350" y="121" /> + <di:waypoint x="1430" y="121" /> + <di:waypoint x="1430" y="280" /> + <di:waypoint x="690" y="280" /> + <di:waypoint x="690" y="360" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_139j3yd_di" bpmnElement="Flow_139j3yd"> - <di:waypoint x="1010" y="121" /> - <di:waypoint x="1119" y="121" /> + <di:waypoint x="1110" y="121" /> + <di:waypoint x="1229" y="121" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1dvo5ih_di" bpmnElement="Flow_1dvo5ih"> - <di:waypoint x="806" y="121" /> - <di:waypoint x="889" y="121" /> + <di:waypoint x="910" y="121" /> + <di:waypoint x="989" y="121" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> - <di:waypoint x="385" y="121" /> + <di:waypoint x="390" y="121" /> <di:waypoint x="479" y="121" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1jdb2oq_di" bpmnElement="SequenceFlow_1jdb2oq"> <di:waypoint x="600" y="121" /> - <di:waypoint x="685" y="121" /> + <di:waypoint x="665" y="121" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> - <di:waypoint x="385" y="350" /> - <di:waypoint x="530" y="350" /> + <di:waypoint x="740" y="400" /> + <di:waypoint x="860" y="400" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> - <di:waypoint x="630" y="350" /> - <di:waypoint x="740" y="350" /> + <di:waypoint x="960" y="400" /> + <di:waypoint x="1130" y="400" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_03s744c_di" bpmnElement="SequenceFlow_03s744c"> - <di:waypoint x="214" y="121" /> - <di:waypoint x="285" y="121" /> + <di:waypoint x="208" y="121" /> + <di:waypoint x="290" y="121" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_1akxvak_di" bpmnElement="Flow_1akxvak"> - <di:waypoint x="840" y="350" /> - <di:waypoint x="1002" y="350" /> + <bpmndi:BPMNEdge id="Flow_0cm9i4m_di" bpmnElement="Flow_0cm9i4m"> + <di:waypoint x="715" y="121" /> + <di:waypoint x="789" y="121" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="743" y="103" width="19" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> - <dc:Bounds x="178" y="103" width="36" height="36" /> + <bpmndi:BPMNEdge id="Flow_0b3rxne_di" bpmnElement="Flow_0b3rxne"> + <di:waypoint x="690" y="146" /> + <di:waypoint x="690" y="360" /> <bpmndi:BPMNLabel> - <dc:Bounds x="161" y="146" width="86" height="40" /> + <dc:Bounds x="698" y="203" width="15" height="14" /> </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="Activity_1vtz33q_di" bpmnElement="Activity_1vtz33q"> + <dc:Bounds x="1229" y="74" width="121" height="94" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0ziz3ti_di" bpmnElement="Activity_0ziz3ti"> - <dc:Bounds x="740" y="310" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_14ab476_di" bpmnElement="Activity_14ab476"> + <dc:Bounds x="989" y="74" width="121" height="94" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> - <dc:Bounds x="685" y="1080" width="781" height="196" /> + <bpmndi:BPMNShape id="Activity_0h1vr2l_di" bpmnElement="Activity_0h1vr2l"> + <dc:Bounds x="789" y="74" width="121" height="94" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> - <di:waypoint x="1079" y="1184" /> - <di:waypoint x="1353" y="1184" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> - <di:waypoint x="751" y="1184" /> - <di:waypoint x="979" y="1184" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> - <dc:Bounds x="715" y="1166" width="36" height="36" /> + <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> + <dc:Bounds x="172" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="155" y="146" width="86" height="40" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> - <dc:Bounds x="1353" y="1166" width="36" height="36" /> + <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> + <dc:Bounds x="290" y="81" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> - <dc:Bounds x="979" y="1144" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> + <dc:Bounds x="479" y="74" width="121" height="94" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> - <dc:Bounds x="1002" y="332" width="36" height="36" /> + <bpmndi:BPMNShape id="Gateway_1o68a9z_di" bpmnElement="Gateway_1o68a9z" isMarkerVisible="true"> + <dc:Bounds x="665" y="96" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1010" y="375" width="20" height="14" /> + <dc:Bounds x="653" y="73" width="75" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> + <dc:Bounds x="640" y="360" width="100" height="80" /> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1ssh2l9_di" bpmnElement="ScriptTask_1ssh2l9"> - <dc:Bounds x="530" y="310" width="100" height="80" /> + <dc:Bounds x="860" y="360" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_19uxoi8_di" bpmnElement="ScriptTask_19uxoi8"> - <dc:Bounds x="285" y="310" width="100" height="80" /> + <bpmndi:BPMNShape id="Activity_0ziz3ti_di" bpmnElement="Activity_0ziz3ti"> + <dc:Bounds x="1130" y="360" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0phv8e5_di" bpmnElement="Activity_0phv8e5"> - <dc:Bounds x="479" y="74" width="121" height="94" /> + <bpmndi:BPMNShape id="EndEvent_05h01gx_di" bpmnElement="EndEvent_05h01gx"> + <dc:Bounds x="1372" y="382" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1380" y="425" width="20" height="14" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1tc44ge_di" bpmnElement="ScriptTask_1tc44ge"> - <dc:Bounds x="285" y="81" width="100" height="80" /> + <bpmndi:BPMNShape id="SubProcess_1yv9i68_di" bpmnElement="SubProcess_1yv9i68" isExpanded="true"> + <dc:Bounds x="735" y="1080" width="781" height="196" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_0h1vr2l_di" bpmnElement="Activity_0h1vr2l"> - <dc:Bounds x="685" y="74" width="121" height="94" /> + <bpmndi:BPMNEdge id="SequenceFlow_08mlzwz_di" bpmnElement="SequenceFlow_08mlzwz"> + <di:waypoint x="1129" y="1184" /> + <di:waypoint x="1403" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1w67v6s_di" bpmnElement="SequenceFlow_1w67v6s"> + <di:waypoint x="801" y="1184" /> + <di:waypoint x="1029" y="1184" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_1omdx56_di" bpmnElement="StartEvent_1omdx56"> + <dc:Bounds x="765" y="1166" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_14ab476_di" bpmnElement="Activity_14ab476"> - <dc:Bounds x="889" y="74" width="121" height="94" /> + <bpmndi:BPMNShape id="EndEvent_1jx3026_di" bpmnElement="EndEvent_1jx3026"> + <dc:Bounds x="1403" y="1166" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_1vtz33q_di" bpmnElement="Activity_1vtz33q"> - <dc:Bounds x="1119" y="74" width="121" height="94" /> + <bpmndi:BPMNShape id="ScriptTask_1swzdpw_di" bpmnElement="ScriptTask_1swzdpw"> + <dc:Bounds x="1029" y="1144" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> 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..ccefc772c3 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 @@ -430,6 +430,8 @@ public class WorkflowActionBBTasks { if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) { postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); } + + flowManipulatorListenerRunner.postModifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); } protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb, 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), @@ -76,7 +76,7 @@ <appc.client.version>1.7.2</appc.client.version> <bowman.client.version>0.9.0</bowman.client.version> <aaf.cadi.version>2.1.15</aaf.cadi.version> - <so-etsi-sol003-adapter-version>1.7.1-SNAPSHOT</so-etsi-sol003-adapter-version> + <so-etsi-sol003-adapter-version>1.8.1-SNAPSHOT</so-etsi-sol003-adapter-version> </properties> <distributionManagement> <repository> |