diff options
88 files changed, 1303 insertions, 1218 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java index 687afeda40..b614a92177 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java @@ -20,8 +20,6 @@ package org.onap.so.openstack.utils; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import org.onap.so.cloud.authentication.KeystoneAuthHolder; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; @@ -30,6 +28,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.glance.Glance; +import com.woorea.openstack.glance.model.Image; import com.woorea.openstack.glance.model.Images; @Component @@ -73,14 +72,7 @@ public class GlanceClientImpl extends MsoCommonUtils { try { String encodedName = null; if (name != null) { - try { - encodedName = - "in:\"" + URLEncoder.encode(name, "UTF-8").replace("+", "%20").replace("%3A", ":") + "\""; - } catch (UnsupportedEncodingException e) { - logger.error("Error Encoding Image Name", e); - throw new GlanceClientException("Error Endcoding Name", e); - } - + encodedName = "in:\"" + name + "\""; } Glance glanceClient = getGlanceClient(cloudSiteId, tenantId); // list is set to false, otherwise an invalid URL is appended @@ -93,4 +85,17 @@ public class GlanceClientImpl extends MsoCommonUtils { } } + public Image queryImage(String cloudSiteId, String tenantId, String imageId) + throws MsoCloudSiteNotFound, GlanceClientException { + try { + Glance glanceClient = getGlanceClient(cloudSiteId, tenantId); + // list is set to false, otherwise an invalid URL is appended + OpenStackRequest<Image> request = glanceClient.images().show(imageId); + return executeAndRecordOpenstackRequest(request, false); + } catch (MsoException e) { + logger.error("Error building Glance Client", e); + throw new GlanceClientException("Error building Glance Client", e); + } + } + } diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index bcc523ab98..b1cf8b14be 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -44,7 +44,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java index e74663dbba..09c790cc6a 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java @@ -68,7 +68,7 @@ public class ServiceMapper { private List<Vnf> mapVnfs(org.onap.so.db.catalog.beans.Service service, int depth) { List<Vnf> vnfs = new ArrayList<>(); logger.info("Vnf Count : {}", service.getVnfCustomizations().size()); - service.getVnfCustomizations().parallelStream().forEach(vnf -> vnfs.add(mapVnf(vnf, depth))); + service.getVnfCustomizations().stream().forEach(vnf -> vnfs.add(mapVnf(vnf, depth))); return vnfs; } @@ -104,7 +104,7 @@ public class ServiceMapper { private List<VfModule> mapVfModules(VnfResourceCustomization vnfResourceCustomization, int depth) { List<VfModule> vfModules = new ArrayList<>(); - vnfResourceCustomization.getVfModuleCustomizations().parallelStream() + vnfResourceCustomization.getVfModuleCustomizations().stream() .forEach(vfModule -> vfModules.add(mapVfModule(vfModule, depth))); return vfModules; } @@ -133,8 +133,7 @@ public class ServiceMapper { private List<Cvnfc> mapCvnfcs(VfModuleCustomization vfModuleCustomization) { List<Cvnfc> cvnfcs = new ArrayList<>(); - vfModuleCustomization.getCvnfcCustomization().parallelStream() - .forEach(cvnfcCust -> cvnfcs.add(mapCvnfcCus(cvnfcCust))); + vfModuleCustomization.getCvnfcCustomization().stream().forEach(cvnfcCust -> cvnfcs.add(mapCvnfcCus(cvnfcCust))); return cvnfcs; } diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index a668b42106..4cf7d6f09b 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -140,7 +140,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java index ed45346131..3ff15ffe2f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java @@ -288,7 +288,7 @@ public class HeatStackAudit { */ protected List<Optional<Port>> retrieveNeutronPortDetails(Resources resources, String cloudSiteId, String tenantId) { - return resources.getList().parallelStream().filter(resource -> "OS::Neutron::Port".equals(resource.getType())) + return resources.getList().stream().filter(resource -> "OS::Neutron::Port".equals(resource.getType())) .map(resource -> neutron.getNeutronPort(resource.getPhysicalResourceId(), tenantId, cloudSiteId)) .collect(Collectors.toList()); 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 dcf33da128..a00b9f9002 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 @@ -272,6 +272,14 @@ public class HeatBridgeImpl implements HeatBridgeApi { } else { lIf.setInterfaceRole(port.getvNicType()); } + boolean isL2Multicast = false; + if (port.getProfile().get("trusted") != null) { + String trusted = port.getProfile().get("trusted").toString(); + if (Boolean.parseBoolean(trusted)) { + isL2Multicast = true; + } + } + lIf.setL2Multicasting(isL2Multicast); updateLInterfaceIps(port, lIf); updateLInterfaceVlan(port, lIf); 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 e9e25db376..eb4b9f538d 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 @@ -163,9 +163,6 @@ public class AaiHelper { if (server.getHost() != null) { pserver.setPserverName2(server.getHost()); } - if (server.getStatus() != null && server.getStatus().value() != null) { - pserver.setProvStatus(server.getStatus().value()); - } return pserver; } diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index 2354272756..3f62fe2420 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -186,7 +186,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java index 84ff054a7c..7feaa9c4c3 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlElement; import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.ResourceOperationStatus; /** @@ -77,6 +78,12 @@ public interface MsoRequestsDbAdapter { public boolean getSiteStatus(@WebParam(name = "siteName") @XmlElement(required = true) String siteName); @WebMethod + public OperationStatus getServiceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = false) String operationId) + throws MsoRequestsDbException; + + @WebMethod public void updateServiceOperationStatus( @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, @WebParam(name = "operationId") @XmlElement(required = false) String operationId, diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index b262cb21cb..8782cce34a 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -222,6 +222,27 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } /** + * get the operation status + * + * @param serviceId + * @param operationId + * @return operationStatus + * @throws MsoRequestsDbException + */ + @Override + @Transactional + public OperationStatus getServiceOperationStatus(String serviceId, String operationId) + throws MsoRequestsDbException { + OperationStatus operationStatus; + if (operationId.isEmpty()) { + operationStatus = operationStatusRepository.findOneByServiceId(serviceId); + } else { + operationStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId); + } + return operationStatus; + } + + /** * update operation status <br> * * @param serviceId diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index 7fd1aa62d4..5001665779 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -63,7 +63,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml index 64eefaa151..0491dd9d56 100644 --- a/adapters/so-appc-orchestrator/pom.xml +++ b/adapters/so-appc-orchestrator/pom.xml @@ -45,7 +45,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index 60a3b5a07b..e44d2ed1ee 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -125,7 +125,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index 7b49fa06b3..91f73e2306 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -443,7 +443,6 @@ class CatalogDbUtils { String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint def responseData = '' HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.CATALOG_DB) - client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, UUID.randomUUID().toString()) client.addAdditionalHeader('X-FromAppId', "BPMN") client.addAdditionalHeader('Accept', MediaType.APPLICATION_JSON) String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 83be39c264..f5cf541076 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup @@ -31,8 +30,10 @@ 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.so.constants.Defaults +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.logging.filter.base.ErrorCode +import org.onap.so.constants.Defaults +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -71,7 +72,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ if(relationships.isPresent()){ List<AAIResourceUri> tenantUris = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) for (AAIResourceUri tenantURI: tenantUris){ - volumeGroupTenantId = tenantURI.getURIKeys().get("tenant-id") + volumeGroupTenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } //Determine if Tenant Ids match diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index a5111a62d3..b390f7675a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -186,7 +186,6 @@ class ExternalAPIUtil { HttpClient httpClient = httpClientFactory.newJsonClient(new URL(url), ONAPComponents.AAI) httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey")) httpClient.addAdditionalHeader("X-FromAppId", "MSO") - httpClient.addAdditionalHeader("X-TransactionId", uuid) httpClient.addAdditionalHeader("Target",execution.getVariable("SPPartnerUrl")) apiResponse = httpClient.post(payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NssmfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NssmfAdapterUtils.groovy new file mode 100644 index 0000000000..775f088136 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NssmfAdapterUtils.groovy @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.bpmn.common.scripts + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.logging.filter.base.ErrorCode +import org.onap.logging.filter.base.ONAPComponents +import org.onap.logging.ref.slf4j.ONAPLogConstants +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.LoggingAnchor +import org.onap.so.logger.MessageEnum +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils + +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response + +/*** + * Utilities for accessing Catalog DB Adapter to retrieve Networks, VNF/VFModules, AllottedResources and complete ServiceResources information + * + */ + +class NssmfAdapterUtils { + private static final Logger logger = LoggerFactory.getLogger( NssmfAdapterUtils.class); + + private HttpClientFactory httpClientFactory + private MsoUtils utils + private JsonUtils jsonUtils + + NssmfAdapterUtils(HttpClientFactory httpClientFactory, JsonUtils jsonUtils) { + this.httpClientFactory = httpClientFactory + this.utils = new MsoUtils() + this.jsonUtils = jsonUtils + } + + + public <T> T sendPostRequestNSSMF (DelegateExecution execution, String endPoint, String nssmfRequest, Class<T> entityType) { + try { + + String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution) + String queryEndpoint = nssmfEndpoint + endPoint + def responseData + HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.EXTERNAL) + String basicAuthCred = execution.getVariable("BasicAuthHeaderValue") + client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution))) + + logger.debug('sending POST to NSSMF endpoint: ' + endPoint) + Response response = client.post(nssmfRequest) + + responseData = response.readEntity(entityType) + if (responseData != null) { + logger.debug("Received data from NSSMF: " + responseData) + } + + logger.debug('Response code:' + response.getStatus()) + logger.debug('Response:' + System.lineSeparator() + responseData) + if (response.getStatus() >= 200 && response.getStatus() < 300) { + // parse response as needed + return responseData + } + else { + return null + } + } + catch (Exception e) { + logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message) + throw e + } + + } + + public String sendPostRequestNSSMF (DelegateExecution execution, String endPoint, String nssmfRequest) { + try { + + String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution) + String queryEndpoint = nssmfEndpoint + endPoint + def responseData + HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.EXTERNAL) + String basicAuthCred = execution.getVariable("BasicAuthHeaderValue") + client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution))) + + logger.debug('sending POST to NSSMF endpoint: ' + endPoint) + Response response = client.post(nssmfRequest) + + responseData = response.readEntity(String.class) + if (responseData != null) { + logger.debug("Received data from NSSMF: " + responseData) + } + + logger.debug('Response code:' + response.getStatus()) + logger.debug('Response:' + System.lineSeparator() + responseData) + if (response.getStatus() >= 200 && response.getStatus() < 300) { + // parse response as needed + return responseData + } + else { + return null + } + } + catch (Exception e) { + logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message) + throw e + } + + } + + + private String getBasicDBAuthHeader(DelegateExecution execution) { + + String encodedString = null + try { + String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) + logger.debug("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB) + + encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValue", encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + logger.error(dataErrorMessage) + } + return encodedString + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 34cbb00735..d307a4e7bc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -534,6 +534,7 @@ class OofUtils { public String buildSelectNSTRequest(String requestId, Map<String, Object> profileInfo) { def transactionId = requestId logger.debug( "transactionId is: " + transactionId) + String callbackUrl = "http://0.0.0.0:9000/callback/" ObjectMapper objectMapper = new ObjectMapper() String json = objectMapper.writeValueAsString(profileInfo) StringBuilder response = new StringBuilder() @@ -543,11 +544,45 @@ class OofUtils { " \"transactionId\": \"${transactionId}\",\n" + " \"requestId\": \"${requestId}\",\n" + " \"sourceId\": \"so\",\n" + - " \"timeout\": 600\n" + + " \"timeout\": 600,\n" + + " \"callbackUrl\": \"${callbackUrl}\"\n" + " },\n") - response.append(",\n \"serviceInfo\": \n") + response.append(" \"serviceProfile\": {\n" + + " \"serviceProfileParameters\": ") + response.append(json); + response.append("\n }\n") + response.append("\n}\n") + return response.toString() + } + + public String buildSelectNSIRequest(String requestId, String nstInfo, Map<String, Object> profileInfo){ + + def transactionId = requestId + logger.debug( "transactionId is: " + transactionId) + String callbackUrl = "http://0.0.0.0:9000/callback/" + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(profileInfo); + StringBuilder response = new StringBuilder(); + response.append( + "{\n" + + " \"requestInfo\": {\n" + + " \"transactionId\": \"${transactionId}\",\n" + + " \"requestId\": \"${requestId}\",\n" + + " \"sourceId\": \"so\",\n" + + " \"timeout\": 600,\n" + + " \"callbackUrl\": \"${callbackUrl}\"\n" + + " },\n" + + " \"serviceInfo\": {\n" + + " \"serviceInstanceId\": \"\",\n" + + " \"serviceName\": \"\"\n" + + " },\n" + + " \"NSTInfoList\": [\n") + response.append(nstInfo); + response.append("\n ],\n") + response.append("\n \"serviceProfile\": \n") response.append(json); response.append("\n }\n") return response.toString() } + } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index ebaf65ff81..55f1187d69 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -224,9 +224,6 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { URL url = new URL(sdncAdapterUrl) HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SDNC_ADAPTER) - httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) - httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString()) - httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-SDNCAdapter") httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id")) httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id")) httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) 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 0fd38badad..bfa77212c4 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 @@ -34,14 +34,36 @@ import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.javatuples.Pair; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.servicedecomposition.bbobjects.*; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -52,12 +74,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -1044,7 +1060,8 @@ public class BBInputSetup implements JavaDelegate { protected ServiceSubscription getServiceSubscriptionFromURI(String resourceId, Customer customer) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String subscriptionServiceType = uriKeys.get("service-type"); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI = bbInputSetupUtils.getAAIServiceSubscription(customer.getGlobalCustomerId(), subscriptionServiceType); if (serviceSubscriptionAAI != null) { @@ -1056,7 +1073,7 @@ public class BBInputSetup implements JavaDelegate { protected Customer getCustomerFromURI(String resourceId) { Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); - String globalCustomerId = uriKeys.get("global-customer-id"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); org.onap.aai.domain.yang.Customer customerAAI = this.bbInputSetupUtils.getAAICustomer(globalCustomerId); if (customerAAI != null) { return mapperLayer.mapAAICustomer(customerAAI); @@ -1085,8 +1102,9 @@ public class BBInputSetup implements JavaDelegate { if (customer == null) { Map<String, String> uriKeys = bbInputSetupUtils .getURIKeysFromServiceInstance(parameter.getServiceInstance().getServiceInstanceId()); - String globalCustomerId = uriKeys.get("global-customer-id"); - String subscriptionServiceType = uriKeys.get("service-type"); + String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId); + String subscriptionServiceType = + uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType); customer = mapCustomer(globalCustomerId, subscriptionServiceType); } outputBB.setServiceInstance(parameter.getServiceInstance()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java index c05557a317..c6a921abb5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -20,8 +20,9 @@ package org.onap.so.client.appc; -import java.util.HashMap; +import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.appc.client.lcm.model.Action; import org.onap.appc.client.lcm.model.Status; @@ -40,10 +41,11 @@ public class ApplicationControllerAction { protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); private String errorCode = "1002"; private String errorMessage = "Unable to reach App C Servers"; + private static final String PAYLOAD_NOT_PRESENT_ERROR_MSG = "Payload is not present for "; private static Logger logger = LoggerFactory.getLogger(ApplicationControllerAction.class); public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional<String> payload, - HashMap<String, String> payloadInfo, String controllerType) { + Map<String, String> payloadInfo, String controllerType) { Status appCStatus = null; try { String vnfName = payloadInfo.getOrDefault("vnfName", ""); @@ -96,20 +98,8 @@ public class ApplicationControllerAction { logger.warn("vserverIds null in AppCClient"); break; } - String vmId = ""; - String vserverId = ""; - ObjectMapper mapper = new ObjectMapper(); - List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {}); - List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {}); - int i = 0; - while (i < vmIdJsonList.size()) { - vmId = vmIdJsonList.get(i); - vserverId = vserverIdJsonList.get(i); - Optional<String> vserverIdString = Optional.of(vserverId); - appCStatus = - snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType); - i++; - } + appCStatus = getSnapshotActionAppcStatus(msoRequestId, vnfId, controllerType, identityUrl, vmIds, + vserverIds); break; case ConfigModify: case ConfigScaleOut: @@ -140,29 +130,44 @@ public class ApplicationControllerAction { logger.error("Error building Appc request: {}", e.getMessage(), e); errorCode = "1002"; errorMessage = e.getMessage(); - } catch (NoSuchMethodError e) { - logger.error("Error building Appc request: {}", e.getMessage(), e); - errorMessage = e.getMessage(); } catch (Exception e) { logger.error("Error building Appc request: {}", e.getMessage(), e); errorMessage = e.getMessage(); } } + private Status getSnapshotActionAppcStatus(String msoRequestId, String vnfId, String controllerType, + String identityUrl, String vmIds, String vserverIds) + throws IOException, ApplicationControllerOrchestratorException { + Status appcStatus = null; + String vmId = ""; + String vserverId = ""; + ObjectMapper mapper = new ObjectMapper(); + List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>() {}); + List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>() {}); + int i = 0; + while (i < vmIdJsonList.size()) { + vmId = vmIdJsonList.get(i); + vserverId = vserverIdJsonList.get(i); + Optional<String> vserverIdString = Optional.of(vserverId); + appcStatus = snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType); + i++; + } + return appcStatus; + } + private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + action.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + action.toString()); } return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.QuiesceTraffic.toString()); } payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, Optional.empty(), payload, controllerType); @@ -170,19 +175,18 @@ public class ApplicationControllerAction { private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + action.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + action.toString()); } payload = PayloadClient.upgradeFormat(payload, vnfName); return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } private Status distributeTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, - String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { - throw new IllegalArgumentException("Payload is not present for " + Action.DistributeTraffic.toString()); + throw new IllegalArgumentException(PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.DistributeTraffic.toString()); } payload = PayloadClient.distributeTrafficFormat(payload, vnfName); return client.vnfCommand(Action.DistributeTraffic, msoRequestId, vnfId, Optional.empty(), payload, @@ -191,10 +195,10 @@ public class ApplicationControllerAction { private Status distributeTrafficCheckAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) - throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + throws JsonProcessingException, ApplicationControllerOrchestratorException { if (!(payload.isPresent())) { throw new IllegalArgumentException( - "Payload is not present for " + Action.DistributeTrafficCheck.toString()); + PAYLOAD_NOT_PRESENT_ERROR_MSG + Action.DistributeTrafficCheck.toString()); } payload = PayloadClient.distributeTrafficCheckFormat(payload, vnfName); return client.vnfCommand(Action.DistributeTrafficCheck, msoRequestId, vnfId, Optional.empty(), payload, diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 79e957155d..948c9326d8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -80,7 +80,7 @@ public class ExceptionBuilder { } logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -113,7 +113,7 @@ public class ExceptionBuilder { } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -144,7 +144,7 @@ public class ExceptionBuilder { } } logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -176,7 +176,7 @@ public class ExceptionBuilder { } } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { // log trace, allow process to complete gracefully @@ -260,7 +260,7 @@ public class ExceptionBuilder { public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { logger.debug("Processing Audit Results"); - String auditListString = (String) execution.getVariable("auditInventoryResult"); + String auditListString = execution.getVariable("auditInventoryResult"); String processKey = getProcessKey(execution.getDelegateExecution()); if (auditListString != null) { StringBuilder errorMessage = new StringBuilder(); @@ -304,6 +304,7 @@ public class ExceptionBuilder { } catch (IOException | BBObjectNotFoundException e) { errorMessage = errorMessage.append("process objects in AAI. "); + logger.error("Exception occurred in processAuditException", e); } if (flowShouldContinue) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java index c2283f1627..692d581b0d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -33,11 +33,10 @@ public class AAIPropertiesImpl implements AAIProperties { public static final String MSO_MSO_KEY = "mso.msoKey"; public static final String AAI_AUTH = "aai.auth"; public static final String AAI_ENDPOINT = "aai.endpoint"; - private UrnPropertiesReader reader; @Override public URL getEndpoint() throws MalformedURLException { - return new URL(reader.getVariable(AAI_ENDPOINT)); + return new URL(UrnPropertiesReader.getVariable(AAI_ENDPOINT)); } @Override @@ -52,11 +51,11 @@ public class AAIPropertiesImpl implements AAIProperties { @Override public String getAuth() { - return reader.getVariable(AAI_AUTH); + return UrnPropertiesReader.getVariable(AAI_AUTH); } @Override public String getKey() { - return reader.getVariable(MSO_MSO_KEY); + return UrnPropertiesReader.getVariable(MSO_MSO_KEY); } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy index fda6b8e6e3..216f34573b 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy @@ -136,7 +136,6 @@ class CatalogDbUtilsTest { } private void verifyHeadersInHttpClient() { - verify(httpClientMock).addAdditionalHeader(eq(ONAPLogConstants.Headers.REQUEST_ID), anyString()) verify(httpClientMock).addAdditionalHeader("X-FromAppId", "BPMN") verify(httpClientMock).addAdditionalHeader("Accept", MediaType.APPLICATION_JSON) verify(httpClientMock).addAdditionalHeader("Authorization", AUTHORIZATION_HEADER) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy index 7abfcffb13..e6d5fb86e6 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy @@ -129,7 +129,6 @@ class ExternalAPIUtilTest { // THEN then(httpClient).should(times(1)).addBasicAuthHeader("value_externalapi_auth", "value_mso_msoKey") then(httpClient).should(times(1)).addAdditionalHeader("X-FromAppId", "MSO") - then(httpClient).should(times(1)).addAdditionalHeader("X-TransactionId", UUID_STR) ResponseAssert.assertThat(apiResponse) .hasStatusCode(HttpStatus.ACCEPTED) .hasBody(BODY_PAYLOAD) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index b327847c11..458919c48e 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -58,6 +58,12 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +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.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -94,11 +100,6 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -944,8 +945,8 @@ public class BBInputSetupTest { cloudRegion.setTenantId("tenantId"); Map<String, String> uriKeys = new HashMap<>(); - uriKeys.put("global-customer-id", "global-customer-id"); - uriKeys.put("service-type", "service-type"); + uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "global-customer-id"); + uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "service-type"); Customer customer = new Customer(); ServiceSubscription serviceSubscription = new ServiceSubscription(); diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 04a291af8c..b285138e9c 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -135,7 +135,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy index 169c00b68b..ecbe766695 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy @@ -129,7 +129,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * check service status through request operation id, update operation status */ - def preCheckServiceStatusReq = { DelegateExecution execution -> + void preCheckServiceStatusReq(DelegateExecution execution) { logger.trace(Prefix + "preCheckServiceStatusReq Start") String serviceInstanceId = execution.getVariable("serviceInstanceId") as String String operationId = execution.getVariable("operationId") as String @@ -142,7 +142,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { * handle service status, if service status is finished or error, set the service status * @param execution */ - def handlerServiceStatusResp = { DelegateExecution execution -> + void handlerServiceStatusResp(DelegateExecution execution) { logger.trace(Prefix + "handlerServiceStatusResp Start") String msg try { @@ -203,7 +203,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def timeWaitDelay = { DelegateExecution execution -> + void timeWaitDelay(DelegateExecution execution) { Long startTime = execution.getVariable("startTime") as Long Long timeOut = execution.getVariable("timeOut") as Long @@ -221,7 +221,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerTimeOut = { DelegateExecution execution -> + private handlerTimeOut(DelegateExecution execution) { Map<String, Object> paramMap = execution.getVariable("timeOutParamMap") as Map @@ -229,7 +229,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerSuccess = { DelegateExecution execution, String result -> + private handlerSuccess(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("successParamMap") as Map @@ -237,7 +237,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerError = { DelegateExecution execution, String result -> + private handlerError(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("errorParamMap") as Map @@ -245,7 +245,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerProcess = { DelegateExecution execution, String result, def paramMap, def status, def msg -> + private handlerProcess(DelegateExecution execution, String result, def paramMap, def status, def msg) { if (paramMap != null) { for (Map.Entry<String, Object> entry : paramMap.entrySet()) { @@ -260,7 +260,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { if (isBlank(execution.getVariable("operationContent") as String)) { - String operationContent = execution.getVariable("processServiceType") + " " + + String operationContent = execution.getVariable("processServiceType") + " " + execution.getVariable("operationType") + " operation finished " + msg execution.setVariable("operationContent", operationContent) } @@ -275,7 +275,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing success finished */ - private isSuccessCompleted = { DelegateExecution execution, String result -> + private Boolean isSuccessCompleted(DelegateExecution execution, String result) { //successConditions: processing end success conditions List<String> successConditions = execution.getVariable("successConditions") as List @@ -291,7 +291,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing error finished */ - private isErrorCompleted = { DelegateExecution execution, String result -> + private Boolean isErrorCompleted(DelegateExecution execution, String result) { //errorConditions: processing end error conditions List<String> errorConditions = execution.getVariable("errorConditions") as List @@ -304,7 +304,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def preUpdateOperationProgress = { DelegateExecution execution -> + void preUpdateOperationProgress(DelegateExecution execution) { logger.trace(Prefix + "prepareUpdateOperationStatus Start") def progress = execution.getVariable("progress") as Integer @@ -314,7 +314,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { def resProgress = (initProgress + (endProgress - initProgress) / 100 * progress) as Integer def operationType = execution.getVariable("operationType") - def operationContent = execution.getVariable("processServiceType") + " " + + def operationContent = execution.getVariable("processServiceType") + " " + operationType + " operation processing " + resProgress // update status creating diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index 8689972c73..cf6bef6510 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -383,9 +383,6 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { } e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) - e2eInputMap.put("areaTrafficCapDL", 100) - e2eInputMap.put("areaTrafficCapUL", 100) - e2eInputMap.put("sST", execution.getVariable("csServiceType")) execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index b3f030d480..15a0f34482 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -155,9 +155,14 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters") Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs") + def serviceProfile = [:] + for(entry in requestInputs) { + serviceProfile[entry.key] = entry.value + } + execution.setVariable("serviceInputParams", inputMap) execution.setVariable("uuiRequest", uuiRequest) - execution.setVariable("serviceProfile", requestInputs) + execution.setVariable("serviceProfile", serviceProfile) //TODO //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) @@ -344,7 +349,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { String orchStatus = execution.getVariable("orchestrationStatus") try { - ServiceInstance si = execution.getVariable("serviceInstanceData") + ServiceInstance si = ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index bc118791a3..005f0f3c6b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -22,10 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AaiUtil; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.onap.so.bpmn.common.scripts.ExceptionUtil; @@ -33,19 +39,13 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory import groovy.json.JsonSlurper -import javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVfModuleVolume.bpmn</class> process. */ @@ -285,7 +285,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { if(wrapper.getRelationships().isPresent()) { List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.TENANT) if(!tenantURIList.isEmpty()){ - return tenantURIList.get(0).getURIKeys().get("tenant-id") + return tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } return null diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index f58cd9a60d..cc2d865957 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -1,31 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.bpmn.infrastructure.scripts -import com.google.common.reflect.TypeToken -import com.google.gson.Gson import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.AllottedResource import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.RelationshipList import org.onap.aai.domain.yang.ServiceInstance import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceProxy import org.onap.so.bpmn.core.json.JsonUtils import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.db.request.beans.OrchestrationTask import org.slf4j.Logger import org.slf4j.LoggerFactory import javax.ws.rs.NotFoundException -import javax.ws.rs.core.UriBuilder import static org.apache.commons.lang3.StringUtils.isBlank @@ -36,7 +50,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - RequestsDbClient requestsDbClient = new RequestsDbClient() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) /** * Pre Process the BPMN Flow Request @@ -65,8 +80,9 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams") try { - String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_uuid") - String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_invariant_uuid") + Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map + String modelUuid = nstSolution.get("UUID") + String modelInvariantUuid = nstSolution.get("invariantUUID") String serviceModelInfo = """{ "modelInvariantUuid":"${modelInvariantUuid}", "modelUuid":"${modelUuid}", @@ -105,7 +121,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi String nsiServiceInstanceID = sliceParams.getSuggestNsiId() AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID) + AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nsiServiceInstanceID) //AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID) try { @@ -156,7 +172,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi { try { AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiID) AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) org.onap.aai.domain.yang.ServiceInstance nssi = si.get() @@ -179,13 +195,13 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } void createNSIinAAI(DelegateExecution execution) { - logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") + logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") org.onap.aai.domain.yang.ServiceInstance nsi = new ServiceInstance(); String sliceInstanceId = UUID.randomUUID().toString() execution.setVariable("sliceInstanceId",sliceInstanceId) nsi.setServiceInstanceId(sliceInstanceId) - String sliceInstanceName = "nsi_"+execution.getVariable("serviceInstanceName") + String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName") nsi.setServiceInstanceName(sliceInstanceName) String serviceType = execution.getVariable("serviceType") nsi.setServiceType(serviceType) @@ -202,11 +218,20 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi //nsi.setEnvironmentContext(snssai) String serviceRole = "nsi" nsi.setServiceRole(serviceRole) + String msg = "" try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId) - client.create(uri, nsi) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId) + client.create(nsiServiceUri, nsi) + + Relationship relationship = new Relationship() + logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri.build().toString()) + relationship.setRelatedLink(nsiServiceUri.build().toString()) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), execution.getVariable("allottedResourceId")).relationshipAPI() + client.create(allottedResourceUri, relationship) } catch (BpmnError e) { throw e @@ -243,7 +268,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi execution.setVariable("maxIndex",maxIndex) execution.setVariable('nsiServiceInstanceId',sliceInstanceId) execution.setVariable("nsiServiceInstanceName",sliceInstanceName) - logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") + logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") } void getOneNsstInfo(DelegateExecution execution){ @@ -271,7 +296,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi String domain = jsonUtil.getJsonValue(content, "metadata.domainType") Map<String, Object> nssiMap = execution.getVariable("nssiMap") - String servicename = execution.getVariable("serviceInstanceName") + String servicename = execution.getVariable("sliceServiceInstanceName") String nsiname = "nsi_"+servicename nssiMap.put(domain,"""{ "serviceInstanceId":"", @@ -335,4 +360,4 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()") } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index e2aa7972df..2d0034a34d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -4,7 +4,6 @@ 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.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.AllocateAnNssi import org.onap.so.beans.nsmf.AllocateCnNssi import org.onap.so.beans.nsmf.AllocateTnNssi @@ -19,18 +18,15 @@ import org.onap.so.beans.nsmf.PerfReq import org.onap.so.beans.nsmf.PerfReqEmbbList import org.onap.so.beans.nsmf.PerfReqUrllcList import org.onap.so.beans.nsmf.ResourceSharingLevel -import org.onap.so.beans.nsmf.ServiceProfile import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.beans.nsmf.TnSliceProfile import org.onap.so.beans.nsmf.UeMobilityLevel import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel @@ -39,7 +35,6 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.ObjectMapper; -import javax.ws.rs.core.Response import static org.apache.commons.lang3.StringUtils.isBlank @@ -53,6 +48,8 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask JsonUtils jsonUtil = new JsonUtils() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + /** * Pre Process the BPMN Flow Request * Inclouds: @@ -155,134 +152,78 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask void sendUpdateRequestNSSMF(DelegateExecution execution) { - logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()") - String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - logger.debug( "get NSSMF: " + urlString) - - //Prepare auth for NSSMF - Begin - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) + logger.debug("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()") String domain = execution.getVariable("nsstDomain") String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase()) - //send request to update NSSI option - Begin - URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(nssmfRequest) - - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF sync response code is: " + responseCode) - - if(responseCode < 199 && responseCode > 299){ - String nssmfResponse ="NSSMF response have nobody" - if(httpResponse.hasEntity()) - nssmfResponse = httpResponse.readEntity(String.class) - logger.trace("received error message from NSSMF : "+nssmfResponse) - logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") - } + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if (nssmfResponse != null) { execution.setVariable("nssmfResponse", nssmfResponse) String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId") String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") execution.setVariable("nssiId",nssiId) execution.setVariable("jobId",jobId) - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()") } void sendCreateRequestNSSMF(DelegateExecution execution) { - logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()") - String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - logger.debug( "get NSSMF: " + urlString) - + logger.debug("Enter sendCreateRequestNSSMF in DoAllocateNSSI()") //Prepare auth for NSSMF - Begin String domain = execution.getVariable("nsstDomain") String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase()) - //send request to get NSI option - Begin - URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(nssmfRequest) - - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF sync response code is: " + responseCode) - - if(responseCode < 199 || responseCode > 299 ){ - String nssmfResponse ="NSSMF response have nobody" - if(httpResponse.hasEntity()) - nssmfResponse = httpResponse.readEntity(String.class) - logger.trace("received error message from NSSMF : "+nssmfResponse) - logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") - } + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if (nssmfResponse != null) { execution.setVariable("nssmfResponse", nssmfResponse) String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId") String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") execution.setVariable("nssiId",nssiId) execution.setVariable("jobId",jobId) - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } - logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + logger.debug("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") } void getNSSMFProgresss(DelegateExecution execution) { - logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()") - - String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - logger.debug( "get NSSMF: " + endpoint) - - //Prepare auth for NSSMF - Begin - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) + logger.debug("Enter getNSSMFProgresss in DoAllocateNSSI()") String nssmfRequest = buildNSSMFProgressRequest(execution) - String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId") - //send request to update NSSI option - Begin - URL url = new URL(endpoint+strUrl) - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(nssmfRequest) - - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF sync response code is: " + responseCode) - - if(responseCode < 199 || responseCode > 299){ - String nssmfResponse ="NSSMF response have nobody" - if(httpResponse.hasEntity()) - nssmfResponse = httpResponse.readEntity(String.class) - logger.trace("received error message from NSSMF : "+nssmfResponse) - logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") - } + String strUrl="/api/rest/provMns/v1/NSS/jobs/" + execution.getVariable("jobId") + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, strUrl, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if(nssmfResponse != null){ Boolean isNSSICreated = false execution.setVariable("nssmfResponse", nssmfResponse) - Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress")) + Integer progress = Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress")) String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status") String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription") execution.setVariable("nssmfProgress",progress) execution.setVariable("nssmfStatus",status) execution.setVariable("nddmfStatusDescription",statusDescription) - if(progress>99) + if(progress > 99) isNSSICreated = true execution.setVariable("isNSSICreated",isNSSICreated) - - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } - logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()") - + logger.debug("Exit getNSSMFProgresss in DoAllocateNSSI()") } void updateRelationship(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 00242b27f6..22e5819068 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -22,12 +22,27 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory +import javax.ws.rs.NotFoundException import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.L3Networks +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +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.AAIPluralResourceUri +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.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,38 +53,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.Relationships -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource -import org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.L3Networks -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty - -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. @@ -354,8 +341,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") }else{ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 8ab7c7a2d1..5741a78ed4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -1,13 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.bpmn.infrastructure.scripts import com.fasterxml.jackson.core.type.TypeReference -import groovy.json.JsonBuilder +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.Relationship -import org.onap.aai.domain.yang.RelationshipList -import org.onap.aai.domain.yang.ServiceInstance import org.onap.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -24,45 +40,27 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.db.request.beans.OrchestrationTask import org.slf4j.Logger import org.slf4j.LoggerFactory + import javax.ws.rs.NotFoundException import javax.ws.rs.core.Response import static org.apache.commons.lang3.StringUtils.isBlank -public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ +class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class) - ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - RequestsDbClient requestsDbClient = new RequestsDbClient() - OofUtils oofUtils = new OofUtils() - /** - * Pre Process the BPMN Flow Request - * Inclouds: - * generate the nsOperationKey - * generate the nsParameters - */ - void preProcessRequest (DelegateExecution execution) { - String msg = "" - logger.trace("Enter preProcessRequest()") - String taskID = execution.getVariable("taskID") - Boolean isSharable = true - String resourceSharingLevel = execution.getVariable("resourceSharingLevel") - if (resourceSharingLevel.equals("shared")) - isSharable = true - execution.setVariable("isSharable",isSharable) - logger.trace("Exit preProcessRequest") + ObjectMapper objectMapper = new ObjectMapper() + void preProcessRequest (DelegateExecution execution) { } @@ -70,11 +68,10 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) + boolean isNSISuggested = true execution.setVariable("isNSISuggested",isNSISuggested) - String nsiInstanceId = "" - String nsiName = "" - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + //Prepare auth for OOF - Begin def authHeader = "" String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) @@ -100,235 +97,234 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String requestId = execution.getVariable("msoRequestId") Map<String, Object> profileInfo = execution.getVariable("serviceProfile") - String nstModelUuid = execution.getVariable("nstModelUuid") - String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid") - String nstInfo = """"NSTInfo" : { - "invariantUUID":"${nstModelInvariantUuid}", - "UUID":"${nstModelUuid}" + Map<String, Object> nstSolution = execution.getVariable("nstSolution") + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + String nstInfo = """{ + "modelInvariantId":"${nstSolution.invariantUUID}", + "modelVersionId":"${nstSolution.UUID}", + "modelName":"${nstSolution.NSTName}" }""" - String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, profileInfo) + logger.debug("Sending request to OOF: " + oofRequest) //send request to get NSI option - Begin - URL url = new URL(urlString+"/api/oof/v1/selectnsi") + URL url = new URL(urlString+"/api/oof/selection/nsi/v1") HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) httpClient.addAdditionalHeader("Authorization", authHeader) Response httpResponse = httpClient.post(oofRequest) + processOOFResponse(httpResponse, execution) + + //解析sliceProfile + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + private void processOOFResponse(Response httpResponse, DelegateExecution execution) { int responseCode = httpResponse.getStatus() logger.debug("OOF sync response code is: " + responseCode) - if(responseCode != 200){ + if (responseCode != 200) { exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - logger.debug("Info: No NSI suggested by OOF" ) + logger.debug("Info: No NSI suggested by OOF") } - if(httpResponse.hasEntity()){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if (httpResponse.hasEntity()) { String OOFResponse = httpResponse.readEntity(String.class) + logger.debug("NSI OOFResponse is: " + OOFResponse) execution.setVariable("OOFResponse", OOFResponse) - int index = 0 //This needs to be changed to derive a value when we add policy to decide the solution options. + int index = 0 + //This needs to be changed to derive a value when we add policy to decide the solution options. Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse) - if(execution.getVariable("isSharable" ) == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) { - nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId - nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName - sliceTaskParams.setNstId(nsiInstanceId) - sliceTaskParams.setSuggestNsiName(nsiName) - execution.setVariable("nsiInstanceId",nsiInstanceId) - execution.setVariable("nsiName",nsiName) - }else { - if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) { - List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions") - for(Map nssi : NSSImap) { - String nssiName = nssi.get("NSSISolution").NSSIName - String nssiId = nssi.get("NSSISolution").NSSIId - String domain = nssi.get("NSSISolution").domain.toUpperCase() - switch (domain) { - case "AN": - sliceTaskParams.setAnSuggestNssiId(nssiId) - sliceTaskParams.setAnSuggestNssiName(nssiName) - break; - case "CN": - sliceTaskParams.setCnSuggestNssiId(nssiId) - sliceTaskParams.setCnSuggestNssiName(nssiName) - break; - case "TN": - sliceTaskParams.setTnSuggestNssiId(nssiId) - sliceTaskParams.setTnSuggestNssiName(nssiName) - break; - default: - break; + Map solutions = OOFResponseObject.get("solutions") + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel.equals("shared") + + if (solutions != null) { + if (isSharable) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } else { + //TODO test OOF + if (solutions.containsKey("newNSISolutions")) { + List<Map> newNSISolutions = solutions.get("newNSISolutions") + List<Map> NSSImap = new ArrayList<>() + if (newNSISolutions != null && newNSISolutions.size() > 0) { + NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map> + } + for (Map nssi : NSSImap) { + def nssiSolution = nssi.get("NSSISolution") as Map<String, ?> + String nssiName = nssiSolution.getOrDefault("NSSIName", "") + String nssiId = nssiSolution.getOrDefault("NSSIId", "") + String domain = nssiSolution.getOrDefault("domainName", "").toString().toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + break + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + break + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + break + default: + break + } } + //TODO sliceProfile } } - } execution.setVariable("sliceTaskParams", sliceTaskParams) - logger.debug("Info: No NSI suggested by OOF" ) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) } - //send request to get NSI option - Begin - + logger.debug("*** Completed options Call to OOF ***") + } - //send request to get NSI service Info - Begin - - /*** - * Need to check whether its needed. - */ -// logger.debug("Begin to query OOF suggetsed NSI from AAI ") -// if(isBlank(nsiInstanceId)){ -// isNSISuggested = false -// execution.setVariable("isNSISuggested",isNSISuggested) -// }else -// { -// try { -// String globalSubscriberId = execution.getVariable('globalSubscriberId') -// String serviceType = execution.getVariable('subscriptionServiceType') -// AAIResourcesClient resourceClient = new AAIResourcesClient() -// AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId) -// AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) -// Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) -// org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get() -// execution.setVariable("nsiServiceInstance",nsiServiceInstance) -// isNSISuggested = true -// execution.setVariable("isNSISuggested",isNSISuggested) -// SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") -// sliceTaskParams.setSuggestNsiId(nsiInstanceId) -// sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName()) -// execution.setVariable("sliceTaskParams", sliceTaskParams) -// logger.debug("Info: NSI suggested by OOF exist in AAI ") -// }catch(BpmnError e) { -// throw e -// }catch(Exception ex) { -// String msg = "Internal Error in getServiceInstance: " + ex.getMessage() -// //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) -// logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId) -// } -// } - //send request to get NSI service Info - End - //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))} - logger.debug( "*** Completed options Call to OOF ***") + private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { + if (!solutions.containsKey("sharedNSISolutions")) + { + logger.error("OOF don't return sharedNSISolutions") + return + } + String nsiName, nsiInstanceId, nssiId, nssiName + Map sliceProfile + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions")).get(0) + nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") + nsiName = sharedNSIsolution.getOrDefault("NSIName", "") + sliceTaskParams.setSuggestNsiId(nsiInstanceId) + sliceTaskParams.setSuggestNsiName(nsiName) + + //Temporary modification + List NSSIs = sharedNSIsolution.get("NSSIs") + if(NSSIs.size()==1){ + Map nssi = NSSIs.get(0) + nssiId = nssi.getOrDefault("NSSIId","") + nssiName = nssi.getOrDefault("NSSIName","") + sliceTaskParams.setCnSuggestNssiId(nssiId) + //TODO Need update after OOF return camel key and domainType + sliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + sliceTaskParams.setCnSuggestNssiName(nssiName) +// execution.setVariable("sliceProfileCn", sliceProfile) +// sliceTaskParams.setSliceProfileCn(sliceProfile) + } + logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") + logger.debug("OOF SliceProfile:"+sliceProfile.toString()) } - - public void parseServiceProfile(DelegateExecution execution) { + void parseServiceProfile(DelegateExecution execution) { logger.debug("Start parseServiceProfile") String serviceType = execution.getVariable("serviceType") Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") - + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") // set sliceProfile for three domains - Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) - Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) - Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) + if(!sliceTaskParams.getSliceProfileAn()){ + Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) + execution.setVariable("sliceProfileAn", sliceProfileAn) + sliceTaskParams.setSliceProfileAn(sliceProfileAn) + logger.debug("sliceProfileAn: " + sliceProfileAn) + } - execution.setVariable("sliceProfileTn", sliceProfileTn) - execution.setVariable("sliceProfileCn", sliceProfileCn) - execution.setVariable("sliceProfileAn", sliceProfileAn) - logger.debug("sliceProfileTn: " + sliceProfileTn) - logger.debug("sliceProfileCn: " + sliceProfileCn) - logger.debug("sliceProfileAn: " + sliceProfileAn) + if(!sliceTaskParams.getSliceProfileTn()){ + Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) + execution.setVariable("sliceProfileTn", sliceProfileTn) + sliceTaskParams.setSliceProfileTn(sliceProfileTn) + logger.debug("sliceProfileTn: " + sliceProfileTn) + } + + if(!sliceTaskParams.getSliceProfileCn()){ + Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) + execution.setVariable("sliceProfileCn", sliceProfileCn) + sliceTaskParams.setSliceProfileCn(sliceProfileCn) + logger.debug("sliceProfileCn: " + sliceProfileCn) + } logger.debug("Finish parseServiceProfile") } - public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) { - String variablePath = "nsmf." + serviceType + ".profileMap" + domain - String profileMapStr = UrnPropertiesReader.getVariable(variablePath) - logger.debug("Profile map for " + domain + " : " + profileMapStr) - Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){}) - Map<String, Object> sliceProfileTn = [:] + Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) { + String profileMapStr + Integer domainLatency = (Integer) serviceProfile.get("latency")/3 + + switch (domain) { + case "AN": + profileMapStr = """ { + "latency": ${domainLatency}, + "sNSSAI": "sNSSAI", + "uEMobilityLevel": "uEMobilityLevel", + "coverageAreaTAList": "coverageAreaTAList", + "5QI": 100 + } + """.trim().replaceAll(" ", "") + break + case "TN": + profileMapStr =""" { + "latency":${domainLatency}, + "sNSSAI":"sNSSAI", + "e2eLatency":"latency", + "bandwidth": 100 + } + """.trim().replaceAll(" ", "") + break + case "CN": + profileMapStr = """ { + "areaTrafficCapDL":"areaTrafficCapDL", + "maxNumberofUEs":"maxNumberofUEs", + "latency":${domainLatency}, + "expDataRateUL":"expDataRateUL", + "sNSSAI":"sNSSAI", + "areaTrafficCapUL":"areaTrafficCapUL", + "uEMobilityLevel":"uEMobilityLevel", + "expDataRateDL":"expDataRateDL", + "activityFactor":"activityFactor", + "resourceSharingLevel":"resourceSharingLevel" + } + """.trim().replaceAll(" ", "") + break + default: + break + } + + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){}) + Map<String, Object> sliceProfile = [:] for (Map.Entry<String, String> profileMap : profileMaps) { - sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value)) + String key = profileMap.key + String value = profileMaps.get(key) + if(serviceProfile.keySet().contains(value)){ + sliceProfile.put(key, serviceProfile.get(value)) + } + else{ + sliceProfile.put(key, profileMaps.get(key)) + } } - return sliceProfileTn + return sliceProfile } + void processDecomposition(DelegateExecution execution){ + logger.debug("Start processDecomposition") - void prepareNSSIList(DelegateExecution execution) - { ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") - List<String> nssiAssociated = new ArrayList<>() - Map<String, String> nssimap = new HashMap<>() - String nsiInstanceId=execution.getVariable("nsiInstanceId") - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String serviceType = execution.getVariable("subscriptionServiceType") - - try { - - ServiceInstance si = execution.getVariable("nsiServiceInstance") - //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation -> - // relation.getRelatedTo().equalsIgnoreCase("service-instance")) - RelationshipList relationshipList = si.getRelationshipList() - List<Relationship> relationships = relationshipList.getRelationship() - for(Relationship relationship in relationships) - { - if(relationship.getRelatedTo().equalsIgnoreCase("service-instance")) - { - String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1); - if(!NSSIassociated.equals(nsiInstanceId)) - nssiAssociated.add(NSSIassociated) - } - } - }catch(BpmnError e) { - throw e - }catch(Exception ex) { - String msg = "Internal Error in getServiceInstance: " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - Map<String, Object> params = execution.getVariable("params") SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") - for(String nssiID in nssiAssociated) - { - try { - AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID) - AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) - Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) - org.onap.aai.domain.yang.ServiceInstance nssi = si.get() - - String domain = nssi.getEnvironmentContext().toString().toUpperCase() - switch (domain) { - case "AN": - sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) - sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) - break; - case "CN": - sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) - sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) - break; - case "TN": - sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) - sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) - break; - default: - break; - } - }catch(NotFoundException e) - { - logger.debug("NSSI Service Instance not found in AAI: " + nssiID) - }catch(Exception e) - { - logger.debug("NSSI Service Instance not found in AAI: " + nssiID) - } - - } String nstName = serviceDecomposition.getModelInfo().getModelName() - sliceTaskParams.setNstName(nstName) String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstName(nstName) sliceTaskParams.setNstId(nstId) - execution.setVariable("sliceTaskParams",sliceTaskParams) + logger.debug("End processDecomposition") } - void updateOptionsInDB(DelegateExecution execution) { - logger.debug("Updating options with default value since not sharable : Begin ") - String taskID = execution.getVariable("taskID") - String params = execution.getVariable("params") - logger.debug("Updating options with default value since not sharable : End ") - - } - void prepareNSTDecompose(DelegateExecution execution) { String modelUuid = execution.getVariable("nstModelUuid") @@ -364,14 +360,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - void updateStatusInDB(DelegateExecution execution) { - - String taskID = execution.getVariable("taskID") - //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID); - //orchestrationTask.setTaskStage("wait to confirm") - //requestsDbClient.updateNetworkSliceOption(orchestrationTask) - } - void prepareNSSTlistfromNST(DelegateExecution execution) { //Need to update this part from decomposition. logger.trace("Enter prepareNSSTlistfromNST()") @@ -400,7 +388,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - void getNSSTOption(DelegateExecution execution) { ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) @@ -483,17 +470,17 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ case "AN": sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break case "CN": sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break case "TN": sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break default: - break; + break } }catch(NotFoundException e) { @@ -503,22 +490,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) } } - - - //Prepare send request to OOF - End - -// String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() -// String nsstID = jsonUtil.getJsonValue(content, "metadata.id") -// String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") -// String domain = jsonUtil.getJsonValue(content, "metadata.domainType") -// String type = jsonUtil.getJsonValue(content, "metadata.type") -// String nsstContentInfo = """{ -// "NsstID":"${nsstID}", -// "Vendor":"${vendor}", -// "type":"${type}" -// }""" - logger.debug("Prepare NSSI option completed ") } } - diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 9a584224ff..488f2d85ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -22,14 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.logging.filter.base.ErrorCode - import static org.apache.commons.lang3.StringUtils.* - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType; +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 +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -41,13 +42,11 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.db.catalog.beans.HomingInstance +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.aaiclient.client.aai.AAIObjectType; -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 /** * This class supports the DoCreateVnf building block subflow @@ -286,8 +285,8 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { if(resourceClient.exists(uri)){ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("globalCustomerId", keys.get("global-customer-id")) - execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("globalCustomerId", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) }else{ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index e6f6af5ab7..4be6ca7e49 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -31,15 +31,14 @@ import org.onap.so.beans.nsmf.NssiDeAllocateRequest import org.onap.so.beans.nsmf.NssiResponse import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ServiceArtifact import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType -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 import org.onap.so.db.request.beans.OperationStatus @@ -56,6 +55,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() private RequestDBUtil requestDBUtil = new RequestDBUtil() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class) @Override @@ -103,7 +104,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * get vendor Info * @param execution */ - void processDecomposition(DelegateExecution execution) { + void processDecomposition(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start processDecomposition *****") try { @@ -150,26 +151,21 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor deAllocateRequest.setEsrInfo(getEsrInfo(currentNSSI)) ObjectMapper mapper = new ObjectMapper() - String json = mapper.writeValueAsString(deAllocateRequest) - - //Prepare auth for NSSMF - Begin - String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId) - //nssmfRequest = nssmfRequest + String.format(NssmfAdapterUtil.NSSMI_DEALLOCATE_URL,profileId) - //send request to active NSSI TN option - URL url = new URL(nssmfRequest) - LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}") - - HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(json) - checkNssmfResponse(httpResponse, execution) - - NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class) - currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" - currentNSSI['jobProgress'] = 0 - execution.setVariable("currentNSSI", currentNSSI) - - LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") + String nssmfRequest = mapper.writeValueAsString(deAllocateRequest) + + String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId) + + NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) + if (nssmfResponse != null) { + currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" + currentNSSI['jobProgress'] = 0 + execution.setVariable("currentNSSI", currentNSSI) + + LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + } + } /** @@ -189,48 +185,36 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor jobStatusRequest.setEsrInfo(getEsrInfo(currentNSSI)) ObjectMapper mapper = new ObjectMapper() - String json = mapper.writeValueAsString(jobStatusRequest) - - //Prepare auth for NSSMF - Begin - String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/jobs/%s",jobId) - //send request to active NSSI TN option - URL url = new URL(nssmfRequest) - LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}") - - HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(json) - checkNssmfResponse(httpResponse, execution) - - JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class) - def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress() - if(!progress) - { - LOGGER.error("job progress is null or empty!") - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.") - } - int oldProgress = currentNSSI['jobProgress'] - int currentProgress = progress + String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) - execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) - execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) - currentNSSI['jobProgress'] = currentProgress + String urlStr = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) - def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() - currentNSSI['statusDescription'] = statusDescription + JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, JobStatusResponse.class) - LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) - } + if (jobStatusResponse != null) { + def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress() + if(!progress) + { + LOGGER.error("job progress is null or empty!") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.") + } + int oldProgress = currentNSSI['jobProgress'] + int currentProgress = progress + + execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) + execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) + currentNSSI['jobProgress'] = currentProgress - private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) { - int responseCode = httpResponse.getStatus() - LOGGER.debug("NSSMF response code is: " + responseCode) + def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() + currentNSSI['statusDescription'] = statusDescription - if ( responseCode < 200 || responseCode > 204 || !httpResponse.hasEntity()) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.") + LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) + + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - } + } private EsrInfo getEsrInfo(def currentNSSI) { @@ -305,4 +289,4 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 51be632f47..bee9ad260b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -22,10 +22,19 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network +import org.onap.aaiclient.client.aai.AAIObjectType +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.graphinventory.entities.uri.Depth +import org.onap.logging.filter.base.ErrorCode +import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,23 +47,13 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.aaiclient.client.aai.AAIObjectType -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.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - import org.springframework.web.util.UriUtils -import org.onap.logging.filter.base.ONAPComponents; - import groovy.json.JsonOutput -import javax.ws.rs.core.Response public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoDeleteNetworkInstance.class); @@ -276,7 +275,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) for(AAIResourceUri tenantURI: tenantURIList){ if(execution.getVariable(Prefix + "tenantId") == null) { - String tenantId = tenantURI.getURIKeys().get("tenant-id") + String tenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable(Prefix + "tenantId", tenantId) logger.debug(" Get AAI getTenantId() : " + tenantId) } @@ -284,7 +283,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) for(AAIResourceUri tenantURI: cloudRegionURIList){ if(execution.getVariable(Prefix + "lcpCloudRegion") == null) { - String lcpCloudRegion = tenantURI.getURIKeys().get("cloud-region-id") + String lcpCloudRegion = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId) execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) logger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index a55381b295..cda7c321ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -23,11 +23,15 @@ package org.onap.so.bpmn.infrastructure.scripts import static org.apache.commons.lang3.StringUtils.*; - -import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -35,17 +39,10 @@ import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils; -import groovy.json.* - /** * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process. * @@ -294,7 +291,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("GENGS_FoundIndicator", true) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) Map<String, String> keys = uri.getURIKeys() - String globalSubscriberId = execution.getVariable("globalSubscriberId") + String globalSubscriberId = execution.getVariable(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId) if(isBlank(globalSubscriberId)){ globalSubscriberId = keys.get("global-customer-id") execution.setVariable("globalSubscriberId", globalSubscriberId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index db90cd0d7b..355b5f77c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -22,12 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.apache.commons.lang3.StringUtils +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.Relationship -import org.onap.aai.domain.yang.RelationshipData import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +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.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -35,15 +39,9 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -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.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleVolumeV2.class); @@ -180,7 +178,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") } for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)){ - volumeGroupTenantId = aaiResourceUri.getURIKeys().get("tenant-id") + volumeGroupTenantId = aaiResourceUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy index 5acc016c7b..a85f5d8ab3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy @@ -25,17 +25,13 @@ import com.google.gson.Gson import com.google.gson.reflect.TypeToken import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.* import org.onap.so.bpmn.common.scripts.* -import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.ServiceArtifact import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum @@ -43,7 +39,6 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils -import javax.ws.rs.core.Response import java.lang.reflect.Type /** @@ -60,7 +55,8 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - OofInfraUtils oofInfraUtils = new OofInfraUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) /** * This method gets and validates the incoming @@ -99,7 +95,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { execution.setVariable("msoRequestId", requestId) String operationType = execution.getVariable("operationType") - execution.setVariable("operationType", operationType) + execution.setVariable("operationType", operationType.toLowerCase()) logger.debug("Incoming operationType is: " + operationType) if (operationType == "activation") { @@ -123,6 +119,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process") } + private String mapToJsonStr(Map<String, NSSI> stringNSSIHashMap) { HashMap<String, NSSI> map = new HashMap<String, NSSI>() for(Map.Entry<String, NSSI> child:stringNSSIHashMap.entrySet()) @@ -131,6 +128,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } return new Gson().toJson(map) } + public void getNSSIformlist(DelegateExecution execution) { String nssiMap = execution.getVariable("DonssiMap") @@ -179,6 +177,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { execution.setVariable("activationIndex", indexcurrent)} } + /** * get vendor Info * @param execution @@ -204,6 +203,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } logger.debug("***** Exit processDecomposition *****") } + public void UpdateIndex(DelegateExecution execution) { def activationIndex = execution.getVariable("activationIndex") int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer @@ -225,7 +225,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { String operationId = UUID.randomUUID().toString() String operationType = execution.getVariable("operationType") String userId = "" - String result = (operationType.equals("activation"))? "ACTIVATING": "DEACTIVATING" + String result = (operationType.equalsIgnoreCase("activation"))? "ACTIVATING": "DEACTIVATING" int progress = rate String reason = "" String operationContent = "Service activation in progress" @@ -269,24 +269,25 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } logger.trace("finished Activate Slice") } + public void WaitForReturn(DelegateExecution execution) { //logger.debug("Query : "+ Jobid) - def miniute=execution.getVariable("miniute") + String miniute = execution.getVariable("miniute") Thread.sleep(10000) int miniute01 = Integer.parseInt(miniute) + 1 logger.debug("waiting for : "+ miniute + "miniutes") execution.setVariable("miniute", String.valueOf(miniute01)) } + public void GetTheStatusOfActivation(DelegateExecution execution) { - String snssai= execution.getVariable("snssai") String domaintype = execution.getVariable("domainType") String NSIserviceid=execution.getVariable("NSIserviceid") String nssiId = execution.getVariable("nssiId") String Jobid=execution.getVariable("JobId") - def miniute=execution.getVariable("miniute") + String miniute=execution.getVariable("miniute") String vendor = execution.getVariable("vendor") - String jobstatus ="error" + String jobstatus logger.debug("Query the jobid activation of SNSSAI: "+ Jobid) @@ -306,66 +307,46 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { ObjectMapper mapper = new ObjectMapper() - String Reqjson = mapper.writeValueAsString(jobStatusRequest) - String isActivateSuccessfull=false - - String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) - String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/jobs/" +Jobid - - //send request to active NSSI TN option - URL url = new URL(nssmfRequest) - - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(Reqjson) - - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF activation response code is: " + responseCode) - - if (responseCode == 404) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") - isActivateSuccessfull = false - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - jobstatus="error" - }else if(responseCode == 200) { - if (httpResponse.hasEntity()) { - JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class) - execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription()) - jobstatus = jobStatusResponse.getResponseDescriptor().getStatus() - switch(jobstatus) { - case "started": - case "processing": - isActivateSuccessfull = "waitting" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - break - case "finished": - isActivateSuccessfull = "true" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1) - break - case "error": - default: - isActivateSuccessfull = "false" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - - } - if(Integer.parseInt(miniute) > 6 ) - { - isActivateSuccessfull = "false" - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a timeout job status Response from NSSMF.") - } - }else - { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") - isActivateSuccessfull = false - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - } - } else { - isActivateSuccessfull = false - execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") - } + String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) + String isActivateSuccessfull + + String urlString = "/api/rest/provMns/v1/NSS/jobs/" +Jobid + + JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, JobStatusResponse.class) + + if (jobStatusResponse != null) { + execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription()) + jobstatus = jobStatusResponse.getResponseDescriptor().getStatus() + switch(jobstatus) { + case "started": + case "processing": + isActivateSuccessfull = "waitting" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + break + case "finished": + isActivateSuccessfull = "true" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1) + break + case "error": + default: + isActivateSuccessfull = "false" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + + } + if(Integer.parseInt(miniute) > 6 ) + { + isActivateSuccessfull = "false" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a timeout job status Response from NSSMF.") + } + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad job status Response from NSSMF.") + isActivateSuccessfull = false + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + } } + public void SendCommandToNssmf(DelegateExecution execution) { String snssai= execution.getVariable("snssai") @@ -391,49 +372,28 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { actRequest.setActDeActNssi(actNssi); actRequest.setEsrInfo(esr) - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(actRequest); - - - String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + ObjectMapper mapper = new ObjectMapper() + String nssmfRequest = mapper.writeValueAsString(actRequest) - //Prepare auth for NSSMF - Begin - def authHeader = "" - String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) String operationType = execution.getVariable("operationType") - String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType - - //send request to active NSSI TN option - URL url = new URL(nssmfRequest) + String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType.toLowerCase() - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(json) + NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, NssiResponse.class) - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF activate response code is: " + responseCode) - checkNssmfResponse(httpResponse, execution) - - NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class) - String jobId = nssmfResponse.getJobId() ?: "" - execution.setVariable("JobId", jobId) + if (nssmfResponse != null) { + String isNSSIActivated = "true" + execution.setVariable("isNSSIActivated", isNSSIActivated) + String jobId = nssmfResponse.getJobId() ?: "" + execution.setVariable("JobId", jobId) + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + String isNSSIActivated = "false" + execution.setVariable("isNSSIActivated", isNSSIActivated) + execution.setVariable("isNSSIActivate","false") + } } - private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) { - int responseCode = httpResponse.getStatus() - logger.debug("NSSMF response code is: " + responseCode) - - if ( responseCode < 200 || responseCode > 202 || !httpResponse.hasEntity()) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.") - String isNSSIActivated = "false" - execution.setVariable("isNSSIActivated", isNSSIActivated) - execution.setVariable("isNSSIActivate","false") - }else{ - String isNSSIActivated = "true" - execution.setVariable("isNSSIActivated", isNSSIActivated) - } - } - void sendSyncError (DelegateExecution execution) { logger.trace("start sendSyncError") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 868ed214be..cf7bb22442 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -22,12 +22,22 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory -import org.apache.commons.lang3.* +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,33 +48,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -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 -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory - -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource -import org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoUpdateNetworkInstance.bpmn</class> process. @@ -347,8 +334,8 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") }else{ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy index 89490ff620..0f15717b3c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy @@ -103,6 +103,7 @@ class HandleOrchestrationTask extends AbstractServiceTaskProcessor { task.setName(taskName) task.setStatus(taskStatus) task.setIsManual(isManual) + task.setCreatedTime(new Date()) task.setParams(paramJson) ObjectMapper objectMapper = new ObjectMapper() payload = objectMapper.writeValueAsString(task) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 3928747e17..148ab1898f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -22,28 +22,28 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang.StringUtils.isEmpty import org.apache.commons.collections.CollectionUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.common.scripts.VfModuleBase -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType 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.so.constants.Defaults +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.logging.filter.base.ErrorCode +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import static org.apache.commons.lang.StringUtils.isEmpty - class UpdateVfModuleVolume extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolume.class) @@ -196,7 +196,7 @@ class UpdateVfModuleVolume extends VfModuleBase { List<AAIResourceUri> resourceUriList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if(CollectionUtils.isNotEmpty(resourceUriList)){ AAIResourceUri tenantUri = resourceUriList.get(0) - String volumeGroupTenantId = tenantUri.getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) if( isEmpty(volumeGroupTenantId)){ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Could not find Tenant Id element in Volume Group with Volume Group Id" + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index a89ea5925b..b6873a19fe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -22,34 +22,33 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import groovy.json.JsonException -import groovy.json.JsonSlurper +import static org.apache.cxf.common.util.CollectionUtils.isEmpty +import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType -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.so.constants.Defaults -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - -import javax.ws.rs.core.UriBuilder - -import static org.apache.cxf.common.util.CollectionUtils.isEmpty +import groovy.json.JsonException +import groovy.json.JsonSlurper class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolumeInfraV1.class) @@ -217,7 +216,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { if (relationships.isPresent()) { List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if (!isEmpty(tenantURIList)) { - String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) logger.debug("Received Tenant Id {} from AAI for Volume Group with Volume Group Id {}, AIC Cloud Region ", volumeGroupTenantId, volumeGroupId, aicCloudRegion) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index c2da495bff..aa3512379a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -26,6 +26,12 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject +import org.onap.aaiclient.client.aai.* +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.appc.client.lcm.model.Action import org.onap.appc.client.lcm.model.ActionIdentifiers import org.onap.appc.client.lcm.model.Flags @@ -39,11 +45,6 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.* -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.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport import org.onap.so.logger.MessageEnum @@ -248,7 +249,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { for (AAIResourceUri j in vserverUris) { - String vserverId = j.getURIKeys().get('vserver-id') + String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId) String vserverJson = client.get(j).getJson() logger.debug("Retrieved vserverJson from AAI: {}", vserverJson) String vserverSelfLink = jsonUtils.getJsonValue(vserverJson, "vserver-selflink") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 8b67790ffc..dd1dae6edd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -21,9 +21,17 @@ */ package org.onap.so.bpmn.vcpe.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -31,19 +39,11 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.AAIObjectType -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 javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process. * @@ -220,7 +220,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { List<AAIResourceUri> vnfUris = relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF) for(AAIResourceUri u:vnfUris){ Map<String, String> keys = u.getURIKeys() - String vnfId = keys.get("vnf-id") + String vnfId = keys.get(AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId) relatedVnfIdList.add(vnfId) } List<AAIResourceUri> arUris = relationships.get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index 013e1b62c2..f27794a389 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> - <bpmn:process id="Process_0r5eb97" isExecutable="true"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wio50w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:process id="CreateSliceService" name="CreateSliceService" isExecutable="true"> <bpmn:startEvent id="StartEvent_1nbljfd" name="Create Slice Service Creation Flow"> <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> </bpmn:startEvent> @@ -369,6 +369,7 @@ css.sendSyncResponse(execution)</bpmn:script> <camunda:out source="rollbackData" target="rollbackData" /> <camunda:out source="rolledBack" target="rolledBack" /> <camunda:in source="allottedResourceId" target="allottedResourceId" /> + <camunda:in source="nstSolution" target="nstSolution" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1bevt3a</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mlrlbv</bpmn:outgoing> @@ -435,6 +436,10 @@ css.sendSyncResponse(execution)</bpmn:script> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> <camunda:in source="serviceType" target="serviceType" /> + <camunda:in source="nstSolution" target="nstSolution" /> + <camunda:out source="sliceProfileTn" target="sliceProfileTn" /> + <camunda:out source="sliceProfileCn" target="sliceProfileCn" /> + <camunda:out source="sliceProfileAn" target="sliceProfileAn" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1ey6m1e</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1aaozcg</bpmn:outgoing> @@ -457,7 +462,7 @@ css.updateAAIOrchStatus(execution)</bpmn:script> <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="Process_0r5eb97"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSliceService"> <bpmndi:BPMNShape id="StartEvent_1nbljfd_di" bpmnElement="StartEvent_1nbljfd"> <dc:Bounds x="178" y="103" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -802,4 +807,3 @@ css.updateAAIOrchStatus(execution)</bpmn:script> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn index 6d9df5240d..3024e39c4e 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSliceService.bpmn @@ -143,14 +143,15 @@ dss.prepareEndOperationStatus(execution)</bpmn:script> <bpmn:extensionElements> <camunda:connector> <camunda:inputOutput> - <camunda:inputParameter name="url">${CVFMI_dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="url">${dbAdapterEndpoint}</camunda:inputParameter> <camunda:inputParameter name="headers"> <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry> </camunda:map> </camunda:inputParameter> - <camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</camunda:inputParameter> + <camunda:inputParameter name="payload">${updateOperationStatus} +</camunda:inputParameter> <camunda:inputParameter name="method">POST</camunda:inputParameter> <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter> <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter> @@ -329,4 +330,4 @@ ex.processJavaException(execution)</bpmn:script> </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/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index 435f91921d..ad0732df4d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> <bpmn:process id="DoCreateSliceServiceOption" name="DoCreateSliceServiceOption" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent" name="createOption_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> </bpmn:startEvent> <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" /> - <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="ExclusiveGateway_0b9d9l0" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="Task_09nzhwk" /> <bpmn:scriptTask id="Task_09nzhwk" name="send request to OOF for NSI options" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1h5bw41</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1utpplq</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() @@ -20,48 +20,12 @@ dcso.getNSIOptionfromOOF(execution)</bpmn:script> def dcso = new DoCreateSliceServiceOption() dcso.preProcessRequest(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_0cq2q6g" sourceRef="finishNSCreate_Task" targetRef="ScriptTask_0j3wd2o" /> <bpmn:endEvent id="EndEvent_1x6k78c"> - <bpmn:incoming>SequenceFlow_01ak5x3</bpmn:incoming> <bpmn:incoming>SequenceFlow_1ap8kar</bpmn:incoming> <bpmn:incoming>SequenceFlow_0hnsycl</bpmn:incoming> </bpmn:endEvent> - <bpmn:scriptTask id="finishNSCreate_Task" name="prepare list of NSSI associated with NSI" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_15679e8</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0cq2q6g</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.prepareNSSIList(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:exclusiveGateway id="ExclusiveGateway_0b9d9l0" default="SequenceFlow_0ueeeca"> - <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1h5bw41</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_0ueeeca</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_1h5bw41" name="NSI Sharable" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="Task_09nzhwk"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSharable" ) == true)}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:scriptTask id="ScriptTask_1ehyrsg" name="update task status in request DB" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0ueeeca</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_0ojueqq</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.updateStatusInDB(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_0ueeeca" name="NSI Not Sharable" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="ScriptTask_1ehyrsg" /> - <bpmn:endEvent id="EndEvent_00n990e"> - <bpmn:incoming>SequenceFlow_0ojueqq</bpmn:incoming> - </bpmn:endEvent> - <bpmn:scriptTask id="ScriptTask_0j3wd2o" name="updated options in request DB" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0cq2q6g</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_01ak5x3</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.updateOptionsInDB(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_01ak5x3" sourceRef="ScriptTask_0j3wd2o" targetRef="EndEvent_1x6k78c" /> <bpmn:scriptTask id="ScriptTask_0kecvrc" name="prepare list of NSST associated with NST" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1614gtr</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0wy6oag</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0lt2cdo</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() @@ -76,7 +40,7 @@ dcso.getNSSTOption(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:exclusiveGateway id="ExclusiveGateway_1y1wzs9"> <bpmn:incoming>SequenceFlow_0lt2cdo</bpmn:incoming> - <bpmn:incoming>SequenceFlow_00gq7h2</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1r9n9ef</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ap8kar</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_0m2mr0o</bpmn:outgoing> </bpmn:exclusiveGateway> @@ -87,44 +51,7 @@ dcso.getNSSTOption(execution)</bpmn:script> <bpmn:sequenceFlow id="SequenceFlow_0m2mr0o" sourceRef="ExclusiveGateway_1y1wzs9" targetRef="ScriptTask_1e5ysya"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isMoreNSSTtoProcess" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:scriptTask id="ScriptTask_0ojz4lj" name="save NSI and NSSI options in DB" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_1r9n9ef</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_00gq7h2</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.updateOptionsInDB(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_1r9n9ef" sourceRef="ScriptTask_1mlytov" targetRef="ScriptTask_0ojz4lj" /> - <bpmn:sequenceFlow id="SequenceFlow_00gq7h2" sourceRef="ScriptTask_0ojz4lj" targetRef="ExclusiveGateway_1y1wzs9" /> - <bpmn:sequenceFlow id="SequenceFlow_0ojueqq" sourceRef="ScriptTask_1ehyrsg" targetRef="EndEvent_00n990e" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_1mdr1l2" default="SequenceFlow_1614gtr"> - <bpmn:incoming>SequenceFlow_041f5ne</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_15679e8</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1614gtr</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_15679e8" sourceRef="ExclusiveGateway_1mdr1l2" targetRef="finishNSCreate_Task"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> - </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_1614gtr" sourceRef="ExclusiveGateway_1mdr1l2" targetRef="ScriptTask_0kecvrc" /> - <bpmn:scriptTask id="ScriptTask_0uu3j3h" name="prepare NST decomposition" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0wy6oag</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1jnsyix</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.prepareNSTDecompose(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:callActivity id="CallActivity_1qs8xd5" name="Call Decompose Service" calledElement="DecomposeService"> - <bpmn:extensionElements> - <camunda:in source="msoRequestId" target="msoRequestId" /> - <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> - <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> - <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> - <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_1jnsyix</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_041f5ne</bpmn:outgoing> - </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_1r9n9ef" sourceRef="ScriptTask_1mlytov" targetRef="ExclusiveGateway_1y1wzs9" /> <bpmn:scriptTask id="ScriptTask_1e5ysya" name="prepare NSST decomposition" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_0m2mr0o</bpmn:incoming> <bpmn:outgoing>SequenceFlow_016vi3s</bpmn:outgoing> @@ -146,193 +73,163 @@ dcso.prepareNSSTDecompose(execution)</bpmn:script> <bpmn:outgoing>SequenceFlow_0a5f5y6</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_0a5f5y6" sourceRef="CallActivity_1rfnoe2" targetRef="ScriptTask_1mlytov" /> - <bpmn:sequenceFlow id="SequenceFlow_1utpplq" sourceRef="Task_09nzhwk" targetRef="ExclusiveGateway_1skfk7w" /> - <bpmn:sequenceFlow id="SequenceFlow_1jnsyix" sourceRef="ScriptTask_0uu3j3h" targetRef="CallActivity_1qs8xd5" /> - <bpmn:sequenceFlow id="SequenceFlow_041f5ne" sourceRef="CallActivity_1qs8xd5" targetRef="ExclusiveGateway_1mdr1l2" /> + <bpmn:sequenceFlow id="SequenceFlow_1utpplq" sourceRef="Task_09nzhwk" targetRef="ScriptTask_1umbyel" /> <bpmn:exclusiveGateway id="ExclusiveGateway_1skfk7w" default="SequenceFlow_0wy6oag"> - <bpmn:incoming>SequenceFlow_1utpplq</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0d774n5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0wy6oag</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_0hnsycl</bpmn:outgoing> </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_0wy6oag" sourceRef="ExclusiveGateway_1skfk7w" targetRef="ScriptTask_0uu3j3h" /> + <bpmn:sequenceFlow id="SequenceFlow_0wy6oag" sourceRef="ExclusiveGateway_1skfk7w" targetRef="ScriptTask_0kecvrc" /> <bpmn:sequenceFlow id="SequenceFlow_0hnsycl" sourceRef="ExclusiveGateway_1skfk7w" targetRef="EndEvent_1x6k78c"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_1umbyel" name="prepare NST decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1utpplq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0piifl1</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSTDecompose(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0piifl1" sourceRef="ScriptTask_1umbyel" targetRef="CallActivity_0ly8xiw" /> + <bpmn:callActivity id="CallActivity_0ly8xiw" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0piifl1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_086yszq</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_086yszq" sourceRef="CallActivity_0ly8xiw" targetRef="Task_1k2ypj0" /> + <bpmn:sequenceFlow id="SequenceFlow_0d774n5" sourceRef="Task_1k2ypj0" targetRef="ExclusiveGateway_1skfk7w" /> + <bpmn:scriptTask id="Task_1k2ypj0" name="Process Decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_086yszq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0d774n5</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> - <dc:Bounds x="175" y="187" width="36" height="36" /> + <dc:Bounds x="175" y="107" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="150" y="223" width="87" height="27" /> + <dc:Bounds x="151" y="143" width="86" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> - <di:waypoint x="211" y="205" /> - <di:waypoint x="251" y="205" /> - <di:waypoint x="251" y="205" /> - <di:waypoint x="293" y="205" /> + <di:waypoint x="211" y="125" /> + <di:waypoint x="251" y="125" /> + <di:waypoint x="251" y="125" /> + <di:waypoint x="293" y="125" /> <bpmndi:BPMNLabel> <dc:Bounds x="266" y="123" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> - <di:waypoint x="393" y="205" /> - <di:waypoint x="448" y="205" /> + <di:waypoint x="393" y="125" /> + <di:waypoint x="460" y="125" /> <bpmndi:BPMNLabel> <dc:Bounds x="436" y="108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> - <dc:Bounds x="594" y="165" width="100" height="80" /> + <dc:Bounds x="460" y="85" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> - <dc:Bounds x="293" y="165" width="100" height="80" /> + <dc:Bounds x="293" y="85" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0cq2q6g_di" bpmnElement="SequenceFlow_0cq2q6g"> - <di:waypoint x="1536" y="205" /> - <di:waypoint x="1592" y="205" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="556.5" y="574" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> - <dc:Bounds x="1813" y="187" width="36" height="36" /> + <dc:Bounds x="1813" y="107" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="412" y="617" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0xxyfku_di" bpmnElement="finishNSCreate_Task"> - <dc:Bounds x="1436" y="165" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0b9d9l0_di" bpmnElement="ExclusiveGateway_0b9d9l0" isMarkerVisible="true"> - <dc:Bounds x="448" y="180" width="50" height="50" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1h5bw41_di" bpmnElement="SequenceFlow_1h5bw41"> - <di:waypoint x="498" y="205" /> - <di:waypoint x="594" y="205" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="514" y="187" width="66" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1ehyrsg_di" bpmnElement="ScriptTask_1ehyrsg"> - <dc:Bounds x="602" y="-197" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0ueeeca_di" bpmnElement="SequenceFlow_0ueeeca"> - <di:waypoint x="473" y="180" /> - <di:waypoint x="473" y="-157" /> - <di:waypoint x="602" y="-157" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="415" y="14" width="86" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_00n990e_di" bpmnElement="EndEvent_00n990e"> - <dc:Bounds x="785" y="-175" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_0j3wd2o_di" bpmnElement="ScriptTask_0j3wd2o"> - <dc:Bounds x="1592" y="165" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_01ak5x3_di" bpmnElement="SequenceFlow_01ak5x3"> - <di:waypoint x="1692" y="205" /> - <di:waypoint x="1813" y="205" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0kecvrc_di" bpmnElement="ScriptTask_0kecvrc"> - <dc:Bounds x="1297" y="391" width="100" height="80" /> + <dc:Bounds x="1250" y="311" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1mlytov_di" bpmnElement="ScriptTask_1mlytov"> - <dc:Bounds x="1781" y="533" width="100" height="80" /> + <dc:Bounds x="1680" y="453" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1y1wzs9_di" bpmnElement="ExclusiveGateway_1y1wzs9" isMarkerVisible="true"> - <dc:Bounds x="1461" y="406" width="50" height="50" /> + <dc:Bounds x="1461" y="326" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> - <di:waypoint x="1486" y="406" /> - <di:waypoint x="1486" y="315" /> - <di:waypoint x="1831" y="315" /> - <di:waypoint x="1831" y="223" /> + <di:waypoint x="1486" y="326" /> + <di:waypoint x="1486" y="235" /> + <di:waypoint x="1831" y="235" /> + <di:waypoint x="1831" y="143" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> - <di:waypoint x="1397" y="431" /> - <di:waypoint x="1461" y="431" /> + <di:waypoint x="1350" y="351" /> + <di:waypoint x="1461" y="351" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> - <di:waypoint x="1511" y="431" /> - <di:waypoint x="1592" y="431" /> + <di:waypoint x="1511" y="351" /> + <di:waypoint x="1592" y="351" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0ojz4lj_di" bpmnElement="ScriptTask_0ojz4lj"> - <dc:Bounds x="1592" y="533" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> - <di:waypoint x="1781" y="573" /> - <di:waypoint x="1692" y="573" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_00gq7h2_di" bpmnElement="SequenceFlow_00gq7h2"> - <di:waypoint x="1592" y="573" /> - <di:waypoint x="1486" y="573" /> - <di:waypoint x="1486" y="456" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ojueqq_di" bpmnElement="SequenceFlow_0ojueqq"> - <di:waypoint x="702" y="-157" /> - <di:waypoint x="785" y="-157" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ExclusiveGateway_1mdr1l2_di" bpmnElement="ExclusiveGateway_1mdr1l2" isMarkerVisible="true"> - <dc:Bounds x="1322" y="180" width="50" height="50" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15679e8_di" bpmnElement="SequenceFlow_15679e8"> - <di:waypoint x="1372" y="205" /> - <di:waypoint x="1436" y="205" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1614gtr_di" bpmnElement="SequenceFlow_1614gtr"> - <di:waypoint x="1347" y="230" /> - <di:waypoint x="1347" y="391" /> + <di:waypoint x="1680" y="493" /> + <di:waypoint x="1486" y="493" /> + <di:waypoint x="1486" y="376" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0uu3j3h_di" bpmnElement="ScriptTask_0uu3j3h"> - <dc:Bounds x="967" y="165" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1qs8xd5_di" bpmnElement="CallActivity_1qs8xd5"> - <dc:Bounds x="1136" y="165" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1e5ysya_di" bpmnElement="ScriptTask_1e5ysya"> - <dc:Bounds x="1592" y="391" width="100" height="80" /> + <dc:Bounds x="1592" y="311" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> - <di:waypoint x="1692" y="431" /> - <di:waypoint x="1781" y="431" /> + <di:waypoint x="1692" y="351" /> + <di:waypoint x="1781" y="351" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1rfnoe2_di" bpmnElement="CallActivity_1rfnoe2"> - <dc:Bounds x="1781" y="391" width="100" height="80" /> + <dc:Bounds x="1781" y="311" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> - <di:waypoint x="1881" y="431" /> - <di:waypoint x="1968" y="431" /> - <di:waypoint x="1968" y="573" /> - <di:waypoint x="1881" y="573" /> + <di:waypoint x="1881" y="351" /> + <di:waypoint x="1968" y="351" /> + <di:waypoint x="1968" y="493" /> + <di:waypoint x="1780" y="493" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1utpplq_di" bpmnElement="SequenceFlow_1utpplq"> - <di:waypoint x="694" y="205" /> - <di:waypoint x="796" y="205" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1jnsyix_di" bpmnElement="SequenceFlow_1jnsyix"> - <di:waypoint x="1067" y="205" /> - <di:waypoint x="1136" y="205" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_041f5ne_di" bpmnElement="SequenceFlow_041f5ne"> - <di:waypoint x="1236" y="205" /> - <di:waypoint x="1322" y="205" /> + <di:waypoint x="560" y="125" /> + <di:waypoint x="620" y="125" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1skfk7w_di" bpmnElement="ExclusiveGateway_1skfk7w" isMarkerVisible="true"> - <dc:Bounds x="796" y="180" width="50" height="50" /> + <dc:Bounds x="1095" y="100" width="50" height="50" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> - <di:waypoint x="846" y="205" /> - <di:waypoint x="967" y="205" /> + <di:waypoint x="1120" y="150" /> + <di:waypoint x="1120" y="351" /> + <di:waypoint x="1250" y="351" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> - <di:waypoint x="821" y="180" /> - <di:waypoint x="821" y="90" /> - <di:waypoint x="1831" y="90" /> - <di:waypoint x="1831" y="187" /> + <di:waypoint x="1145" y="125" /> + <di:waypoint x="1813" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1umbyel_di" bpmnElement="ScriptTask_1umbyel"> + <dc:Bounds x="620" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0piifl1_di" bpmnElement="SequenceFlow_0piifl1"> + <di:waypoint x="720" y="125" /> + <di:waypoint x="780" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_0ly8xiw_di" bpmnElement="CallActivity_0ly8xiw"> + <dc:Bounds x="780" y="85" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_086yszq_di" bpmnElement="SequenceFlow_086yszq"> + <di:waypoint x="880" y="125" /> + <di:waypoint x="940" y="125" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0d774n5_di" bpmnElement="SequenceFlow_0d774n5"> + <di:waypoint x="1040" y="125" /> + <di:waypoint x="1095" y="125" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1895p18_di" bpmnElement="Task_1k2ypj0"> + <dc:Bounds x="940" y="85" 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-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index a55cd4c169..385b96c0f8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -321,8 +321,8 @@ public class AAICreateTasks { logger.debug("PlatformName is null in input. Skipping create platform..."); } else { List<String> platforms = splitCDL(platform.getPlatformName()); - platforms.stream().forEach( - platformName -> aaiNetworkResources.createPlatformAndConnectNetwork(platform, network)); + platforms.stream().forEach(platformName -> aaiNetworkResources + .createPlatformAndConnectNetwork(new Platform(platformName), network)); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index 2668357f63..b337564dab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -6,6 +6,11 @@ import java.util.List; import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.appc.client.lcm.model.Action; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; @@ -17,10 +22,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; @@ -186,7 +187,7 @@ public class AppcOrchestratorPreProcessor { ArrayList<String> vserverIds = new ArrayList<String>(); ArrayList<String> vserverSelfLinks = new ArrayList<String>(); for (AAIResourceUri j : vserverUris) { - String vserverId = j.getURIKeys().get("vserver-id"); + String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId); vserverIds.add(vserverId); Optional<Vserver> oVserver = aaiVnfResources.getVserver(j); if (oVserver.isPresent()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 52edacc29d..70edc375c4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -28,10 +28,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; import org.json.JSONObject; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.appc.client.lcm.model.Action; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -40,17 +45,13 @@ import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -257,7 +258,8 @@ public class AppcRunTasks { for (AAIResourceUri j : vserverUris) { if (j != null) { if (j.getURIKeys() != null) { - String vserverId = j.getURIKeys().get("vserver-id"); + String vserverId = + j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId); vserverIds.put(vserverId); } aaiVnfResources.getVserver(j).ifPresent((vserver) -> { 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 677100cfc1..b4eb97a187 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 @@ -48,6 +48,13 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.so.bpmn.common.BBConstants; import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -60,12 +67,6 @@ import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIEntityNotFoundException; @@ -94,9 +95,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.util.CollectionUtils; @Component public class WorkflowAction { @@ -1547,10 +1548,12 @@ public class WorkflowAction { Map<String, String> keys = bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId()); - throw new DuplicateNameException(SERVICE_INSTANCE, - String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, - keys.get("global-customer-id"), keys.get("service-type"), - si.getModelVersionId())); + throw new DuplicateNameException(SERVICE_INSTANCE, String.format( + NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, + keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId), + keys.get( + AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType), + si.getModelVersionId())); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 3f81e432e1..e317822a13 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -287,6 +287,9 @@ public class NetworkAdapterObjectMapper { for (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet subnet : subnets) { org.onap.so.openstack.beans.Subnet openstackSubnet = modelMapper.map(subnet, org.onap.so.openstack.beans.Subnet.class); + if (StringUtils.isEmpty(openstackSubnet.getGatewayIp())) { + openstackSubnet.setGatewayIp("NULL"); + } // update cidr value if (subnet.getNetworkStartAddress() != null && subnet.getCidrMask() != null) openstackSubnet diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index 4f1ad996dc..e84bfce389 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -455,6 +455,10 @@ public class TestDataSetup { modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter); network.setModelInfoNetwork(modelInfoNetwork); + Platform platform = new Platform(); + platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4"); + network.setPlatform(platform); + return network; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index cb1b9e5ffe..f09e792cf4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.TreeSet; +import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Rule; @@ -195,6 +196,30 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test + public void createPlatformNetworkTest() throws Exception { + doNothing().when(aaiNetworkResources).createPlatformAndConnectNetwork(network.getPlatform(), network); + aaiCreateTasks.createPlatformForNetwork(execution); + ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class); + ArgumentCaptor<L3Network> network = ArgumentCaptor.forClass(L3Network.class); + Mockito.verify(aaiNetworkResources, times(4)).createPlatformAndConnectNetwork(platformCaptor.capture(), + network.capture()); + + List<Platform> capturedPlatforms = platformCaptor.getAllValues(); + + String actual = capturedPlatforms.stream().map(item -> item.getPlatformName()).collect(Collectors.toList()) + .stream().sorted().collect(Collectors.joining(" ,")); + String expected = + Arrays.asList("testPlatformName", "testPlatformName2", "testPlatformName3", "testPlatformName4") + .stream().sorted().collect(Collectors.joining(" ,")); + + assertEquals(expected, actual); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName()))); + } + + @Test public void createLineOfBusinessTest() throws Exception { doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf); aaiCreateTasks.createLineOfBusiness(execution); 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 c1107a4df8..e24eaf0581 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 @@ -34,14 +34,14 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -77,6 +77,12 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -84,11 +90,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.client.orchestration.AAIEntityNotFoundException; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -2423,8 +2424,8 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances); Map<String, String> uriKeys = new HashMap<>(); - uriKeys.put("global-customer-id", "globalCustomerId"); - uriKeys.put("service-type", "serviceType"); + uriKeys.put(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId, "globalCustomerId"); + uriKeys.put(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType, "serviceType"); when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index ccd4376a10..7ff784815b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -176,6 +176,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup { public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException { org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet(); subnet.setSubnetId("subnetId"); + subnet.setGatewayIp("NULL"); subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>()); List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>(); @@ -397,5 +398,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup { assertEquals("192.168.0.0/16", subnets.get(0).getHostRoutes().get(0).getPrefix()); assertEquals("192.168.1.5/16", subnets.get(0).getHostRoutes().get(1).getPrefix()); + + assertEquals("NULL", subnets.get(1).getGatewayIp()); } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json index e9b25ff266..21df57108b 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json @@ -49,5 +49,30 @@ "next-hop": "192.168.1.1", "next-hop-type": null }] + }, { + "subnet-id" : "subnetId2", + "subnet-name" : "aSubnetName2", + "neutron-subnet-id" : null, + "network-start-address" : "192.168.1.2", + "cidr-mask" : "10", + "ip-version" : "4", + "orchestration-status" : "ACTIVE", + "dhcp-enabled" : true, + "dhcp-start" : "192.168.1.2", + "dhcp-end" : "192.168.1.16", + "subnet-role" : "", + "ip-assignment-direction" : "true", + "subnet-sequence" : null, + "host-routes": [{ + "host-route-id": "hrId1", + "route-prefix": "192.168.0.0/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }, { + "host-route-id": "hrId2", + "route-prefix": "192.168.1.5/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }] }] }
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java index bf881c0f19..f0857fc458 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParams.java @@ -87,6 +87,13 @@ public class SliceTaskParams implements Serializable { private String anStatusDescription; + public SliceTaskParams() { + this.serviceProfile = new HashMap<>(); + this.sliceProfileAn = new HashMap<>(); + this.sliceProfileCn = new HashMap<>(); + this.sliceProfileTn = new HashMap<>(); + } + public String getNstId() { return nstId; } diff --git a/common/src/main/java/org/onap/so/logging/tasks/AuditMDCSetup.java b/common/src/main/java/org/onap/so/logging/tasks/AuditMDCSetup.java index 8d98307a43..39d208b1dd 100644 --- a/common/src/main/java/org/onap/so/logging/tasks/AuditMDCSetup.java +++ b/common/src/main/java/org/onap/so/logging/tasks/AuditMDCSetup.java @@ -3,6 +3,7 @@ package org.onap.so.logging.tasks; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.UUID; import org.camunda.bpm.client.task.ExternalTask; import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.filter.base.ONAPComponents; @@ -30,6 +31,7 @@ public class AuditMDCSetup { MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName()); MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, ONAPComponents.OPENSTACK_ADAPTER.toString()); setResponseCode(ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, UUID.randomUUID().toString()); setElapsedTime(); mdcSetup.setServerFQDN(); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); @@ -53,5 +55,4 @@ public class AuditMDCSetup { MDC.remove(ONAPLogConstants.MDCs.ELAPSED_TIME); MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); } - } diff --git a/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPLoggingInInterceptor.java b/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPLoggingInInterceptor.java index d1f509f476..1e1c8a7de1 100644 --- a/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPLoggingInInterceptor.java +++ b/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPLoggingInInterceptor.java @@ -31,6 +31,7 @@ import org.apache.cxf.interceptor.Fault; import org.apache.cxf.message.Message; import org.apache.cxf.phase.Phase; import org.apache.cxf.transport.http.AbstractHTTPDestination; +import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +49,7 @@ public class SOAPLoggingInInterceptor extends AbstractSoapInterceptor { @Override public void handleMessage(SoapMessage message) throws Fault { try { - SOAPMDCSetup mdcSetup = new SOAPMDCSetup(); + MDCSetup mdcSetup = new MDCSetup(); Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS); HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST); request.getRemoteAddr(); @@ -59,8 +60,10 @@ public class SOAPLoggingInInterceptor extends AbstractSoapInterceptor { setMDCPartnerName(headers); mdcSetup.setServerFQDN(); mdcSetup.setClientIPAddress(request); - mdcSetup.setInstanceUUID(); + mdcSetup.setInstanceID(); mdcSetup.setEntryTimeStamp(); + mdcSetup.setLogTimestamp(); + mdcSetup.setElapsedTime(); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, "INPROGRESS"); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); } catch (Exception e) { diff --git a/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPMDCSetup.java b/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPMDCSetup.java deleted file mode 100644 index 8258ce6f99..0000000000 --- a/cxf-logging/src/main/java/org/onap/so/logging/cxf/interceptor/SOAPMDCSetup.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.logging.cxf.interceptor; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.UUID; -import javax.servlet.http.HttpServletRequest; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - - - -public class SOAPMDCSetup { - - protected static Logger logger = LoggerFactory.getLogger(SOAPMDCSetup.class); - - private static final String INSTANCE_UUID = UUID.randomUUID().toString(); - - public void setInstanceUUID() { - MDC.put(ONAPLogConstants.MDCs.INSTANCE_UUID, INSTANCE_UUID); - } - - public void setServerFQDN() { - String serverFQDN = ""; - InetAddress addr = null; - try { - addr = InetAddress.getLocalHost(); - serverFQDN = addr.toString(); - } catch (UnknownHostException e) { - logger.warn("Cannot Resolve Host Name"); - serverFQDN = ""; - } - MDC.put(ONAPLogConstants.MDCs.SERVER_FQDN, serverFQDN); - } - - public void setClientIPAddress(HttpServletRequest httpServletRequest) { - String remoteIpAddress = ""; - if (httpServletRequest != null) { - remoteIpAddress = httpServletRequest.getRemoteAddr(); - } - MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, remoteIpAddress); - } - - public void setEntryTimeStamp() { - MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, - ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); - } - - -} diff --git a/deployment-configs/src/main/resources/logger/logback-spring.xml b/deployment-configs/src/main/resources/logger/logback-spring.xml index 258382b834..bd9712ad87 100644 --- a/deployment-configs/src/main/resources/logger/logback-spring.xml +++ b/deployment-configs/src/main/resources/logger/logback-spring.xml @@ -52,7 +52,8 @@ <appender name="Audit" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> - <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>ENTRY</marker> <marker>EXIT</marker> </evaluator> <onMismatch>DENY</onMismatch> @@ -80,7 +81,8 @@ <appender name="Metric" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> - <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>INVOKE</marker> <marker>INVOKE-RETURN</marker> </evaluator> <onMismatch>DENY</onMismatch> diff --git a/docs/architecture/SO Internal Arc.pptx b/docs/architecture/SO Internal Arc.pptx Binary files differindex ee4b112b3b..3472b92a73 100644 --- a/docs/architecture/SO Internal Arc.pptx +++ b/docs/architecture/SO Internal Arc.pptx diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml index 39555f3f4a..8c7be3eb7e 100644 --- a/graph-inventory/aai-client/pom.xml +++ b/graph-inventory/aai-client/pom.xml @@ -72,7 +72,6 @@ <artifactItem> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema</artifactId> - <version>1.6.5</version> <outputDirectory>${project.build.directory}/swagger</outputDirectory> <includes>**/*.yaml</includes> </artifactItem> @@ -276,7 +275,6 @@ <dependency> <groupId>org.onap.aai.schema-service</groupId> <artifactId>aai-schema</artifactId> - <version>1.6.5</version> </dependency> <dependency> <groupId>com.jayway.jsonpath</groupId> diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java index 180a99e88b..d2b2300ee9 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectName.java @@ -1,23 +1,7 @@ package org.onap.aaiclient.client.aai; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; -import com.google.common.base.CaseFormat; -public class AAIObjectName implements GraphInventoryObjectName { +public interface AAIObjectName extends GraphInventoryObjectName { - private final String name; - - public AAIObjectName(String name) { - this.name = name; - } - - @Override - public String typeName() { - return name; - } - - @Override - public String typeName(CaseFormat format) { - return CaseFormat.LOWER_HYPHEN.to(format, this.name); - } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java index 0ddbb8fae5..ef43717b4f 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java @@ -32,7 +32,8 @@ public enum AAIVersion implements GraphInventoryVersion { V16("v16"), V17("v17"), V18("v18"), - V19("v19"); + V19("v19"), + V20("v20"); public static final AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1]; private final String value; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java index 9310933499..519e49335d 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentSingleType.java @@ -1,12 +1,25 @@ package org.onap.aaiclient.client.aai.entities.uri; +import org.onap.aaiclient.client.aai.AAIObjectName; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.graphinventory.GraphInventoryFluentType; +import com.google.common.base.CaseFormat; public interface AAIFluentSingleType extends GraphInventoryFluentType<AAIObjectType> { - public interface Info extends GraphInventoryFluentType.Info { + public interface Info extends GraphInventoryFluentType.Info, AAIObjectName { + public default String typeName() { + return this.getName(); + } + + public default String typeName(CaseFormat format) { + return CaseFormat.LOWER_HYPHEN.to(format, this.getName()); + } + + public interface UriParams extends GraphInventoryFluentType.Info.UriParams { + + } } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java index 94fa240244..5741bf36eb 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryFluentType.java @@ -4,6 +4,12 @@ public interface GraphInventoryFluentType<T> extends GraphInventoryFluentTypeBas public interface Info extends GraphInventoryFluentTypeBase.Info { String getName(); + + UriParams getUriParams(); + + public interface UriParams { + + } } T build(); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java index 829ef1d646..000521bdf6 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java @@ -24,10 +24,10 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; 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; public class AAIObjectTypeTest { - @Test public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException { AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource"); @@ -88,4 +88,27 @@ public class AAIObjectTypeTest { AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id); assertEquals("/network/network-policies/network-policy/test1", aaiUri.build().toString()); } + + @Test + public void equalityTest() { + + AAIObjectType genericVnf = AAIFluentTypeBuilder.network().genericVnf("test").build(); + + assertEquals(AAIObjectType.GENERIC_VNF, genericVnf); + + } + + @Test + public void uriParamTest() { + + assertEquals("vnf-id", AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId); + + assertEquals("l-interface.interface-name", AAIFluentTypeBuilder.Types.L_INTERFACE.getUriParams().interfaceName); + + assertEquals("cloud-owner", AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner); + + assertEquals("cloud-region-id", AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId); + + + } } diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java index f9c664389b..23a1a812df 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java @@ -8,6 +8,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Matcher; import java.util.stream.Collectors; import javax.lang.model.element.Modifier; import org.apache.commons.lang3.ArrayUtils; @@ -240,19 +241,17 @@ public class FluentGenerator { } protected TypeSpec createTypes() { - Pair<String, String> path = splitClasspath(this.nameClass); - ClassName nameType = ClassName.get(path.getLeft(), path.getRight()); - - List<FieldSpec> params = - doc.values().stream().filter(item -> item.getType().equals("singular")) - .sorted(Comparator - .comparing(item -> item.getName())) - .map(item -> FieldSpec - .builder(nameType, - CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, item.getName()), - Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) - .initializer("new $T($S)", nameType, item.getName()).build()) - .collect(Collectors.toList()); + List<FieldSpec> params = doc.values().stream().filter(item -> item.getType().equals("singular")) + .sorted(Comparator.comparing(item -> item.getName())).map(item -> { + ClassName nameType = + ClassName.get(CLASSPATH, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, item.getName())) + .nestedClass("Info"); + FieldSpec field = FieldSpec + .builder(nameType, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, item.getName()), + Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) + .initializer("new $T()", nameType).build(); + return field; + }).collect(Collectors.toList()); TypeSpec type = TypeSpec.classBuilder("Types").addModifiers(Modifier.PUBLIC, Modifier.FINAL, Modifier.STATIC) .addFields(params).build(); @@ -276,30 +275,71 @@ public class FluentGenerator { .build()); ClassName superInterface; + String name; if (oType.getType().equals("plural")) { - classFields.add(FieldSpec.builder(String.class, "name") - .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC) - .initializer("$S", oType.getAdditionalName()).build()); - superInterface = ClassName.get(this.pluralBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.pluralBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getAdditionalName(); } else if (oType.getType().equals("singular")) { - classFields.add(FieldSpec.builder(String.class, "name") - .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$S", oType.getName()) - .build()); - superInterface = ClassName.get(this.singularBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.singularBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getName(); } else { - superInterface = ClassName.get(this.topLevelBuilderClass, "Info"); + Pair<String, String> path = splitClasspath(this.topLevelBuilderClass); + superInterface = ClassName.get(path.getLeft(), path.getRight()); + name = oType.getName(); } + superInterface = superInterface.nestedClass("Info"); methods.add(MethodSpec.methodBuilder("getPaths").returns(ParameterizedTypeName.get(List.class, String.class)) .addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement("return Info.paths").build()); methods.add(MethodSpec.methodBuilder("getPartialUri").returns(String.class).addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class).addStatement("return Info.partialUri").build()); if (!oType.getType().equals("top level")) { + classFields.add(FieldSpec.builder(String.class, "name") + .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$S", name).build()); + classFields.add(FieldSpec.builder(ClassName.get("", "UriParams"), "uriParams") + .addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC) + .initializer("new $T()", ClassName.get("", "UriParams")).build()); methods.add(MethodSpec.methodBuilder("getName").returns(String.class).addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class).addStatement("return Info.name").build()); + + methods.add(MethodSpec.methodBuilder("getUriParams").returns(ClassName.get("", "UriParams")) + .addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement("return Info.uriParams") + .build()); + } + TypeSpec.Builder returnTypeSpec = TypeSpec.classBuilder("Info").addModifiers(Modifier.PUBLIC, Modifier.STATIC) + .addSuperinterface(superInterface).addFields(classFields).addMethods(methods); + if (!oType.getType().equals("top level")) { + returnTypeSpec.addType(createUriParamsClass(superInterface, oType)); + } + return returnTypeSpec.build(); + + } + + protected TypeSpec createUriParamsClass(ClassName parent, ObjectType oType) { + + List<FieldSpec> classFields = new ArrayList<>(); + Matcher params = Patterns.urlTemplatePattern.matcher(oType.getPartialUri()); + + while (params.find()) { + String value; + String name; + + if (params.group(2) != null) { + name = params.group(2); + } else { + name = params.group(1); + } + value = params.group(1); + + name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name); + + classFields.add(FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.FINAL) + .initializer("$S", value).build()); } - return TypeSpec.classBuilder("Info").addModifiers(Modifier.PUBLIC, Modifier.STATIC) - .addSuperinterface(superInterface).addFields(classFields).addMethods(methods).build(); + return TypeSpec.classBuilder("UriParams").addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) + .addFields(classFields).addSuperinterface(parent.nestedClass("UriParams")).build(); } protected String makeValidJavaVariable(String name) { diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java new file mode 100644 index 0000000000..8be22e1dcc --- /dev/null +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java @@ -0,0 +1,11 @@ +package org.onap.graphinventory.generate; + +import java.util.regex.Pattern; + +public class Patterns { + + public static final Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); + public static final Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); + public static final Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); + public static final Pattern urlTemplatePattern = Pattern.compile("\\{([^}.]+(?:\\.([^}]+))?)\\}"); +} diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java index b3ced65390..42305488bc 100644 --- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java +++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.maven.plugin.logging.Log; import com.fasterxml.jackson.core.JsonProcessingException; @@ -33,10 +32,6 @@ public class SwaggerConverter { .filter(item -> !item.getKey().endsWith("/relationship-list/relationship")) .collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue())); - Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))"); - Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)"); - Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*"); - Pattern urlTemplatePattern = Pattern.compile("\\{([^}]+)\\}"); Matcher pluralMatcher; Matcher singularMatcher; Matcher topLevelMatcher; @@ -44,9 +39,9 @@ public class SwaggerConverter { Map<String, ObjectType> output = new HashMap<>(); for (Map.Entry<String, Path> entry : paths.entrySet()) { - pluralMatcher = pluralPattern.matcher(entry.getKey()); - singularMatcher = singularPattern.matcher(entry.getKey()); - topLevelMatcher = topLevelPattern.matcher(entry.getKey()); + pluralMatcher = Patterns.pluralPattern.matcher(entry.getKey()); + singularMatcher = Patterns.singularPattern.matcher(entry.getKey()); + topLevelMatcher = Patterns.topLevelPattern.matcher(entry.getKey()); ObjectType item; if (pluralMatcher.matches()) { if (!output.containsKey(pluralMatcher.group("name"))) { @@ -158,7 +153,7 @@ public class SwaggerConverter { } if (!item.getValue().getFields().isEmpty()) { - Matcher templates = urlTemplatePattern.matcher(item.getValue().getPartialUri()); + Matcher templates = Patterns.urlTemplatePattern.matcher(item.getValue().getPartialUri()); List<String> localFields = new ArrayList<>(); while (templates.find()) { localFields.add(templates.group(1)); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java index 4517811494..65c850a785 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java @@ -65,7 +65,8 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) private CamundaInput serviceInstanceId; - + @JsonProperty(CommonConstants.OPERATION_TYPE) + private CamundaInput operationType; @JsonProperty(CommonConstants.PNF_CORRELATION_ID) private CamundaInput pnfCorrelationId; @@ -194,6 +195,16 @@ public class CamundaVIDRequest { this.serviceInstanceId = serviceInstanceId; } + @JsonProperty(CommonConstants.OPERATION_TYPE) + public CamundaInput getOperationType() { + return operationType; + } + + @JsonProperty(CommonConstants.OPERATION_TYPE) + public void setOperationType(CamundaInput operationType) { + this.operationType = operationType; + } + @JsonProperty(CommonConstants.PNF_CORRELATION_ID) public CamundaInput getPnfCorrelationId() { return pnfCorrelationId; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java index 33e4740740..4bbfa1d067 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java @@ -90,7 +90,8 @@ public class CamundaClient { parameterObject.getVnfType(), parameterObject.getVfModuleType(), parameterObject.getNetworkType(), parameterObject.getRequestDetails(), parameterObject.getApiVersion(), parameterObject.isaLaCarte(), parameterObject.getRequestUri(), parameterObject.getRecipeParamXsd(), - parameterObject.getInstanceGroupId(), parameterObject.isGenerateIdsOnly()); + parameterObject.getInstanceGroupId(), parameterObject.isGenerateIdsOnly(), + parameterObject.getOperationType()); return post(jsonReq, orchestrationURI); } @@ -167,7 +168,7 @@ public class CamundaClient { String serviceInstanceId, String pnfCorrelationId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, String serviceType, String vnfType, String vfModuleType, String networkType, String requestDetails, String apiVersion, boolean aLaCarte, String requestUri, - String paramXsd, String instanceGroupId, boolean generateIdsOnly) { + String paramXsd, String instanceGroupId, boolean generateIdsOnly, String operationType) { String jsonReq = null; try { @@ -179,6 +180,7 @@ public class CamundaClient { CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); CamundaInput requestActionInput = new CamundaInput(); CamundaInput serviceInstanceIdInput = new CamundaInput(); + CamundaInput operationTypeInput = new CamundaInput(); CamundaInput pnfCorrelationIdInput = new CamundaInput(); CamundaInput vnfIdInput = new CamundaInput(); CamundaInput vfModuleIdInput = new CamundaInput(); @@ -196,7 +198,7 @@ public class CamundaClient { CamundaInput instanceGroupIdInput = new CamundaInput(); CamundaBooleanInput generateIds = new CamundaBooleanInput(); - + operationTypeInput.setValue(StringUtils.defaultString(operationType)); requestIdInput.setValue(StringUtils.defaultString(requestId)); isBaseVfModuleInput.setValue(isBaseVfModule); recipeTimeoutInput.setValue(recipeTimeout); @@ -228,6 +230,7 @@ public class CamundaClient { camundaRequest.setRecipeTimeout(recipeTimeoutInput); camundaRequest.setRequestAction(requestActionInput); camundaRequest.setServiceInstanceId(serviceInstanceIdInput); + camundaRequest.setOperationType(operationTypeInput); camundaRequest.setPnfCorrelationId(pnfCorrelationIdInput); camundaRequest.setVnfId(vnfIdInput); camundaRequest.setVfModuleId(vfModuleIdInput); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java index 6d2bbfc613..d667126afa 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java @@ -54,6 +54,7 @@ public final class CommonConstants { public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; public static final String REQUEST_ACTION_VARIABLE = "requestAction"; public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; + public static final String OPERATION_TYPE = "operationType"; public static final String PNF_CORRELATION_ID = "pnfCorrelationId"; public static final String VNF_ID_VARIABLE = "vnfId"; public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java index e51f0e2412..e0f4fe3f7a 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java @@ -139,11 +139,12 @@ public class CamundaClientTest { boolean aLaCarte = true; String requestUri = "v7/serviceInstances/assign"; String instanceGroupId = "ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + String operationType = "activation"; String testResult = client.wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, pnfCorrelationId, vnfId, vfModuleId, volumeGroupId, networkId, configurationId, serviceType, vnfType, vfModuleType, networkType, requestDetails, apiVersion, aLaCarte, requestUri, "", - instanceGroupId, false); + instanceGroupId, false, operationType); String expected = inputStream("/WrappedVIDRequest.json"); JSONAssert.assertEquals(expected, testResult, false); diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json index 3353f8c7ce..6eebb5f703 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json +++ b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json @@ -95,6 +95,10 @@ "generateIdsOnly": { "value": false, "type": "Boolean" + }, + "operationType": { + "value": "activation", + "type": "String" } } } diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 3a7c7ad477..a046123778 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -300,7 +300,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java index 8b270f8d5a..e8046a2cd9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java @@ -29,11 +29,12 @@ import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; @@ -56,12 +57,6 @@ public class BpmnRequestBuilder { private static final String CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND = "Cloud Configuration could not be found"; - private static final String CLOUD_REGION_ID = "cloud-region-id"; - - private static final String CLOUD_OWNER = "cloud-owner"; - - private static final String TENANT_ID = "tenant-id"; - private static final String GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID = "Generic Vnf Not Found In Inventory, VnfId: "; @@ -283,11 +278,14 @@ public class BpmnRequestBuilder { String lcpRegionId = null; if (relationshipsOpt.isPresent()) { tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null); + .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) + .orElse(null); + cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) + .orElse(null); + lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) + .orElse(null); } if (tenantId == null || cloudOwner == null || lcpRegionId == null) { @@ -325,11 +323,14 @@ public class BpmnRequestBuilder { String lcpRegionId = null; if (relationshipsOpt.isPresent()) { tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() - .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null); + .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) + .orElse(null); + cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) + .orElse(null); + lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) + .orElse(null); } if (tenantId == null || cloudOwner == null || lcpRegionId == null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index f0943393ed..7aa6e0f831 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -108,7 +108,6 @@ public class SDCClientHelper { HttpClient httpClient = httpClientFactory.newJsonClient(url, ONAPComponents.SDC); httpClient.addBasicAuthHeader(sdcClientAuth, msoKey); httpClient.addAdditionalHeader("X-ECOMP-InstanceID", sdcActivateInstanceId); - httpClient.addAdditionalHeader("X-ECOMP-RequestID", UUID.randomUUID().toString()); httpClient.addAdditionalHeader("Content-Type", SDCClientHelper.SDC_CONTENT_TYPE); httpClient.addAdditionalHeader("Accept", SDCClientHelper.SDC_ACCEPT_TYPE); httpClient.addAdditionalHeader("USER_ID", sdcActivateUserId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 4a244a6a7b..d4c66f62e4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -26,8 +26,13 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.aai.domain.yang.OperationalEnvironment; +import org.onap.aaiclient.client.aai.AAIObjectType; +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.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.apihandler.common.ErrorNumbers; -import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -36,13 +41,9 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; -import org.onap.aaiclient.client.aai.AAIObjectType; -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.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; @@ -58,7 +59,6 @@ public class ActivateVnfOperationalEnvironment { private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; - private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; @Autowired private ActivateVnfDBHelper dbHelper; @@ -97,8 +97,8 @@ public class ActivateVnfOperationalEnvironment { List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); if (!operationalEnvironments.isEmpty()) { - ecompOperationalEnvironmentId = - operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); + ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get( + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId); } } logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId); @@ -123,7 +123,8 @@ public class ActivateVnfOperationalEnvironment { .build(); throw new ValidateException.Builder( " The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " - + OPER_ENVIRONMENT_ID_KEY, + + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT + .getUriParams().operationalEnvironmentId, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) .build(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 143c92861a..ef90b22b01 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -1389,7 +1390,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException { wireMockServer.stubFor( - get(urlPathEqualTo("/aai/v19/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000")) + get(urlPathMatching("/aai/v\\d+/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK))); wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image index 031142f216..e3eb954e1e 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -8,7 +8,7 @@ ENV http_proxy=$HTTP_PROXY ENV https_proxy=$HTTPS_PROXY # Install commonly needed tools -RUN apk --no-cache add curl netcat-openbsd nss +RUN apk --no-cache add curl netcat-openbsd nss apache2-utils # Create 'so' user RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so @@ -71,7 +71,7 @@ <camunda.springboot.version>3.2.0</camunda.springboot.version> <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> - <io.fabric8.version>4.1.0</io.fabric8.version> + <io.fabric8.version>0.33.0</io.fabric8.version> <appc.client.version>1.7.1</appc.client.version> </properties> <distributionManagement> @@ -212,17 +212,9 @@ </resource> </resources> <plugins> - <!-- <plugin> - <groupId>org.sonatype.plugins</groupId> - <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.7</version> - <extensions>true</extensions> - <configuration> - <nexusUrl>${nexusproxy}</nexusUrl> - <stagingProfileId>176c31dfe190a</stagingProfileId> - <serverId>ecomp-staging</serverId> - </configuration> - </plugin> --> + <!-- <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.7</version> + <extensions>true</extensions> <configuration> <nexusUrl>${nexusproxy}</nexusUrl> <stagingProfileId>176c31dfe190a</stagingProfileId> + <serverId>ecomp-staging</serverId> </configuration> </plugin> --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> @@ -544,7 +536,7 @@ <plugins> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <version>${io.fabric8.version}</version> <configuration> <skip>${docker.skip}</skip> @@ -831,17 +823,17 @@ <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-slf4j</artifactId> - <version>1.6.6</version> + <version>1.6.7-SNAPSHOT</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-base</artifactId> - <version>1.6.6</version> + <version>1.6.7-SNAPSHOT</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-spring</artifactId> - <version>1.6.6</version> + <version>1.6.7-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> @@ -915,6 +907,11 @@ <artifactId>json</artifactId> <version>20140107</version> </dependency> + <dependency> + <groupId>org.onap.aai.schema-service</groupId> + <artifactId>aai-schema</artifactId> + <version>1.7.1-SNAPSHOT</version> + </dependency> </dependencies> </dependencyManagement> <profiles> @@ -923,7 +920,6 @@ <properties> <docker.skip>false</docker.skip> <docker.skip.build>false</docker.skip.build> - <fabric8.skipResourceValidation>true</fabric8.skipResourceValidation> </properties> </profile> <profile> @@ -932,7 +928,6 @@ <docker.skip>false</docker.skip> <docker.skip.build>false</docker.skip.build> <docker.skip.push>false</docker.skip.push> - <fabric8.skipResourceValidation>true</fabric8.skipResourceValidation> </properties> </profile> <profile> diff --git a/so-simulator/pom.xml b/so-simulator/pom.xml index 7e996510ef..a92664afb8 100644 --- a/so-simulator/pom.xml +++ b/so-simulator/pom.xml @@ -98,7 +98,7 @@ </plugin> <plugin> <groupId>io.fabric8</groupId> - <artifactId>fabric8-maven-plugin</artifactId> + <artifactId>docker-maven-plugin</artifactId> <executions> <execution> <id>start</id> |