diff options
38 files changed, 1589 insertions, 301 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml index f97c1b8c56..fdbc76dea7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml @@ -1,6 +1,6 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.so.adapters</groupId> @@ -120,5 +120,10 @@ <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.23</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java new file mode 100644 index 0000000000..db34cbf3f2 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import org.slf4j.Logger; +import java.util.ArrayList; +import java.util.Collection; +import static org.slf4j.LoggerFactory.getLogger; + +public class NvfmAdapterUtils { + private static Logger logger = getLogger(NvfmAdapterUtils.class); + + public static JsonObject child(JsonObject parent, String name) { + return childElement(parent, name).getAsJsonObject(); + } + + public static JsonElement childElement(JsonObject parent, String name) { + JsonElement child = parent.get(name); + if (child == null) { + throw abortOperation("Missing child " + name); + } + return child; + } + + public static Collection<JsonObject> children(JsonObject parent) { + ArrayList<JsonObject> childElements = new ArrayList<>(); + for (String childKey : parent.keySet()) { + if (parent.get(childKey).isJsonObject()) { + childElements.add(parent.get(childKey).getAsJsonObject()); + } + } + return childElements; + } + + public static RuntimeException abortOperation(String msg, Exception e) { + logger.error(msg, e); + return new RuntimeException(msg, e); + } + + public static RuntimeException abortOperation(String msg) { + logger.error(msg); + return new RuntimeException(msg); + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java index 2d80d558de..30ce0c2253 100755 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java @@ -20,11 +20,11 @@ package org.onap.so.adapters.vnfmadapter; -import static org.slf4j.LoggerFactory.getLogger; import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController; import org.slf4j.Logger; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import static org.slf4j.LoggerFactory.getLogger; /** * The spring boot application for the VNFM (Virtual Network Function Manager) Adapter. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java new file mode 100644 index 0000000000..045b98007d --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.extclients; + +import com.google.common.io.ByteStreams; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.onap.so.utils.CryptoUtils; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.yaml.snakeyaml.Yaml; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import static com.google.common.base.Splitter.on; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.io.ByteStreams.toByteArray; +import static java.lang.String.format; +import static org.apache.http.HttpHeaders.ACCEPT; +import static org.apache.http.HttpHeaders.AUTHORIZATION; +import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.*; +import static org.slf4j.LoggerFactory.getLogger; +import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE; + + +@Component +public class SdcPackageProvider { + private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel"; + @Value("sdc.toscametapath:TOSCA-Metadata/TOSCA.meta") + private List<String> toscaMetaPaths; + private final String TOSCA_VNFD_KEY = "Entry-Definitions"; + private static Logger logger = getLogger(SdcPackageProvider.class); + + @Value("${sdc.username}") + private String sdcUsername; + @Value("${sdc.password}") + private String sdcPassword; + @Value("${sdc.key}") + private String sdcKey; + @Value("${sdc.endpoint}") + private String baseUrl; + + + public String getVnfdId(String csarId) { + return getVnfNodeProperty(csarId, "descriptor_id"); + } + + private String getVnfNodeProperty(final String csarId, final String propertyName) { + logger.debug("Getting " + propertyName + " from " + csarId); + final byte[] onapPackage = getPackage(csarId); + + try { + final String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(onapPackage)); + final String onapVnfdContent = getFileInZip(new ByteArrayInputStream(onapPackage), vnfdLocation).toString(); + final JsonObject root = new Gson().toJsonTree(new Yaml().load(onapVnfdContent)).getAsJsonObject(); + + final JsonObject topologyTemplates = child(root, "topology_template"); + final JsonObject nodeTemplates = child(topologyTemplates, "node_templates"); + for (final JsonObject child : children(nodeTemplates)) { + final String type = childElement(child, "type").getAsString(); + String propertyValue = null; + if (type.equals("tosca.nodes.nfv.VNF")) { + final JsonObject properties = child(child, "properties"); + logger.debug("properties: " + properties.toString()); + + propertyValue = properties.get(propertyName).getAsJsonPrimitive().getAsString(); + } + if (propertyValue == null) { + propertyValue = getValueFromNodeTypeDefinition(root, type, propertyName); + } + return propertyValue; + } + + } catch (final Exception e) { + throw new IllegalArgumentException("Unable to extract " + propertyName + " from ONAP package", e); + } + throw new IllegalArgumentException("Unable to extract " + propertyName + " from ONAP package"); + } + + private String getValueFromNodeTypeDefinition(final JsonObject root, final String nodeTypeName, + final String propertyName) { + final JsonObject nodeTypes = child(root, "node_types"); + final JsonObject nodeType = child(nodeTypes, nodeTypeName); + + if (childElement(nodeType, "derived_from").getAsString().equals("tosca.nodes.nfv.VNF")) { + final JsonObject properties = child(nodeType, "properties"); + logger.debug("properties: " + properties.toString()); + final JsonObject property = child(properties, propertyName); + logger.debug("property: " + property.toString()); + logger.debug("property default: " + childElement(property, "default").toString()); + return childElement(property, "default").getAsJsonPrimitive().getAsString(); + } + return null; + } + + private byte[] getPackage(String csarId) { + final String SERVICE_NAME = "vnfm-adapter"; + try { + CloseableHttpClient client = HttpClients.createDefault(); + HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId)); + httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE); + httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME); + httpget.setHeader("X-FromAppId", SERVICE_NAME); + String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey); + byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); + String authHeader = "Basic " + new String(encodedAuth); + httpget.setHeader(AUTHORIZATION, authHeader); + logger.debug("Fetching from SDC: " + httpget); + CloseableHttpResponse response = client.execute(httpget); + HttpEntity entity = response.getEntity(); + InputStream is = entity.getContent(); + byte[] bytes = toByteArray(is); + client.close(); + return bytes; + } catch (Exception e) { + throw abortOperation("Unable to download " + csarId + " package from SDC", e); + } + } + + private String getVnfdLocation(InputStream stream) throws IOException { + Iterator pathIterator = toscaMetaPaths.iterator(); + while (pathIterator.hasNext()) { + String toscaMetadata = new String(getFileInZip(stream, pathIterator.next().toString()).toByteArray()); + if (!toscaMetadata.isEmpty()) { + String toscaVnfdLine = + filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next(); + return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim(); + } + } + throw abortOperation("Unable to find valid Tosca Path"); + } + + private static ByteArrayOutputStream getFileInZip(InputStream zip, String path) throws IOException { + ZipInputStream zipInputStream = new ZipInputStream(zip); + ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path); + zipInputStream.close(); + return fileContent; + } + + private static ByteArrayOutputStream getFileInZip(ZipInputStream zipInputStream, String path) throws IOException { + ZipEntry zipEntry; + Set<String> items = new HashSet<>(); + while ((zipEntry = zipInputStream.getNextEntry()) != null) { + items.add(zipEntry.getName()); + if (zipEntry.getName().matches(path)) { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ByteStreams.copy(zipInputStream, byteArrayOutputStream); + return byteArrayOutputStream; + } + } + logger.error("Unable to find the {} in archive found: {}", path, items); + throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items); + } + + + public String getFlavourId(String csarId) { + return getVnfNodeProperty(csarId, "flavour_id"); + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java index b9ffd8bac5..88b8ba8ef0 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java @@ -20,18 +20,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.EsrVnfmList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Relationship; -import org.onap.aai.domain.yang.RelationshipData; -import org.onap.aai.domain.yang.RelationshipList; -import org.onap.aai.domain.yang.Vserver; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; import org.onap.so.adapters.vnfmadapter.rest.exceptions.TenantNotFoundException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; @@ -43,6 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * Provides helper methods for interactions with AAI. @@ -72,7 +64,6 @@ public class AaiHelper { final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList(); vnfmRelationshiplist.getRelationship().add(createRelationshipToVnfm(vnfmId)); - aaiServiceProvider.invokePutGenericVnf(vnf); } private Relationship createRelationshipToVnfm(final String vnfmId) { @@ -237,4 +228,28 @@ public class AaiHelper { public OamIpAddressSource getOamIpAddressSource(final String vnfId) { return mapOfVnfIdToOamIpAddressHolder.get(vnfId); } + + /** + * Add a relationship to the given tenant to the given VNF. + * + * @param vnf the generic vnf + * @param tenant the Tenant + */ + + public void addRelationshipFromGenericVnfToTenant(final GenericVnf vnf, final Tenant tenant) { + if (vnf.getRelationshipList() == null) { + vnf.setRelationshipList(new RelationshipList()); + } + final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList(); + vnfmRelationshiplist.getRelationship().add(createRelationshipToTenant(tenant)); + } + + private Relationship createRelationshipToTenant(final Tenant tenant) { + final Relationship relationship = new Relationship(); + relationship.setRelatedTo("tenant"); + relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, + tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString()); + relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId())); + return relationship; + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java index ea12c5a265..cfaad3fd04 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java @@ -20,12 +20,12 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai; -import java.net.MalformedURLException; -import java.net.URL; import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; +import java.net.MalformedURLException; +import java.net.URL; public class AaiPropertiesImpl implements AAIProperties { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java index 2708742e6a..807f3bdb9d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java @@ -20,13 +20,9 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai; -import java.util.List; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.EsrVnfmList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Vserver; +import org.onap.aai.domain.yang.*; import org.onap.vnfmadapter.v1.model.Tenant; +import java.util.List; /** * Provides methods for invoking REST calls to AAI. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java index 55a2cc39ec..4346114e34 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java @@ -20,12 +20,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai; -import java.util.List; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.EsrVnfmList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Vserver; +import org.onap.aai.domain.yang.*; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.vnfmadapter.v1.model.Tenant; @@ -33,6 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; @Service public class AaiServiceProviderImpl implements AaiServiceProvider { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java index 54b4055276..311c4de8bd 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.extclients.aai; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; - /** * Represents the source of the value to use as the AAI OAM IP address of a VNF */ diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java index b370dc35c8..70567d8631 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java @@ -20,27 +20,19 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.InterfaceInfo; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.VimCredentials; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo; import org.onap.so.security.WebSecurityConfig; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.ExternalVirtualLink; @@ -50,10 +42,11 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; +import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; /** * Provides helper methods for interactions with VNFM. @@ -81,10 +74,10 @@ public class VnfmHelper { * @param tenant the tenant the request is to be fulfilled on * @param createVnfRequest the request received by the VNFM adapter */ - public InstantiateVnfRequest createInstantiateRequest(final Tenant tenant, - final CreateVnfRequest createVnfRequest) { + public InstantiateVnfRequest createInstantiateRequest(final Tenant tenant, final CreateVnfRequest createVnfRequest, + final String flavourId) { final InstantiateVnfRequest instantiateVnfRequest = new InstantiateVnfRequest(); - instantiateVnfRequest.setFlavourId(getFlavourId()); + instantiateVnfRequest.setFlavourId(flavourId); instantiateVnfRequest.setVimConnectionInfo(getVimConnectionInfos(tenant)); instantiateVnfRequest .setAdditionalParams(getAdditionalParametersAsJsonObject(createVnfRequest.getAdditionalParams())); @@ -170,7 +163,6 @@ public class VnfmHelper { * Create a {@link LccnSubscriptionRequest} to send in an notification subscription request to a VNFM. * * @param the ID of the VNF notifications are required for - * * @return the request */ public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId) { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java index 472a8b8680..d061dd05c3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java @@ -21,12 +21,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; import com.google.common.base.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; /** * Provides methods for invoking REST calls to a VNFM. @@ -86,4 +81,13 @@ public interface VnfmServiceProvider { */ Optional<InlineResponse200> getOperation(final String vnfmId, final String operationId); + /** + * Invoke a create request to a VNFM + * + * @param vnfmId the id of the VNFM in AAI + * @param createVnfRequest the parameters for creating a VNF + * @return the newly created VNF + */ + Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest); + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java index 88008c6a3f..164f12ea29 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.util.Iterator; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; @@ -34,6 +32,8 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestTemplate; +import java.util.Iterator; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; /** * Configures the HttpRestServiceProvider for REST call to a VNFM. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java index 104e2d11ac..b096f51cb0 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java @@ -21,12 +21,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; import com.google.common.base.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; @@ -142,4 +137,17 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { return httpServiceProvider.get(url, InlineResponse200.class); } + @Override + public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) { + final String url = urlProvider.getCreationUrl(vnfmId); + try { + return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class); + } catch (final Exception exception) { + final String errorMessage = + "Create request to vnfm:" + vnfmId + " resulted in exception" + createVnfRequest; + logger.error(errorMessage, exception); + throw new VnfmRequestFailureException(errorMessage, exception); + } + } + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java index 2eaaa8113f..d4aa65d159 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; -import static org.slf4j.LoggerFactory.getLogger; -import java.net.URI; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; @@ -30,6 +28,8 @@ import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.util.UriComponentsBuilder; +import java.net.URI; +import static org.slf4j.LoggerFactory.getLogger; /** * Provides URLs for REST calls to a VNFM. @@ -68,7 +68,15 @@ public class VnfmUrlProvider { public String getSubscriptionsUrl(final String vnfmId) { final String url = UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/subscriptions").build().toString(); - logger.debug("getOperationUrl:" + url); + logger.debug("getSubscriptionUrl:" + url); + + return url; + } + + public String getCreationUrl(final String vnfmId) { + final String url = + UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/vnf_instances").build().toString(); + logger.debug("getCreationUrl:" + url); return url; } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java index 7034b7f5ee..e61bf860b3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java @@ -20,11 +20,8 @@ package org.onap.so.adapters.vnfmadapter.jobmanagement; -import static org.slf4j.LoggerFactory.getLogger; import com.google.common.base.Optional; import com.google.common.collect.Maps; -import java.util.Map; -import java.util.UUID; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException; @@ -35,6 +32,9 @@ import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Map; +import java.util.UUID; +import static org.slf4j.LoggerFactory.getLogger; /** * Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java index 7085218c0b..e6b787bacc 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java @@ -21,9 +21,9 @@ package org.onap.so.adapters.vnfmadapter.lifecycle; import com.google.common.base.Optional; -import java.util.Map; import org.onap.aai.domain.yang.EsrVnfm; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; @@ -38,6 +38,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfReques import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfNotFoundException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.CreateVnfResponse; import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; @@ -45,6 +46,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Map; /** * Manages lifecycle operations towards the VNFMs. @@ -57,15 +59,18 @@ public class LifecycleManager { private final AaiHelper aaiHelper; private final VnfmHelper vnfmHelper; private final JobManager jobManager; + private final SdcPackageProvider packageProvider; @Autowired LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper, - final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager) { + final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager, + SdcPackageProvider packageProvider) { this.aaiServiceProvider = aaiServiceProvider; this.vnfmServiceProvider = vnfmServiceProvider; this.aaiHelper = aaiHelper; this.vnfmHelper = vnfmHelper; this.jobManager = jobManager; + this.packageProvider = packageProvider; } /** @@ -84,8 +89,11 @@ public class LifecycleManager { vnfm = aaiHelper.selectVnfm(genericVnf); aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId()); } - - final String vnfIdInVnfm = sendCreateRequestToVnfm(genericVnf); + aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant()); + InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId()); + genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref()); + aaiServiceProvider.invokePutGenericVnf(genericVnf); + final String vnfIdInVnfm = vnfmResponse.getId(); final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request); aaiHelper.setOamIpAddressSource(vnfIdInVnfm, oamIpAddressSource); @@ -127,10 +135,26 @@ public class LifecycleManager { } } - private String sendCreateRequestToVnfm(final GenericVnf genericVnf) { - // TODO call create request - genericVnf.setSelflink("http://dummy.value/until/create/implememted/vnfId"); - return "vnfId"; + private InlineResponse201 sendCreateRequestToVnfm(CreateVnfRequest aaiRequest, GenericVnf genericVnf, + String vnfIdInAai, String vnfmId) { + logger.debug("Sending a create request to SVNFM " + aaiRequest); + org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest = + new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest(); + + String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId()); + vnfmRequest.setVnfdId(vnfdId); + vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_")); + vnfmRequest.setVnfInstanceDescription(vnfIdInAai); + + Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest); + + try { + return optionalResponse.get(); + } catch (final Exception exception) { + final String errorMessage = "Unable to return response from VNFM"; + logger.error(errorMessage, exception); + throw new VnfmRequestFailureException(errorMessage, exception); + } } private void createNotificationSubscription(final String vnfmId, final String vnfId) { @@ -148,7 +172,8 @@ public class LifecycleManager { final CreateVnfRequest createVnfRequest, final String vnfIdInAai, final String vnfIdInVnfm) { final InstantiateVnfRequest instantiateVnfRequest = - vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest); + vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest, + packageProvider.getFlavourId(genericVnf.getModelVersionId())); final String jobId = vnfmServiceProvider.instantiateVnf(genericVnf.getSelflink(), instantiateVnfRequest); logger.info("Instantiate VNF request successfully sent to " + genericVnf.getSelflink()); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java index 506eb8db0e..a339b9be70 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java @@ -20,10 +20,6 @@ package org.onap.so.adapters.vnfmadapter.notificationhandling; -import static org.slf4j.LoggerFactory.getLogger; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.json.JSONException; import org.json.JSONObject; import org.onap.aai.domain.yang.GenericVnf; @@ -40,6 +36,10 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo; import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; import org.slf4j.Logger; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.slf4j.LoggerFactory.getLogger; /** * Performs updates to AAI based on a received notification. The updates are executed in a separate thread so as the diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java index 82e72a7630..a16c3fb5cc 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java @@ -20,19 +20,10 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.*; import org.onap.vnfmadapter.v1.model.Tenant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,11 +31,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.*; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; @Controller @RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java index 0441342b79..9cb09e6261 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java @@ -20,12 +20,6 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; -import static org.slf4j.LoggerFactory.getLogger; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; @@ -45,6 +39,12 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import javax.ws.rs.core.MediaType; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; +import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; +import static org.slf4j.LoggerFactory.getLogger; /** * Controller for handling notifications from the VNFM (Virtual Network Function Manager). diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java index 875d3350bc..1cf00da499 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java @@ -20,9 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import javax.validation.Valid; -import javax.ws.rs.core.MediaType; +import io.swagger.annotations.ApiParam; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; import org.onap.so.adapters.vnfmadapter.lifecycle.LifecycleManager; @@ -37,14 +35,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; +import javax.ws.rs.core.MediaType; +import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; /** * Controller for handling requests to the VNFM (Virtual Network Function Manager) adapter REST API. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml index bbe13152fc..4fb110349d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml @@ -14,16 +14,22 @@ server: port: 9092 tomcat: - max-threads: 50 - + max-threads: 50 + mso: key: 07a7159d3bf51a0e53be7a8f89699be7 - + aai: auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 version: v15 endpoint: https://aai.onap:8443 +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + #Actuator management: endpoints: diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java index c25d8257d8..07c471ec87 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import java.net.URI; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; @@ -33,6 +31,8 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import java.net.URI; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java index 21c6eff6b0..7e87e669e2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java @@ -20,24 +20,14 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.util.Optional; +import com.google.gson.Gson; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.hamcrest.MockitoHamcrest; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Relationship; -import org.onap.aai.domain.yang.RelationshipData; -import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum; @@ -59,7 +49,12 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; -import com.google.gson.Gson; +import java.util.Optional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java index aa089e1348..363780dcc5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java @@ -20,25 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.inject.Inject; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -54,13 +36,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationComputeResource; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierCreationNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; @@ -82,6 +59,17 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import javax.inject.Inject; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java index c69b483592..39572c73cd 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java @@ -20,21 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.util.Optional; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -42,28 +28,16 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.hamcrest.MockitoHamcrest; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.EsrVnfmList; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Relationship; -import org.onap.aai.domain.yang.RelationshipData; -import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; -import org.onap.vnfmadapter.v1.model.OperationEnum; -import org.onap.vnfmadapter.v1.model.OperationStateEnum; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.vnfmadapter.v1.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -82,6 +56,16 @@ import org.springframework.web.client.RestTemplate; import org.threeten.bp.LocalDateTime; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.ZoneOffset; +import java.net.URI; +import java.util.Optional; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @@ -107,6 +91,9 @@ public class VnfmAdapterControllerTest { @MockBean AAIResourcesClient aaiResourcesClient; + @MockBean + SdcPackageProvider sdcPackageProvider; + @Autowired VnfmAdapterController controller; Gson gson = new Gson(); @@ -128,11 +115,16 @@ public class VnfmAdapterControllerTest { final String expectedsubscriptionRequest = "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke\"}}}"; final InlineResponse2001 subscriptionResponse = new InlineResponse2001(); + + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")) .andExpect(content().json(expectedsubscriptionRequest)) .andRespond(withSuccess(gson.toJson(subscriptionResponse), MediaType.APPLICATION_JSON)); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -163,12 +155,20 @@ public class VnfmAdapterControllerTest { assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", uriArgument.getValue().build().toString()); assertEquals("myTestVnfId", genericVnfArgument.getValue().getVnfId()); - assertEquals(1, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); - final Relationship createdRelationship = + assertEquals(2, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); + final Relationship vnfmRelationship = genericVnfArgument.getValue().getRelationshipList().getRelationship().get(0); - assertEquals("esr-vnfm", createdRelationship.getRelatedTo()); - assertEquals("tosca.relationships.DependsOn", createdRelationship.getRelationshipLabel()); - assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", createdRelationship.getRelatedLink()); + assertEquals("esr-vnfm", vnfmRelationship.getRelatedTo()); + assertEquals("tosca.relationships.DependsOn", vnfmRelationship.getRelationshipLabel()); + assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", vnfmRelationship.getRelatedLink()); + + final Relationship tenantRelationship = + genericVnfArgument.getValue().getRelationshipList().getRelationship().get(1); + assertEquals("tenant", tenantRelationship.getRelatedTo()); + assertEquals( + "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/myTestCloudOwner/myTestRegion/tenants/tenant/myTestTenantId", + tenantRelationship.getRelatedLink()); + // check the job status @@ -223,9 +223,13 @@ public class VnfmAdapterControllerTest { setUpVnfmsInMockAai(); setUpVimInMockAai(); + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")).andRespond(withBadRequest()); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -469,6 +473,19 @@ public class VnfmAdapterControllerTest { + CLOUD_OWNER + "/" + REGION + "/esr-system-info-list"))); } + private InlineResponse201 createCreateResponse() { + final InlineResponse201 createResponse = new InlineResponse201(); + createResponse.setVnfdId("myTestVnfd"); + final InlineResponse201Links links = new InlineResponse201Links(); + final InlineResponse201LinksSelf self = new InlineResponse201LinksSelf(); + self.setHref("http://vnfm2:8080/vnf_instances/vnfId"); + links.setSelf(self); + createResponse.setLinks(links); + createResponse.setId("vnfId"); + return createResponse; + } + + private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { final String uriAsString; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml index e69e90173d..3afc542a1b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml @@ -14,20 +14,27 @@ spring: security: usercredentials: - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPEL-Client - - username: vnfm - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - + - username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - username: vnfm + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + mso: key: 07a7159d3bf51a0e53be7a8f89699be7 - + aai: auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 endpoint: https://aai.onap:8443 version: v15 - + +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + + vnfmadapter: - endpoint: https://so-vnfm-adapter.onap:30406
\ No newline at end of file + endpoint: https://so-vnfm-adapter.onap:30406 diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy new file mode 100644 index 0000000000..a1f68f9b06 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy @@ -0,0 +1,270 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * 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 org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory +/** + * This groovy class supports the <class>DoCompareServiceInstanceData.bpmn</class> process. + * + * Inputs: + * @param - serviceInstanceData-original + * @param - serviceInstanceId + * @param - uuiRequest + * @param - model-invariant-id-original + * @param - model-version-id-original + * @param - msoRequestId + * @param - isDebugLogEnabled + * + * Outputs: + * @param - addResourceList + * @param - delResourceList + * @param - uuiRequest-add + * @param - uuiRequest-del + * + */ +public class DoCompareServiceInstanceData extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger( DoCompareServiceInstanceData.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO"," ***** preProcessRequest *****", isDebugEnabled) + try { + checkInput("serviceInstanceData-original", execution, isDebugEnabled) + checkInput("serviceInstanceId", execution, isDebugEnabled) + checkInput("uuiRequest", execution, isDebugEnabled) + checkInput("model-invariant-id-original", execution, isDebugEnabled) + checkInput("model-version-id-original", execution, isDebugEnabled) + checkInput("msoRequestId", execution, isDebugEnabled) + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.info("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + private void checkInput(String inputName, DelegateExecution execution, isDebugEnabled) { + String msg + Object inputValue = execution.getVariable(inputName) + if (inputValue == null) { + msg = "Input" + inputName + "is null" + logger.info("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + + public void prepareDecomposeService_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + logger.debug( " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ") + String modelInvariantUuid = execution.getVariable("model-invariant-id-original") + String modelUuid = execution.getVariable("model-version-id-original") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + + execution.setVariable("serviceModelInfo_Original", serviceModelInfo) + + logger.debug( " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + logger.debug( " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ") + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecomposition_Original", serviceDecomposition) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage() + logger.debug( exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doCompareUuiRquestInput(DelegateExecution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + logger.info("INFO", "======== Start doCompareUuiRquestInput Process ======== ", isDebugEnabled) + + String uuiRequest_Target = execution.getVariable("uuiRequest") + Map<String, Object> serviceParametersObject_Target = getServiceParametersObject(uuiRequest_Target) + Map<String, Object> serviceRequestInputs_Target = (Map<String, Object>) serviceParametersObject_Target.get("requestInputs") + List<Object> resources_Target = (List<Object>) serviceParametersObject_Target.get("resources") + + String uuiRequest_Original = ((ServiceInstance) execution.getVariable("serviceInstanceData-original")).getInputParameters() + Map<String, Object> serviceParametersObject_Original = getServiceParametersObject(uuiRequest_Original) + Map<String, Object> serviceRequestInputs_Original = (Map<String, Object>) serviceParametersObject_Original.get("requestInputs") + List<Object> resources_Original = (List<Object>) serviceParametersObject_Original.get("resources") + + logger.info("INFO", "uuiRequest is: " + uuiRequest_Target, isDebugEnabled) + + //the resources which are included by resources_Target but resources_Original are the resources going to be added + ArrayList<Object> resourceList_Add = findResourceListIncluded(resources_Target, resources_Original) + HashMap<String, Object> serviceRequestInputs_Add = getServiceRequestInputsIncluded(resourceList_Add, serviceRequestInputs_Target, serviceParametersObject_Target) + String uuiRequest_add = loadUuiRequestJsonString(uuiRequest_Target, resourceList_Add, serviceRequestInputs_Add) + execution.setVariable("uuiRequest", uuiRequest_add) + logger.info("INFO", "uuiRequest will be changed to: " + uuiRequest_add, isDebugEnabled) + + //the resources which are included by resources_Original but resources_Target are the resources going to be deleted + ArrayList<Object> resourceList_Del = findResourceListIncluded(resources_Original, resources_Target) + HashMap<String, Object> serviceRequestInputs_Del = getServiceRequestInputsIncluded(resourceList_Del, serviceRequestInputs_Original, serviceParametersObject_Original) + String uuiRequest_del = loadUuiRequestJsonString(uuiRequest_Original, resourceList_Del, serviceRequestInputs_Del) + execution.setVariable("uuiRequest-del", uuiRequest_del) + logger.info("INFO", "uuiRequest-del: " + uuiRequest_del, isDebugEnabled) + + List<Resource> addResourceList = findResourceList(resourceList_Add, execution) + execution.setVariable("addResourceList", addResourceList) + logger.info("INFO", "addResourceList: " + addResourceList, isDebugEnabled) + + List<Resource> delResourceList = findResourceList(resourceList_Del, execution) + execution.setVariable("delResourceList", delResourceList) + logger.info("INFO", "delResourceList: " + delResourceList, isDebugEnabled) + + logger.info("INFO", "======== COMPLETED doCompareUuiRquestInput Process ======== ", isDebugEnabled) + } + + private List<Resource> findResourceList(ArrayList<Object> uuiResourceList, DelegateExecution execution) { + HashSet<String> addResourceCustomizationUuidSet = getCustomizationUuidSet(uuiResourceList) + Set<Resource> resourceSet = new HashSet<>() + ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") + List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources() + for (Resource resource : allSR_original) { + if (addResourceCustomizationUuidSet.contains(resource.getModelInfo().getModelCustomizationUuid())) { + resourceSet.add(resource) + } + } + List<Resource> resourceList = new ArrayList<String>(resourceSet) + resourceList + } + + private HashSet<String> getCustomizationUuidSet(ArrayList<Object> resourceList_Add) { + Set<String> addRsourceCustomizationUuidSet = new HashSet<>() + for (Map<String, Object> resourceAdded : resourceList_Add) { + addRsourceCustomizationUuidSet.add(resourceAdded.get("rsourceCustomizationUuid")) + } + addRsourceCustomizationUuidSet + } + + private String loadUuiRequestJsonString(String uuiRequest_Target, ArrayList<Object> resourceList_Add, HashMap<String, Object> serviceRequestInputs_Add) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters") + serviceParametersObject.put("resources", resourceList_Add) + serviceParametersObject.put("requestInputs", serviceRequestInputs_Add) + String uuiRequest_add = ServicePluginFactory.getInstance().getJsonString(serviceObject) + uuiRequest_add + } + + private HashMap<String, Object> getServiceRequestInputsIncluded(ArrayList<Object> resourceList_Add, Map<String, Object> serviceRequestInputs_Target, Map<String, Object> serviceParametersObject_Target) { + ArrayList<String> newResourceNames = getNewResourceNames(resourceList_Add) + Map<String, Object> serviceRequestInputs_Add = new HashMap<String, Object>() + for (String inputKey : serviceRequestInputs_Target.keySet()) { + String resourceName = (inputKey.split("_"))[0] + if (newResourceNames.contains(resourceName)) { + serviceRequestInputs_Add.put(inputKey, serviceParametersObject_Target.get(inputKey)) + } + } + serviceRequestInputs_Add + } + + private ArrayList<String> getNewResourceNames(ArrayList<Object> addResourceList) { + Set<String> newResourceNames = new ArrayList<String>() + for (Object resourceObject : addResourceList) { + Map<String, Object> resourceAdded = (Map<String, Object>) resourceObject + String resName = new String(resourceAdded.get("resourceName")) + normalizeName(resName) + newResourceNames.add(resName) + } + newResourceNames + } + + private void normalizeName(String resName) { + resName.replaceAll("_", "") + resName.replaceAll(" ", "") + resName.toLowerCase() + } + + private ArrayList<Object> findResourceListIncluded(List<Object> resources_Target, List<Object> resources_Original) { + List<Object> addResourceList = new ArrayList<Object>() + for (Object resource_Target : resources_Target) { + Map<String, Object> resourceObject_Target = (Map<String, Object>) resource_Target + boolean isNewResourceInstance = isNewResourceInstance(resourceObject_Target, resources_Original) + if (isNewResourceInstance) { + addResourceList.add(resource_Target) + } + } + addResourceList + } + + private boolean isNewResourceInstance(Map<String, Object> resourceObject_Target, List<Object> resources_Original) { + String resourceIndex_Target = null + if (resourceObject_Target.keySet().contains("resourceIndex")) { + resourceIndex_Target = resourceObject_Target.get("resourceIndex") + } + String resourceName_Target = resourceObject_Target.get("resourceName") + boolean isNewResourceInstance = true + for (Object resource_Original : resources_Original) { + Map<String, Object> resourceObject_Original = (Map<String, Object>) resource_Original + String resourceIndex_Original = null + if (resourceObject_Original.keySet().contains("resourceIndex")) { + resourceIndex_Original = resourceObject_Original.get("resourceIndex") + } + String resourceName_Original = resourceObject_Original.get("resourceName") + if (resourceName_Target.equals(resourceName_Original)) { + if (resourceIndex_Target != null && resourceIndex_Original != null) { + if (resourceIndex_Target.equals(resourceIndex_Original)) { + isNewResourceInstance = false + } + } else { + isNewResourceInstance = false + } + } + } + isNewResourceInstance + } + + private Map<String, Object> getServiceParametersObject(String uuiRequest_Target) { + Map<String, Object> uuiObject = ServicePluginFactory.getInstance().getJsonObject(uuiRequest_Target, Map.class) + Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service") + Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters") + serviceParametersObject + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy index 1168b20220..8e554e286d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -189,6 +189,7 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor JSONObject ob = new JSONObject(wrapper.getJson()) JSONArray ar = ob.getJSONObject("relationship-list").getJSONArray("relationship") + execution.setVariable("serviceInstanceData-original", si.get()) execution.setVariable("serviceRelationShip", ar.toString()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java new file mode 100644 index 0000000000..267ddbf6a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/PnfNotificationEvent.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf; + +import org.springframework.context.ApplicationEvent; + +public class PnfNotificationEvent extends ApplicationEvent { + + private String pnfCorrelationId; + + /** + * Create a new ApplicationEvent. + * + * @param source the object on which the event initially occurred (never {@code null}) + */ + public PnfNotificationEvent(Object source, String pnfCorrelationId) { + super(source); + this.pnfCorrelationId = pnfCorrelationId; + } + + public String getPnfCorrelationId() { + return pnfCorrelationId; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 5cbd530a93..e2dc375cd1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -23,14 +23,20 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @Component -public class InformDmaapClient implements JavaDelegate { +public class InformDmaapClient implements JavaDelegate, ApplicationListener<PnfNotificationEvent> { + private Logger logger = LoggerFactory.getLogger(getClass()); private DmaapClient dmaapClient; + private DelegateExecution execution; @Override public void execute(DelegateExecution execution) { @@ -38,10 +44,19 @@ public class InformDmaapClient implements JavaDelegate { RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage") .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult()); + this.execution = execution; } @Autowired public void setDmaapClient(DmaapClient dmaapClient) { this.dmaapClient = dmaapClient; } + + @Override + public void onApplicationEvent(PnfNotificationEvent event) { + logger.info("Received application event for pnfCorrelationId: {}", event.getPnfCorrelationId()); + RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); + runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult(); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 3de0f38b70..2869111485 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -35,9 +35,11 @@ import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -53,8 +55,11 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; + private ApplicationEventPublisher applicationEventPublisher; + @Autowired - public PnfEventReadyDmaapClient(Environment env) { + public PnfEventReadyDmaapClient(Environment env, ApplicationEventPublisher applicationEventPublisher) { + this.applicationEventPublisher = applicationEventPublisher; httpClient = HttpClientBuilder.create().build(); pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>(); topicListenerDelayInSeconds = env.getProperty("pnf.dmaap.topicListenerDelayInSeconds", Integer.class); @@ -130,13 +135,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) { - Runnable runnable = unregister(pnfCorrelationId); - if (runnable != null) { - logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId); - // runnable.run(); - runnable = null; - } + unregister(pnfCorrelationId); + PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, pnfCorrelationId); + applicationEventPublisher.publishEvent(pnfNotificationEvent); } } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy new file mode 100644 index 0000000000..afbace76d6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy @@ -0,0 +1,301 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition + +import static com.shazam.shazamcrest.MatcherAssert.assertThat +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +/** + * Copyright 2018 ZTE Corporation. + * + * 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. + */ +class DoCompareServiceInstanceDataTest extends MsoGroovyTest { + + + public static final String uuiSoString = "{\n" + + " \"service\":{\n" + + " \"name\":\"SiteService\",\n" + + " \"description\":\"SiteService\",\n" + + " \"serviceInvariantUuid\":\"5c13f3fb-2744-4635-9f1f-c59c92dc8f70\",\n" + + " \"serviceUuid\":\"3a76b1f5-fb0d-4b6b-82d5-0e8a4ebc3838\",\n" + + " \"globalSubscriberId\":\"test_custormer\",\n" + + " \"serviceType\":\"example-service-type\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + " {\n" + + " \"resourceIndex\":\"1\",\n" + + " \"resourceName\":\"sdwanvpnresource\",\n" + + " \"resourceInvariantUuid\":\"0c0e1cbe-6e01-4f9e-8c45-a9700ebc14df\",\n" + + " \"resourceUuid\":\"4ad2d390-5c51-45f5-9710-b467a4ec7a73\",\n" + + " \"resourceCustomizationUuid\":\"66590e07-0777-415c-af44-36347cf3ddd3\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " },\n" + + " {\n" + + " \"resourceIndex\":\"1\",\n" + + " \"resourceName\":\"sdwansiteresource\",\n" + + " \"resourceInvariantUuid\":\"97a3e552-08c4-4697-aeeb-d8d3e09ce58e\",\n" + + " \"resourceUuid\":\"63d8e1af-32dc-4c71-891d-e3f7b6a976d2\",\n" + + " \"resourceCustomizationUuid\":\"205456e7-3dc0-40c4-8cb0-28e6c1877042\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " },\n" + + " {\n" + + " \"resourceIndex\":\"2\",\n" + + " \"resourceName\":\"sdwansiteresource\",\n" + + " \"resourceInvariantUuid\":\"97a3e552-08c4-4697-aeeb-d8d3e09ce58e\",\n" + + " \"resourceUuid\":\"63d8e1af-32dc-4c71-891d-e3f7b6a976d2\",\n" + + " \"resourceCustomizationUuid\":\"205456e7-3dc0-40c4-8cb0-28e6c1877042\",\n" + + " \"parameters\":{\n" + + " \"locationConstraints\":[\n" + + "\n" + + " ],\n" + + " \"resources\":[\n" + + "\n" + + " ],\n" + + " \"requestInputs\":{\n" + + "\n" + + " }\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"requestInputs\":{\n" + + " \"sdwanvpnresource_list\":[\n" + + " {\n" + + " \"sdwanvpn_topology\":\"hub_spoke\",\n" + + " \"sdwanvpn_name\":\"defaultvpn\",\n" + + " \"sdwansitelan_list\":[\n" + + " {\n" + + " \"role\":\"Hub\",\n" + + " \"portType\":\"GE\",\n" + + " \"portSwitch\":\"layer3-port\",\n" + + " \"vlanId\":\"\",\n" + + " \"ipAddress\":\"192.168.10.1\",\n" + + " \"deviceName\":\"vCPE\",\n" + + " \"portNumer\":\"0/0/1\"\n" + + " },\n" + + " {\n" + + " \"role\":\"Hub\",\n" + + " \"portType\":\"GE\",\n" + + " \"portSwitch\":\"layer2-port\",\n" + + " \"vlanId\":\"55\",\n" + + " \"ipAddress\":\"192.168.11.1\",\n" + + " \"deviceName\":\"CPE_Beijing\",\n" + + " \"portNumer\":\"0/0/1\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"sdwansiteresource_list\":[\n" + + " {\n" + + " \"sdwansite_emails\":\"chenchuanyu@huawei.com\",\n" + + " \"sdwansite_address\":\"Huawei Public Cloud\",\n" + + " \"sdwansite_description\":\"DC Site\",\n" + + " \"sdwansite_role\":\"dsvpn_hub\",\n" + + " \"sdwansite_postcode\":\"20000\",\n" + + " \"sdwansite_type\":\"single_gateway\",\n" + + " \"sdwansite_latitude\":\"\",\n" + + " \"sdwansite_controlPoint\":\"\",\n" + + " \"sdwansite_longitude\":\"\",\n" + + " \"sdwansitewan_list\":[\n" + + " {\n" + + " \"providerIpAddress\":\"\",\n" + + " \"portType\":\"GE\",\n" + + " \"inputBandwidth\":\"1000\",\n" + + " \"ipAddress\":\"\",\n" + + " \"name\":\"10000\",\n" + + " \"transportNetworkName\":\"internet\",\n" + + " \"outputBandwidth\":\"10000\",\n" + + " \"deviceName\":\"vCPE\",\n" + + " \"portNumber\":\"0/0/0\",\n" + + " \"ipMode\":\"DHCP\",\n" + + " \"publicIP\":\"119.3.7.113\"\n" + + " }\n" + + " ],\n" + + " \"sdwandevice_list\":[\n" + + " {\n" + + " \"esn\":\"XXXXXXX\",\n" + + " \"vendor\":\"Huawei\",\n" + + " \"name\":\"vCPE\",\n" + + " \"type\":\"AR1000V\",\n" + + " \"version\":\"1.0\",\n" + + " \"class\":\"VNF\",\n" + + " \"systemIp\":\"20.20.20.1\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"sdwansite_emails\":\"chenchuanyu@huawei.com\",\n" + + " \"sdwansite_address\":\"Huawei Public Cloud\",\n" + + " \"sdwansite_description\":\"DC Site\",\n" + + " \"sdwansite_role\":\"dsvpn_hub\",\n" + + " \"sdwansite_postcode\":\"20000\",\n" + + " \"sdwansite_type\":\"single_gateway\",\n" + + " \"sdwansite_latitude\":\"\",\n" + + " \"sdwansite_controlPoint\":\"\",\n" + + " \"sdwansite_longitude\":\"\",\n" + + " \"sdwansitewan_list\":[\n" + + " {\n" + + " \"providerIpAddress\":\"\",\n" + + " \"portType\":\"GE\",\n" + + " \"inputBandwidth\":\"1000\",\n" + + " \"ipAddress\":\"172.18.1.2/24\",\n" + + " \"name\":\"10000\",\n" + + " \"transportNetworkName\":\"internet\",\n" + + " \"outputBandwidth\":\"10000\",\n" + + " \"deviceName\":\"CPE_Beijing\",\n" + + " \"portNumber\":\"0/0/0\",\n" + + " \"ipMode\":\"Static\",\n" + + " \"publicIP\":\"\"\n" + + " }\n" + + " ],\n" + + " \"sdwandevice_list\":[\n" + + " {\n" + + " \"esn\":\"XXXXXXX\",\n" + + " \"vendor\":\"Huawei\",\n" + + " \"name\":\"CPE_Beijing\",\n" + + " \"type\":\"AR161\",\n" + + " \"version\":\"1.0\",\n" + + " \"class\":\"PNF\",\n" + + " \"systemIp\":\"20.20.20.2\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " }\n" + + " }\n" + + " }\n" + + "}" + + @Before + void setUp() { + super.init("DoCompareServiceInstanceData") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.preProcessRequest(mockExecution) + } + + @Test(expected = BpmnError.class) + void testPreProcessRequestException() { + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.preProcessRequest(mockExecution) + } + + @Test + void testPrepareDecomposeService_Original() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.prepareDecomposeService_Original(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + String serviceModelInfo = getServiceModelInfo() + assertThat(captor.getValue(), sameBeanAs(serviceModelInfo)) + } + + @Test + void testProcessDecomposition_Original() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.processDecomposition_Original(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + ServiceDecomposition serviceDecomposition = getServiceDecomposition() + assertThat(captor.getValue(), sameBeanAs(serviceDecomposition)) + } + + @Test + void testDoCompareUuiRquestInput() { + mockData() + DoCompareServiceInstanceData csi = new DoCompareServiceInstanceData() + csi.doCompareUuiRquestInput(mockExecution) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + } + + private String getServiceModelInfo() { + String modelInvariantUuid = mockExecution.getVariable("model-invariant-id-original") + String modelUuid = mockExecution.getVariable("model-version-id-original") + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + serviceModelInfo + } + + private void mockData() { + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("model-version-id-original")).thenReturn("12345") + when(mockExecution.getVariable("model-invariant-id-original")).thenReturn("12345") + when(mockExecution.getVariable("uuiRequest")).thenReturn(uuiSoString) + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234") + when(mockExecution.getVariable("serviceInstanceData-original")).thenReturn(getExpectedServiceInstance()) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(getServiceDecomposition()) + when(mockExecution.getVariable("serviceDecomposition_Original")).thenReturn(getServiceDecomposition()) + } + + private ServiceDecomposition getServiceDecomposition() { + ServiceDecomposition decomposition = new ServiceDecomposition() + List<Resource> allSR_original = new ArrayList<>() + decomposition.setAllottedResources(allSR_original) + return decomposition + } + + private ServiceInstance getExpectedServiceInstance() { + ServiceInstance expectedServiceInstanceData = new ServiceInstance() + expectedServiceInstanceData.setServiceInstanceId("1234") + expectedServiceInstanceData.setServiceInstanceName("volte-service") + expectedServiceInstanceData.setServiceType("E2E Service") + expectedServiceInstanceData.setServiceRole("E2E Service") + expectedServiceInstanceData.setInputParameters(uuiSoString) + return expectedServiceInstanceData + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java index 446c73dda1..96c3db0ccc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java @@ -27,12 +27,14 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; public class InformDmaapClientTest { + @Before public void setUp() throws Exception { informDmaapClient = new InformDmaapClient(); @@ -71,6 +73,19 @@ public class InformDmaapClientTest { inOrder.verify(messageCorrelationBuilder).correlateWithResult(); } + @Test + public void onApplicationEvent_validPnfNotificationEvent_expectedOutput() { + + PnfNotificationEvent pnfNotificationEvent = new PnfNotificationEvent(this, "testPnfCorrelationId"); + + informDmaapClient.execute(delegateExecution); + informDmaapClient.onApplicationEvent(pnfNotificationEvent); + + InOrder inOrder = inOrder(messageCorrelationBuilder); + inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey"); + inOrder.verify(messageCorrelationBuilder).correlateWithResult(); + } + private DelegateExecution mockDelegateExecution() { DelegateExecution delegateExecution = mock(DelegateExecution.class); when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index ca3373e8cb..9f31e2a5df 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -25,8 +25,10 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; @@ -47,9 +49,12 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.pnf.PnfNotificationEvent; import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.env.Environment; @RunWith(MockitoJUnitRunner.class) @@ -80,6 +85,9 @@ public class PnfEventReadyDmaapClientTest { private Runnable threadMockToNotifyCamundaFlow; private ScheduledThreadPoolExecutor executorMock; + @Mock + private ApplicationEventPublisher applicationEventPublisher; + @Before public void init() throws NoSuchFieldException, IllegalAccessException { when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT); @@ -91,7 +99,7 @@ public class PnfEventReadyDmaapClientTest { when(env.getProperty(eq("pnf.dmaap.consumerGroup"))).thenReturn(CONSUMER_GROUP); when(env.getProperty(eq("pnf.dmaap.topicListenerDelayInSeconds"), eq(Integer.class))) .thenReturn(TOPIC_LISTENER_DELAY_IN_SECONDS); - testedObject = new PnfEventReadyDmaapClient(env); + testedObject = new PnfEventReadyDmaapClient(env, applicationEventPublisher); testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread(); httpClientMock = mock(HttpClient.class); threadMockToNotifyCamundaFlow = mock(Runnable.class); @@ -123,7 +131,10 @@ public class PnfEventReadyDmaapClientTest { assertEquals(captor1.getValue().getURI().getPath(), "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); - // verify(threadMockToNotifyCamundaFlow).run(); + /** + * Two PNF returned from HTTP request. + */ + verify(applicationEventPublisher, times(2)).publishEvent(any(PnfNotificationEvent.class)); verify(executorMock).shutdown(); } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn index e2488fda6a..345e0bbb28 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn @@ -45,6 +45,7 @@ ex.processJavaException(execution)]]></bpmn:script> <camunda:in source="addResourceList" target="addResourceList" /> <camunda:in source="delResourceList" target="delResourceList" /> <camunda:in source="serviceRelationShip" target="serviceRelationShip" /> + <camunda:in source="uuiRequest-del" target="uuiRequest-del" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_04qwbbf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0klbpxx</bpmn:outgoing> @@ -192,7 +193,7 @@ csi.postCompareModelVersions(execution)]]></bpmn:script> </bpmn:scriptTask> <bpmn:scriptTask id="ScriptTask_0hixtxc" name="Prepare for Compare Model Versions" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_03i6zhx</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1pdv4qj</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_16jngfs</bpmn:outgoing> <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new UpdateCustomE2EServiceInstance() ddsi.preCompareModelVersions(execution)]]></bpmn:script> @@ -210,11 +211,10 @@ ddsi.preCompareModelVersions(execution)]]></bpmn:script> <camunda:out source="addResourceList" target="addResourceList" /> <camunda:out source="delResourceList" target="delResourceList" /> </bpmn:extensionElements> - <bpmn:incoming>SequenceFlow_1pdv4qj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1bvnbfu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xhbobd</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_03i6zhx" sourceRef="ScriptTask_0cx1y0g" targetRef="ScriptTask_0hixtxc" /> - <bpmn:sequenceFlow id="SequenceFlow_1pdv4qj" sourceRef="ScriptTask_0hixtxc" targetRef="CallActivity_1rkoyc5" /> <bpmn:sequenceFlow id="SequenceFlow_0xhbobd" sourceRef="CallActivity_1rkoyc5" targetRef="ScriptTask_11y3uq6" /> <bpmn:exclusiveGateway id="ExclusiveGateway_0mc34qe" name="HasResourcetoUpdate?" default="SequenceFlow_1n8h3zt"> <bpmn:incoming>SequenceFlow_0secadm</bpmn:incoming> @@ -315,14 +315,54 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("hasResourcetoUpdate") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1n8h3zt" name="No" sourceRef="ExclusiveGateway_0mc34qe" targetRef="ScriptTask_04a0t3p" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0o2r7np" name="IsServiceInstanceModification?" default="SequenceFlow_1bvnbfu"> + <bpmn:incoming>SequenceFlow_16jngfs</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1bvnbfu</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1po82kn</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_16jngfs" sourceRef="ScriptTask_0hixtxc" targetRef="ExclusiveGateway_0o2r7np" /> + <bpmn:sequenceFlow id="SequenceFlow_1bvnbfu" name="No" sourceRef="ExclusiveGateway_0o2r7np" targetRef="CallActivity_1rkoyc5" /> + <bpmn:sequenceFlow id="SequenceFlow_1po82kn" name="Yes" sourceRef="ExclusiveGateway_0o2r7np" targetRef="Task_1ktxr5y"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("model-version-id-original") == execution.getVariable("model-version-id-target") && execution.getVariable("model-invariant-id-original") == execution.getVariable("model-invariant-id-target")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:callActivity id="Task_1ktxr5y" name="Call DoCompareServiceInstanceData" calledElement="DoCompareServiceInstanceData"> + <bpmn:extensionElements> + <camunda:in source="serviceInstanceData-original" target="serviceInstanceData-original" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:out source="addResourceList" target="addResourceList" /> + <camunda:out source="delResourceList" target="delResourceList" /> + <camunda:out source="uuiRequest" target="uuiRequest" /> + <camunda:out source="uuiRequest-del" target="uuiRequest-del" /> + <camunda:in source="model-invariant-id-original" target="model-invariant-id-original" /> + <camunda:in source="model-version-id-original" target="model-version-id-original" /> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1po82kn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0gqpsvb</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0gqpsvb" sourceRef="Task_1ktxr5y" targetRef="Task_1xbq4e3" /> + <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_01jy2z3" name="GoToOperStatusInit"> + <bpmn:incoming>SequenceFlow_0qe8uv2</bpmn:incoming> + <bpmn:linkEventDefinition name="StartOperStatusInit" /> + </bpmn:intermediateThrowEvent> + <bpmn:sequenceFlow id="SequenceFlow_0qe8uv2" sourceRef="Task_1xbq4e3" targetRef="IntermediateThrowEvent_01jy2z3" /> + <bpmn:scriptTask id="Task_1xbq4e3" name="Post for Compare Service Instance Data" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0gqpsvb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qe8uv2</bpmn:outgoing> + <bpmn:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new UpdateCustomE2EServiceInstance() +csi.postCompareModelVersions(execution)]]></bpmn:script> + </bpmn:scriptTask> </bpmn:process> <bpmn:error id="Error_0nbdy47" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateCustomE2EServiceInstance"> <bpmndi:BPMNShape id="StartEvent_00qj6ro_di" bpmnElement="StartEvent_00qj6ro"> - <dc:Bounds x="-6" y="180" width="36" height="36" /> + <dc:Bounds x="-6" y="135" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-24" y="221" width="73" height="24" /> + <dc:Bounds x="-25" y="176" width="75" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_0ka59nc_di" bpmnElement="SubProcess_0ka59nc" isExpanded="true"> @@ -338,7 +378,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1s09c7d_di" bpmnElement="ScriptTask_1s09c7d"> - <dc:Bounds x="147" y="158" width="100" height="80" /> + <dc:Bounds x="107" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0ttvn8r_di" bpmnElement="ScriptTask_0ttvn8r"> <dc:Bounds x="782" y="585" width="100" height="80" /> @@ -350,7 +390,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> <dc:Bounds x="-61" y="908" width="1322" height="164" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0xupxj9_di" bpmnElement="ScriptTask_0xupxj9"> - <dc:Bounds x="451" y="337" width="100" height="80" /> + <dc:Bounds x="451" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_0aqn64l_di" bpmnElement="ExclusiveGateway_0aqn64l" isMarkerVisible="true"> <dc:Bounds x="639" y="600" width="50" height="50" /> @@ -365,10 +405,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0s2spoq_di" bpmnElement="SequenceFlow_0s2spoq"> - <di:waypoint xsi:type="dc:Point" x="30" y="198" /> - <di:waypoint xsi:type="dc:Point" x="147" y="198" /> + <di:waypoint xsi:type="dc:Point" x="30" y="153" /> + <di:waypoint xsi:type="dc:Point" x="107" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="43.5" y="177" width="90" height="12" /> + <dc:Bounds x="23.5" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0klbpxx_di" bpmnElement="SequenceFlow_0klbpxx"> @@ -485,49 +525,42 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0cx1y0g_di" bpmnElement="ScriptTask_0cx1y0g"> - <dc:Bounds x="364" y="158" width="100" height="80" /> + <dc:Bounds x="251" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_11y3uq6_di" bpmnElement="ScriptTask_11y3uq6"> - <dc:Bounds x="959" y="158" width="100" height="80" /> + <dc:Bounds x="959" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0hixtxc_di" bpmnElement="ScriptTask_0hixtxc"> - <dc:Bounds x="563" y="158" width="100" height="80" /> + <dc:Bounds x="422" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_1rkoyc5_di" bpmnElement="CallActivity_1rkoyc5"> - <dc:Bounds x="782" y="158" width="100" height="80" /> + <dc:Bounds x="782" y="113" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_03i6zhx_di" bpmnElement="SequenceFlow_03i6zhx"> - <di:waypoint xsi:type="dc:Point" x="464" y="198" /> - <di:waypoint xsi:type="dc:Point" x="563" y="198" /> + <di:waypoint xsi:type="dc:Point" x="351" y="153" /> + <di:waypoint xsi:type="dc:Point" x="422" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="468.5" y="177" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1pdv4qj_di" bpmnElement="SequenceFlow_1pdv4qj"> - <di:waypoint xsi:type="dc:Point" x="663" y="198" /> - <di:waypoint xsi:type="dc:Point" x="782" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="677.5" y="177" width="90" height="12" /> + <dc:Bounds x="341.5" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xhbobd_di" bpmnElement="SequenceFlow_0xhbobd"> - <di:waypoint xsi:type="dc:Point" x="882" y="198" /> - <di:waypoint xsi:type="dc:Point" x="959" y="198" /> + <di:waypoint xsi:type="dc:Point" x="882" y="153" /> + <di:waypoint xsi:type="dc:Point" x="959" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="875.5" y="177" width="90" height="12" /> + <dc:Bounds x="876" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0mc34qe_di" bpmnElement="ExclusiveGateway_0mc34qe" isMarkerVisible="true"> - <dc:Bounds x="639" y="352" width="50" height="50" /> + <dc:Bounds x="639" y="377" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="622" y="324" width="85" height="24" /> + <dc:Bounds x="622" y="349" width="85" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0az1n4y_di" bpmnElement="SequenceFlow_0az1n4y"> - <di:waypoint xsi:type="dc:Point" x="247" y="198" /> - <di:waypoint xsi:type="dc:Point" x="364" y="198" /> + <di:waypoint xsi:type="dc:Point" x="207" y="153" /> + <di:waypoint xsi:type="dc:Point" x="251" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="260.5" y="177" width="90" height="12" /> + <dc:Bounds x="184" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_0m01dm3_di" bpmnElement="IntermediateCatchEvent_0m01dm3"> @@ -537,10 +570,10 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0secadm_di" bpmnElement="SequenceFlow_0secadm"> - <di:waypoint xsi:type="dc:Point" x="551" y="377" /> - <di:waypoint xsi:type="dc:Point" x="639" y="377" /> + <di:waypoint xsi:type="dc:Point" x="551" y="402" /> + <di:waypoint xsi:type="dc:Point" x="639" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="550" y="356" width="90" height="12" /> + <dc:Bounds x="550" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_04qwbbf_di" bpmnElement="SequenceFlow_04qwbbf"> @@ -551,58 +584,58 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1jvqhkf_di" bpmnElement="EndEvent_1jvqhkf"> - <dc:Bounds x="1192" y="359" width="36" height="36" /> + <dc:Bounds x="1192" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1200" y="404" width="19" height="12" /> + <dc:Bounds x="1200" y="429" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_16sgdqw_di" bpmnElement="ScriptTask_16sgdqw"> - <dc:Bounds x="97" y="337" width="100" height="80" /> + <dc:Bounds x="97" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0qjpd5v_di" bpmnElement="ServiceTask_0qjpd5v"> - <dc:Bounds x="274" y="337" width="100" height="80" /> + <dc:Bounds x="274" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1e3vtyq_di" bpmnElement="SequenceFlow_1e3vtyq"> - <di:waypoint xsi:type="dc:Point" x="197" y="377" /> - <di:waypoint xsi:type="dc:Point" x="274" y="377" /> + <di:waypoint xsi:type="dc:Point" x="197" y="402" /> + <di:waypoint xsi:type="dc:Point" x="274" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="235.5" y="356" width="0" height="12" /> + <dc:Bounds x="191" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12dou7o_di" bpmnElement="SequenceFlow_12dou7o"> - <di:waypoint xsi:type="dc:Point" x="374" y="377" /> - <di:waypoint xsi:type="dc:Point" x="451" y="377" /> + <di:waypoint xsi:type="dc:Point" x="374" y="402" /> + <di:waypoint xsi:type="dc:Point" x="451" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="412.5" y="356" width="0" height="12" /> + <dc:Bounds x="368" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0mj3kf2_di" bpmnElement="ServiceTask_0mj3kf2"> - <dc:Bounds x="959" y="337" width="100" height="80" /> + <dc:Bounds x="959" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_08mk8h9_di" bpmnElement="IntermediateThrowEvent_08mk8h9"> - <dc:Bounds x="1192" y="180" width="36" height="36" /> + <dc:Bounds x="1192" y="135" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1175" y="220" width="86" height="24" /> + <dc:Bounds x="1175" y="175" width="86" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0t7zinj_di" bpmnElement="SequenceFlow_0t7zinj"> - <di:waypoint xsi:type="dc:Point" x="1059" y="198" /> - <di:waypoint xsi:type="dc:Point" x="1192" y="198" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="153" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="153" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1125.5" y="177" width="0" height="12" /> + <dc:Bounds x="1081" y="132" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_14w7v9s_di" bpmnElement="IntermediateCatchEvent_14w7v9s"> - <dc:Bounds x="-6" y="359" width="36" height="36" /> + <dc:Bounds x="-6" y="384" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-29" y="421" width="88" height="24" /> + <dc:Bounds x="-29" y="446" width="88" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1bddzne_di" bpmnElement="SequenceFlow_1bddzne"> - <di:waypoint xsi:type="dc:Point" x="30" y="377" /> - <di:waypoint xsi:type="dc:Point" x="97" y="377" /> + <di:waypoint xsi:type="dc:Point" x="30" y="402" /> + <di:waypoint xsi:type="dc:Point" x="97" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="63.5" y="356" width="0" height="12" /> + <dc:Bounds x="19" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_14kqo0r_di" bpmnElement="ScriptTask_14kqo0r"> @@ -626,42 +659,96 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_04a0t3p_di" bpmnElement="ScriptTask_04a0t3p"> - <dc:Bounds x="782" y="337" width="100" height="80" /> + <dc:Bounds x="782" y="362" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1wzk6tu_di" bpmnElement="SequenceFlow_1wzk6tu"> - <di:waypoint xsi:type="dc:Point" x="882" y="377" /> - <di:waypoint xsi:type="dc:Point" x="959" y="377" /> + <di:waypoint xsi:type="dc:Point" x="882" y="402" /> + <di:waypoint xsi:type="dc:Point" x="959" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="920.5" y="356" width="0" height="12" /> + <dc:Bounds x="876" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_1k72hze_di" bpmnElement="IntermediateThrowEvent_1k72hze"> - <dc:Bounds x="646" y="447" width="36" height="36" /> + <dc:Bounds x="646" y="472" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="631" y="487" width="76" height="12" /> + <dc:Bounds x="631" y="512" width="76" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0kvl23y_di" bpmnElement="SequenceFlow_0kvl23y"> - <di:waypoint xsi:type="dc:Point" x="1059" y="377" /> - <di:waypoint xsi:type="dc:Point" x="1192" y="377" /> + <di:waypoint xsi:type="dc:Point" x="1059" y="402" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1125.5" y="356" width="0" height="12" /> + <dc:Bounds x="1081" y="381" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0zmd4rt_di" bpmnElement="SequenceFlow_0zmd4rt"> - <di:waypoint xsi:type="dc:Point" x="664" y="402" /> - <di:waypoint xsi:type="dc:Point" x="664" y="447" /> + <di:waypoint xsi:type="dc:Point" x="664" y="427" /> + <di:waypoint xsi:type="dc:Point" x="664" y="472" /> <bpmndi:BPMNLabel> - <dc:Bounds x="670" y="419" width="19" height="12" /> + <dc:Bounds x="670" y="444" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1n8h3zt_di" bpmnElement="SequenceFlow_1n8h3zt"> - <di:waypoint xsi:type="dc:Point" x="689" y="377" /> - <di:waypoint xsi:type="dc:Point" x="782" y="377" /> + <di:waypoint xsi:type="dc:Point" x="689" y="402" /> + <di:waypoint xsi:type="dc:Point" x="782" y="402" /> <bpmndi:BPMNLabel> - <dc:Bounds x="729" y="356" width="14" height="12" /> + <dc:Bounds x="729" y="381" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0o2r7np_di" bpmnElement="ExclusiveGateway_0o2r7np" isMarkerVisible="true"> + <dc:Bounds x="628.6452095808384" y="128.09730538922156" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="611" y="182" width="88" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_16jngfs_di" bpmnElement="SequenceFlow_16jngfs"> + <di:waypoint xsi:type="dc:Point" x="522" y="153" /> + <di:waypoint xsi:type="dc:Point" x="629" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="575.5" y="132" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1bvnbfu_di" bpmnElement="SequenceFlow_1bvnbfu"> + <di:waypoint xsi:type="dc:Point" x="679" y="153" /> + <di:waypoint xsi:type="dc:Point" x="782" y="153" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="724" y="132" width="14" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1po82kn_di" bpmnElement="SequenceFlow_1po82kn"> + <di:waypoint xsi:type="dc:Point" x="654" y="178" /> + <di:waypoint xsi:type="dc:Point" x="654" y="267" /> + <di:waypoint xsi:type="dc:Point" x="782" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="660" y="217" width="19" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_0vnoaee_di" bpmnElement="Task_1ktxr5y"> + <dc:Bounds x="782" y="227" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0gqpsvb_di" bpmnElement="SequenceFlow_0gqpsvb"> + <di:waypoint xsi:type="dc:Point" x="882" y="267" /> + <di:waypoint xsi:type="dc:Point" x="959" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="920.5" y="246" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_01jy2z3_di" bpmnElement="IntermediateThrowEvent_01jy2z3"> + <dc:Bounds x="1192" y="249" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1175" y="289" width="86" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0qe8uv2_di" bpmnElement="SequenceFlow_0qe8uv2"> + <di:waypoint xsi:type="dc:Point" x="1059" y="267" /> + <di:waypoint xsi:type="dc:Point" x="1192" y="267" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1125.5" y="246" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_179xmbe_di" bpmnElement="Task_1xbq4e3"> + <dc:Bounds x="959" y="227" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn new file mode 100644 index 0000000000..6e5032a2eb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareServiceInstanceData.bpmn @@ -0,0 +1,241 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="DoCompareServiceInstanceData" name="DoCompareServiceInstanceData" isExecutable="true"> + <bpmn2:scriptTask id="ScriptTask_04rn9mp" name="DoCompareServiceInstanceData" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1rebkae</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1lkpfe2</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new DoCompareServiceInstanceData() +csi.doCompareUuiRquestInput(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1rebkae" sourceRef="StartEvent_0jhv664" targetRef="ScriptTask_04rn9mp" /> + <bpmn2:intermediateCatchEvent id="StartEvent_0jhv664" name="StartCompare"> + <bpmn2:outgoing>SequenceFlow_1rebkae</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="StartCompare" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:endEvent id="EndEvent_0x8im5g"> + <bpmn2:incoming>SequenceFlow_1lkpfe2</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1lkpfe2" sourceRef="ScriptTask_04rn9mp" targetRef="EndEvent_0x8im5g" /> + <bpmn2:subProcess id="SubProcess_0roysbg" name="Sub-process for UnexpectedErrors" triggeredByEvent="true"> + <bpmn2:startEvent id="StartEvent_0xtpw6j"> + <bpmn2:outgoing>SequenceFlow_19sogyb</bpmn2:outgoing> + <bpmn2:errorEventDefinition /> + </bpmn2:startEvent> + <bpmn2:endEvent id="EndEvent_05a2pr9"> + <bpmn2:incoming>SequenceFlow_17mr4jl</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:scriptTask id="ScriptTask_0xk9fk3" name="Log / Print Unexpected Error" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_19sogyb</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_17mr4jl</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_19sogyb" name="" sourceRef="StartEvent_0xtpw6j" targetRef="ScriptTask_0xk9fk3" /> + <bpmn2:sequenceFlow id="SequenceFlow_17mr4jl" name="" sourceRef="ScriptTask_0xk9fk3" targetRef="EndEvent_05a2pr9" /> + </bpmn2:subProcess> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0se5nzs" name="GoTo Decompose_Service_Original"> + <bpmn2:incoming>SequenceFlow_1o9916j</bpmn2:incoming> + <bpmn2:linkEventDefinition name="Decompose_Service_Original" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0b436w1" name="GoTo StartCompare"> + <bpmn2:incoming>SequenceFlow_08zjjzw</bpmn2:incoming> + <bpmn2:linkEventDefinition name="StartCompare" /> + </bpmn2:intermediateThrowEvent> + <bpmn2:scriptTask id="ScriptTask_1d9qb54" name="PostProcess Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1wudpuj</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_08zjjzw</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi= new DoCompareServiceInstanceData() +dcsi.processDecomposition_Original(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:callActivity id="CallActivity_1fc56sd" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn2:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo_Original" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_04ciw70</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1wudpuj</bpmn2:outgoing> + </bpmn2:callActivity> + <bpmn2:scriptTask id="ScriptTask_1i06996" name="Prepare Decompose Service " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1fgkvpr</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_04ciw70</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi= new DoCompareServiceInstanceData() +dcsi.prepareDecomposeService_Original(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1m9q0j7" name="Decompose_Service_Original"> + <bpmn2:outgoing>SequenceFlow_1fgkvpr</bpmn2:outgoing> + <bpmn2:linkEventDefinition name="Decompose_Service_Original" /> + </bpmn2:intermediateCatchEvent> + <bpmn2:sequenceFlow id="SequenceFlow_08zjjzw" sourceRef="ScriptTask_1d9qb54" targetRef="IntermediateThrowEvent_0b436w1" /> + <bpmn2:sequenceFlow id="SequenceFlow_1wudpuj" sourceRef="CallActivity_1fc56sd" targetRef="ScriptTask_1d9qb54" /> + <bpmn2:sequenceFlow id="SequenceFlow_04ciw70" sourceRef="ScriptTask_1i06996" targetRef="CallActivity_1fc56sd" /> + <bpmn2:sequenceFlow id="SequenceFlow_1fgkvpr" sourceRef="IntermediateCatchEvent_1m9q0j7" targetRef="ScriptTask_1i06996" /> + <bpmn2:startEvent id="StartEvent_13da9hl" name="Start Flow"> + <bpmn2:outgoing>SequenceFlow_1chfao3</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:scriptTask id="ScriptTask_0nie46r" name="PreProcess Incoming Request" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1chfao3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1o9916j</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCompareServiceInstanceData() +dcsi.preProcessRequest(execution) +]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_1chfao3" name="" sourceRef="StartEvent_13da9hl" targetRef="ScriptTask_0nie46r" /> + <bpmn2:sequenceFlow id="SequenceFlow_1o9916j" sourceRef="ScriptTask_0nie46r" targetRef="IntermediateThrowEvent_0se5nzs" /> + </bpmn2:process> + <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCompareServiceInstanceData"> + <bpmndi:BPMNShape id="ScriptTask_04rn9mp_di" bpmnElement="ScriptTask_04rn9mp"> + <dc:Bounds x="426" y="426" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1rebkae_di" bpmnElement="SequenceFlow_1rebkae"> + <di:waypoint xsi:type="dc:Point" x="10" y="466" /> + <di:waypoint xsi:type="dc:Point" x="426" y="466" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="173" y="445" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_05z1jyy_di" bpmnElement="StartEvent_0jhv664"> + <dc:Bounds x="-26" y="448" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-42" y="488" width="68" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0x8im5g_di" bpmnElement="EndEvent_0x8im5g"> + <dc:Bounds x="1040" y="448" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1013" y="488" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1lkpfe2_di" bpmnElement="SequenceFlow_1lkpfe2"> + <di:waypoint xsi:type="dc:Point" x="526" y="466" /> + <di:waypoint xsi:type="dc:Point" x="1040" y="466" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="738" y="445" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_0roysbg_di" bpmnElement="SubProcess_0roysbg" isExpanded="true"> + <dc:Bounds x="221" y="751" width="467" height="193" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_0xtpw6j_di" bpmnElement="StartEvent_0xtpw6j"> + <dc:Bounds x="289" y="818" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="172" y="859" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05a2pr9_di" bpmnElement="EndEvent_05a2pr9"> + <dc:Bounds x="582" y="818" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="465" y="859" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0xk9fk3_di" bpmnElement="ScriptTask_0xk9fk3"> + <dc:Bounds x="393" y="796" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_19sogyb_di" bpmnElement="SequenceFlow_19sogyb"> + <di:waypoint xsi:type="dc:Point" x="325" y="836" /> + <di:waypoint xsi:type="dc:Point" x="393" y="836" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="224" y="821" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17mr4jl_di" bpmnElement="SequenceFlow_17mr4jl"> + <di:waypoint xsi:type="dc:Point" x="493" y="836" /> + <di:waypoint xsi:type="dc:Point" x="582" y="836" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="405" y="821" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0se5nzs_di" bpmnElement="IntermediateThrowEvent_0se5nzs"> + <dc:Bounds x="1047" y="83" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1021" y="124" width="88" height="36" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateThrowEvent_0b436w1_di" bpmnElement="IntermediateThrowEvent_0b436w1"> + <dc:Bounds x="1047" y="311" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1032" y="352" width="68" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1d9qb54_di" bpmnElement="ScriptTask_1d9qb54"> + <dc:Bounds x="711" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1fc56sd_di" bpmnElement="CallActivity_1fc56sd"> + <dc:Bounds x="426" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1i06996_di" bpmnElement="ScriptTask_1i06996"> + <dc:Bounds x="144" y="290" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1m9q0j7_di" bpmnElement="IntermediateCatchEvent_1m9q0j7"> + <dc:Bounds x="-26" y="312" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-50" y="348" width="88" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08zjjzw_di" bpmnElement="SequenceFlow_08zjjzw"> + <di:waypoint xsi:type="dc:Point" x="811" y="330" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="329" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="929" y="308.5" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1wudpuj_di" bpmnElement="SequenceFlow_1wudpuj"> + <di:waypoint xsi:type="dc:Point" x="526" y="330" /> + <di:waypoint xsi:type="dc:Point" x="711" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="618.5" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_04ciw70_di" bpmnElement="SequenceFlow_04ciw70"> + <di:waypoint xsi:type="dc:Point" x="244" y="330" /> + <di:waypoint xsi:type="dc:Point" x="426" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="245" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fgkvpr_di" bpmnElement="SequenceFlow_1fgkvpr"> + <di:waypoint xsi:type="dc:Point" x="10" y="330" /> + <di:waypoint xsi:type="dc:Point" x="144" y="330" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-13" y="309" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_13da9hl_di" bpmnElement="StartEvent_13da9hl"> + <dc:Bounds x="-20" y="83" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-26" y="124" width="50" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0nie46r_di" bpmnElement="ScriptTask_0nie46r"> + <dc:Bounds x="340" y="61" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1chfao3_di" bpmnElement="SequenceFlow_1chfao3"> + <di:waypoint xsi:type="dc:Point" x="16" y="101" /> + <di:waypoint xsi:type="dc:Point" x="181" y="101" /> + <di:waypoint xsi:type="dc:Point" x="181" y="101" /> + <di:waypoint xsi:type="dc:Point" x="340" y="101" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="196" y="95" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1o9916j_di" bpmnElement="SequenceFlow_1o9916j"> + <di:waypoint xsi:type="dc:Point" x="440" y="101" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="101" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="743.5" y="80" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn index 785db75fa1..002e382451 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -186,6 +186,7 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> <camunda:in source="operationType" target="operationType" /> <camunda:in source="operationId" target="operationId" /> <camunda:in source="serviceDecomposition_Original" target="serviceDecomposition" /> + <camunda:in source="uuiRequest-del" target="uuiRequest-del" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0ur34hv</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0w4t4ao</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index abab08bdf3..b0517ace3d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -1,16 +1,21 @@ -/* +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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 * - * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix - * Foundation. ================================================================================ 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 * - * 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. + * 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. * - * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.process; @@ -25,10 +30,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import com.google.protobuf.Struct; -import com.google.protobuf.Value; import java.io.IOException; import java.util.List; -import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.ProcessInstance; @@ -114,6 +117,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { if (!execution.isSuspended() && !execution.isEnded()) { try { + runtimeService.signal(execution.getId()); } catch (Exception e) { logger.info(e.getMessage(), e); |