diff options
19 files changed, 227 insertions, 77 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java index ef5d4316d7..90b8024c18 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapAdapter.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -36,8 +38,8 @@ public class MapAdapter extends XmlAdapter<MapEntry, Map<String, Object>> { MapEntry map = new MapEntry(); - for (String key : v.keySet()) { - map.addEntry(key, v.get(key)); + for (Map.Entry<String, Object> entry : v.entrySet()) { + map.addEntry(entry.getKey(), entry.getValue()); } return map; @@ -49,9 +51,9 @@ public class MapAdapter extends XmlAdapter<MapEntry, Map<String, Object>> { return null; } - Map<String, Object> map = new HashMap<>(v.entry.size()); + Map<String, Object> map = new HashMap<>(v.getEntry().size()); - for (MapElements entry : v.entry) { + for (MapElements entry : v.getEntry()) { if (entry.value instanceof Element) { map.put(entry.key, ((Element) entry.value).getTextContent()); } else { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java index 0327fd67a3..3dd339dc68 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapElements.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +37,9 @@ public class MapElements { @XmlElement public Object value; - public MapElements() {} // Required by JAXB + public MapElements() { + // Required by JAXB + } public MapElements(String key, Object value) { this.key = key; @@ -46,7 +50,7 @@ public class MapElements { try { this.value = new ObjectMapper().writeValueAsString(value); } catch (JsonProcessingException e) { - logger.warn("could not marshal value to json, calling toString"); + logger.warn("could not marshal value to json, calling toString", e); this.value = value.toString(); } } else { diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java index 489e11e111..b6b121c820 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/mappers/MapEntry.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,12 +27,23 @@ import java.util.List; public class MapEntry { - public List<MapElements> entry = new ArrayList<>(); + private List<MapElements> entry = new ArrayList<>(); - public MapEntry() {} // Required by JAXB + public MapEntry() { + // Required by JAXB + } - public void addEntry(String key, Object value) { + void addEntry(String key, Object value) { entry.add(new MapElements(key, value)); } + public List<MapElements> getEntry() { + // Required by JAXB + return entry; + } + + public void setEntry(List<MapElements> entry) { + // Required by JAXB + this.entry = entry; + } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java index 189d4cca3e..19dbcad1a2 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,12 +26,13 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; -import com.fasterxml.jackson.databind.ObjectMapper; public class JAXBMarshallingTest { @@ -53,9 +56,13 @@ public class JAXBMarshallingTest { CreateVfModuleRequest request = new CreateVfModuleRequest(); request.getVfModuleParams().put("test-null", null); + request.getVfModuleParams().put("vcpe_image_name", "ubuntu-16-04-cloud-amd64"); + request.getVfModuleParams().put("test-empty", ""); request.getVfModuleParams().put("test array", Arrays.asList("a", "b", "c")); + request.getVfModuleParams().put("test map", Collections.singletonMap("d", "e")); + request.getVfModuleParams().put("marshalling error", new ArrayList()); - assertEquals("documents are equal", + assertEquals("documents should be equal", new String(Files .readAllBytes(Paths.get("src/test/resources/VfRequest-marshalled-with-complex-object.xml"))), request.toXmlString()); diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml index ce175127df..d4955f1b18 100644 --- a/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml +++ b/adapters/mso-adapters-rest-interface/src/test/resources/VfRequest-marshalled-with-complex-object.xml @@ -4,12 +4,28 @@ <backout>true</backout> <vfModuleParams> <entry> + <key>vcpe_image_name</key> + <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">ubuntu-16-04-cloud-amd64</value> + </entry> + <entry> <key>test array</key> <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">["a","b","c"]</value> </entry> <entry> + <key>test map</key> + <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">{"d":"e"}</value> + </entry> + <entry> <key>test-null</key> </entry> + <entry> + <key>marshalling error</key> + <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">[]</value> + </entry> + <entry> + <key>test-empty</key> + <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string"></value> + </entry> </vfModuleParams> <msoRequest/> </createVfModuleRequest> diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.8__Add_Column_Original_Request_Id.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.8__Add_Column_Original_Request_Id.sql new file mode 100644 index 0000000000..54c3c8af60 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.8__Add_Column_Original_Request_Id.sql @@ -0,0 +1,4 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS ORIGINAL_REQUEST_ID varchar(45); +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS ORIGINAL_REQUEST_ID varchar(45);
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java new file mode 100644 index 0000000000..d99b68846e --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java @@ -0,0 +1,46 @@ +/*- + * ============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.Gson; +import java.util.ArrayList; +import java.util.Collection; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; + +/** + * Configures message converter + */ +@Configuration +public class MessageConverterConfiguration { + + @Bean + public HttpMessageConverters customConverters() { + final Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<>(); + final Gson gson = new JSON().getGson(); + final GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(gson); + messageConverters.add(gsonHttpMessageConverter); + return new HttpMessageConverters(true, messageConverters); + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java index 2b33e8b11d..f0830139b7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java @@ -36,9 +36,11 @@ public class WebSecurityConfigImpl extends WebSecurityConfig { @Override protected void configure(final HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); + http.csrf().disable().authorizeRequests() + .antMatchers("/manage/health", "/manage/info", Constants.BASE_URL + "/lcn/**", + Constants.BASE_URL + "/grants/**") + .permitAll().antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")) + .and().httpBasic(); } @Override 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 index fd92910e36..57d6615d66 100644 --- 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 @@ -89,6 +89,7 @@ public class SdcPackageProvider { try { final String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(onapPackage)); final String onapVnfdContent = getFileInZip(new ByteArrayInputStream(onapPackage), vnfdLocation).toString(); + logger.debug("VNFD CONTENTS: " + onapVnfdContent); final JsonObject root = new Gson().toJsonTree(new Yaml().load(onapVnfdContent)).getAsJsonObject(); final JsonObject topologyTemplates = child(root, "topology_template"); 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 1374e89a19..110bbabdb2 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 @@ -202,6 +202,9 @@ public class AaiHelper { logger.debug("VNFMs in ESR: " + vnfmsInEsr); for (final EsrVnfm vnfm : vnfmsInEsr.getEsrVnfm()) { + final EsrSystemInfoList systemInfolist = + aaiServiceProvider.invokeGetVnfmEsrSystemInfoList(vnfm.getVnfmId()); + vnfm.setEsrSystemInfoList(systemInfolist); if (vnfmHasMatchingEsrSystemInfoType(vnfm, vnf.getNfType())) { return vnfm; } @@ -212,7 +215,7 @@ public class AaiHelper { private boolean vnfmHasMatchingEsrSystemInfoType(final EsrVnfm vnfm, final String type) { logger.debug("Checking VNFM ID: " + vnfm + ": " + vnfm.getVnfmId()); - final EsrSystemInfoList systemInfolist = aaiServiceProvider.invokeGetVnfmEsrSystemInfoList(vnfm.getVnfmId()); + final EsrSystemInfoList systemInfolist = vnfm.getEsrSystemInfoList(); if (systemInfolist != null) { for (final EsrSystemInfo esrSystemInfo : systemInfolist.getEsrSystemInfo()) { if (esrSystemInfo.getType().equals(type)) { 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 50e579dd83..1fa62efa25 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 @@ -58,8 +58,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public GenericVnfs invokeQueryGenericVnf(final String selfLink) { return aaiClientProvider.getAaiClient() - .get(GenericVnfs.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam("selflink", selfLink)) + .get(GenericVnfs.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS) + .queryParam("selflink", selfLink.replaceAll("https", "http"))) .orElseGet(() -> { logger.debug("No vnf found in AAI with selflink: {}", selfLink); return null; 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 e66f86b66f..0b5b09ae39 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 @@ -54,7 +54,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { @Override public Optional<InlineResponse201> getVnf(final String vnfSelfLink) { - return httpServiceProvider.get(vnfSelfLink, InlineResponse201.class); + return httpServiceProvider.get(vnfSelfLink.replaceAll("https", "http"), InlineResponse201.class); } @Override @@ -96,7 +96,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { logger.error(errorMessage, exception); throw new VnfmRequestFailureException(errorMessage, exception); } - if (response.getStatusCode() != HttpStatus.OK) { + if (response.getStatusCode() != HttpStatus.CREATED) { final String errorMessage = "Subscription to VNFM " + vnfmId + " returned status code: " + response.getStatusCode() + ", request: " + subscriptionRequest; logger.error(errorMessage); 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 f948f3cfac..9c760b44b1 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 @@ -52,7 +52,7 @@ public class VnfmUrlProvider { * @return the URL of the operation */ public String getOperationUrl(final String vnfmId, final String operationId) { - final String url = UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/vnf_lcm_op_occs/") + final String url = UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("vnf_lcm_op_occs") .pathSegment(operationId).build().toString(); logger.debug("getOperationUrl:" + url); @@ -67,7 +67,7 @@ public class VnfmUrlProvider { */ public String getSubscriptionsUrl(final String vnfmId) { final String url = - UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/subscriptions").build().toString(); + UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("subscriptions").build().toString(); logger.debug("getSubscriptionUrl:" + url); return url; @@ -75,7 +75,7 @@ public class VnfmUrlProvider { public String getCreationUrl(final String vnfmId) { final String url = - UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/vnf_instances").build().toString(); + 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/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java index 32bb9b93a4..a4f7d3206d 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 @@ -95,7 +95,7 @@ public class LifecycleManager { logger.info("Create response: {}", vnfmResponse); - genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref()); + genericVnf.setSelflink(getSelfLink(vnfmResponse, vnfm)); aaiServiceProvider.invokePutGenericVnf(genericVnf); final String vnfIdInVnfm = vnfmResponse.getId(); @@ -111,6 +111,15 @@ public class LifecycleManager { return response; } + private String getSelfLink(final InlineResponse201 vnfmResponse, final EsrVnfm vnfm) { + if (vnfmResponse.getLinks() != null && vnfmResponse.getLinks().getSelf() != null + && vnfmResponse.getLinks().getSelf().getHref() != null) { + return vnfmResponse.getLinks().getSelf().getHref().replaceAll("https", "http"); + } + return vnfm.getEsrSystemInfoList().getEsrSystemInfo().iterator().next().getServiceUrl() + "/vnf_instances/" + + vnfmResponse.getId(); + } + private OamIpAddressSource extractOamIpAddressSource(final CreateVnfRequest request) { final Map<String, String> additionalParams = request.getAdditionalParams(); try { diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 891a57d0f2..182976d69e 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -311,7 +311,7 @@ <dependency> <groupId>org.onap.appc.client</groupId> <artifactId>client-lib</artifactId> - <version>1.5.0-SNAPSHOT</version> + <version>1.6.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.mockito</groupId> @@ -330,7 +330,7 @@ <dependency> <groupId>org.onap.appc.client</groupId> <artifactId>client-kit</artifactId> - <version>1.5.0-SNAPSHOT</version> + <version>1.6.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.mockito</groupId> diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java index e32a03dfa2..cc628657db 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -42,12 +42,14 @@ public class InstanceResourceList { List<Resource> seqResourceList) { Map<String, List<List<GroupResource>>> normalizedRequest = new HashMap<>(); + Resource lastVfProcessed = null; for (Resource r : seqResourceList) { if (r.getResourceType() == ResourceType.VNF) { String pk = getPrimaryKey(r); JsonElement vfNode = reqInputJsonObj.get(pk); + lastVfProcessed = r; // if the service property is type of array then it // means it is a VF resource @@ -67,27 +69,36 @@ public class InstanceResourceList { } else if (r.getResourceType() == ResourceType.GROUP) { String sk = getPrimaryKey(r); - for (String pk : normalizedRequest.keySet()) { - JsonArray vfs = reqInputJsonObj.getAsJsonArray(pk); + // if sk is empty that means it is not list type + if (sk.isEmpty()) { + List<List<GroupResource>> vfList = normalizedRequest.get(getPrimaryKey(lastVfProcessed)); + for (List<GroupResource> grpList : vfList) { + grpList.add((GroupResource) r); + } + continue; + } - for (int i = 0; i < vfs.size(); i++) { + String pk = getPrimaryKey(lastVfProcessed); + JsonArray vfs = reqInputJsonObj.getAsJsonArray(pk); - JsonElement vfcsNode = vfs.get(i).getAsJsonObject().get(sk); - if (vfcsNode instanceof JsonArray) { + for (int i = 0; i < vfs.size(); i++) { - List<GroupResource> groupResources = normalizedRequest.get(pk).get(i); + JsonElement vfcsNode = vfs.get(i).getAsJsonObject().get(sk); + if (vfcsNode instanceof JsonArray) { - if (groupResources == null) { - groupResources = new ArrayList<>(); - normalizedRequest.get(pk).add(i, groupResources); - } + List<GroupResource> groupResources = normalizedRequest.get(pk).get(i); - for (int j = 0; j < ((JsonArray) vfcsNode).size(); j++) { - groupResources.add((GroupResource) r); - } + if (groupResources == null) { + groupResources = new ArrayList<>(); + normalizedRequest.get(pk).add(i, groupResources); + } + + for (int j = 0; j < ((JsonArray) vfcsNode).size(); j++) { + groupResources.add((GroupResource) r); } } } + } } return normalizedRequest; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index 2d0b9e5a99..0338647ce7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -33,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader @@ -84,9 +85,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sdnc_svcAction = "activate" - String sdnc_requestAction = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") - String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".activation-required") - execution.setVariable("isActivateRequired", isActivateRequired) + String sdnc_requestAction = sdnc_svcAction.capitalize() + UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + "Instance" execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) @@ -175,7 +174,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String source = execution.getVariable("source") String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class) - String networkInstanceId = execution.getVariable("networkInstanceId") + String resourceInstanceId = execution.getVariable("resourceInstanceId") String serviceType = resourceInputObj.getServiceType() String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid() @@ -194,6 +193,25 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { // 1. prepare assign topology via SDNC Adapter SUBFLOW call String sdncTopologyActivateRequest = "" String modelType = resourceInputObj.getResourceModelInfo().getModelType() + + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = "" + String vnfmodelInvariantUuid = "" + String vnfmodelCustomizationUuid = "" + String vnfmodelUuid = "" + String vnfmodelVersion = "" + String vnfmodelName = "" + if(modelType.equalsIgnoreCase(ResourceType.GROUP.toString())) { + vnfid = resourceInputObj.getVnfId() + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + vnfmodelUuid = vfModelInfo.getModelUuid() + vnfmodelVersion = vfModelInfo.getModelVersion() + vnfmodelName = vfModelInfo.getModelName() + } + switch (modelType) { case "VNF" : sdncTopologyActivateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" @@ -230,7 +248,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> <vnf-information> - <vnf-id>${msoUtils.xmlEscape(networkInstanceId)}</vnf-id> + <vnf-id>${msoUtils.xmlEscape(resourceInstanceId)}</vnf-id> <vnf-type></vnf-type> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> @@ -254,15 +272,14 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { break case "GROUP" : - sdncTopologyActivateRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + sdncTopologyActivateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> <sdncadapter:RequestHeader> <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -286,23 +303,34 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { </onap-model-information> <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> - <allotted-resource-information> - <!-- TODO: to be filled as per the request input --> - <allotted-resource-id>${msoUtils.xmlEscape(networkInstanceId)}</allotted-resource-id> - <allotted-resource-type></allotted-resource-type> - <parent-service-instance-id>$parentServiceInstanceId</parent-service-instance-id> + <vnf-information> <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + <vnf-id>${msoUtils.xmlEscape(vnfid)}</vnf-id> + </vnf-information> + <vf-module-information> + <from-preload>false</from-preload> + <vf-module-id>${msoUtils.xmlEscape(resourceInstanceId)}</vf-module-id> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> <model-name>${msoUtils.xmlEscape(modelName)}</model-name> </onap-model-information> - </allotted-resource-information> - <connection-attachment-request-input> - $netowrkInputParameters - </connection-attachment-request-input> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> + $netowrkInputParameters + </vf-module-input-parameters> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break @@ -344,7 +372,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { </service-information> <network-information> <!-- TODO: to be filled by response from create --> - <network-id>${msoUtils.xmlEscape(networkInstanceId)}</network-id> + <network-id>${msoUtils.xmlEscape(resourceInstanceId)}</network-id> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 4c4b63101f..23c11ca4dc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -102,7 +102,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sdnc_svcAction = "create" - String sdnc_requestAction = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + String sdnc_requestAction = sdnc_svcAction.capitalize() + UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + "Instance" String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".activation-required") execution.setVariable("isActivateRequired", isActivateRequired) @@ -352,7 +352,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String vnfmodelName = "" String modelType = resourceInputObj.getResourceModelInfo().getModelType() if(modelType.equalsIgnoreCase(ResourceType.GROUP.toString())) { - vnfid = resourceInputObj.getVnfId(); + vnfid = resourceInputObj.getVnfId() ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() @@ -397,7 +397,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> <vnf-information> - <vnf-id>${msoUtils.xmlEscape(vnfid)}</vnf-id> <vnf-type></vnf-type> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> @@ -427,7 +426,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -454,24 +453,30 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> <vnf-information> + <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + <vnf-id>${msoUtils.xmlEscape(vnfid)}</vnf-id> </vnf-information> - <vnf-request-input> - <vnf-input-parameters> + <vf-module-information> + <from-preload>false</from-preload> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> $netowrkInputParameters - </vnf-input-parameters> - <request-version></request-version> - <vnf-name></vnf-name> - <vnf-networks> - </vnf-networks> - </vnf-request-input> - <connection-attachment-request-input> - $netowrkInputParameters - </connection-attachment-request-input> + </vf-module-input-parameters> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn index 0bdc6dc0bd..5a4b3ac348 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.16.2"> <bpmn:process id="CreateSDNCNetworkResource" name="CreateSDNCNetworkResource" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent" name="createNS_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> @@ -137,8 +137,7 @@ dcsi.prepareUpdateAfterCreateSDNCResource(execution)</bpmn:script> <camunda:in source="requestAction" target="requestAction" /> <camunda:in source="URN_mso_workflow_sdncadapter_callback" target="URN_mso_workflow_sdncadapter_callback" /> <camunda:in source="networkRequest" target="networkRequest" /> - <camunda:in source="networkInstanceId" target="networkInstanceId" /> - <camunda:in source="parentServiceInstanceId" target="parentServiceInstanceId" /> + <camunda:in source="resourceInstanceId" target="resourceInstanceId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1dww8ye</bpmn:incoming> <bpmn:outgoing>SequenceFlow_05niqbf</bpmn:outgoing> @@ -309,4 +308,4 @@ dcsi.afterCreateSDNCCall(execution)</bpmn:script> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> |