diff options
52 files changed, 1089 insertions, 235 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java index fbaf12b337..283fef1d3b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -26,7 +28,6 @@ import java.io.ByteArrayOutputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index b89c6275d4..3b50871a8d 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -71,10 +73,10 @@ public class QueryServiceMacroHolder extends CatalogQuery { StringBuilder buf = new StringBuilder(); Map<String, String> valueMap = new HashMap<>(); - put(valueMap, "SERVICE_MODEL_NAME", service.getModelName()); //getServiceModelName()); - put(valueMap, "SERVICE_MODEL_UUID", service.getModelUUID()); //getServiceModelUuid()); - put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID()); //getServiceModelInvariantId()); - put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion()); //getServiceModelVersion()); + put(valueMap, "SERVICE_MODEL_NAME", service.getModelName()); + put(valueMap, "SERVICE_MODEL_UUID", service.getModelUUID()); + put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID()); + put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion()); put(valueMap, "SERVICE_TYPE", service.getServiceType()); put(valueMap, "SERVICE_ROLE", service.getServiceRole()); put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext()); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.3__ScaleOutRecipe.sql index b3d8b98176..3ae135fc56 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.3__ScaleOutRecipe.sql @@ -1,5 +1,5 @@ use catalogdb; -INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) +INSERT IGNORE INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) VALUES ('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT'); diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java index fd2ec179dc..d638e47e8c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java @@ -2,6 +2,8 @@ package db.migration; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.flywaydb.core.api.MigrationVersion; @@ -13,9 +15,13 @@ import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.logger.MsoLogger; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.Collection; @@ -33,10 +39,31 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro @Override public void migrate(Connection connection) throws Exception { LOGGER.debug("Starting migration for CloudConfig"); - CloudConfig cloudConfig = loadCloudConfig(); - if(cloudConfig == null){ - LOGGER.debug("No CloudConfig defined in :"+getApplicationYamlName()+" exiting."); - }else{ + + CloudConfig cloudConfig = null; + + // Try the override file + String configLocation = System.getProperty("spring.config.location"); + if (configLocation != null) { + try (InputStream stream = new FileInputStream(configLocation)) { + cloudConfig = loadCloudConfig(stream); + } + } + + if (cloudConfig == null) { + LOGGER.debug("No CloudConfig defined in " + configLocation); + + // Try the application.yaml file + try (InputStream stream = R__CloudConfigMigration.class.getResourceAsStream(getApplicationYamlName())) { + cloudConfig = loadCloudConfig(stream); + } + + if (cloudConfig == null) { + LOGGER.debug("No CloudConfig defined in " + getApplicationYamlName()); + } + } + + if(cloudConfig != null){ migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection); migrateCloudSite(cloudConfig.getCloudSites().values(), connection); migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection); @@ -51,13 +78,14 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro this.cloudConfig = cloudConfig; } - private CloudConfig loadCloudConfig() throws Exception { + private CloudConfig loadCloudConfig(InputStream stream) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - R__CloudConfigMigration cloudConfigMigration = mapper.readValue(R__CloudConfigMigration.class - .getResourceAsStream(getApplicationYamlName()), R__CloudConfigMigration.class); + R__CloudConfigMigration cloudConfigMigration = + mapper.readValue(stream, R__CloudConfigMigration.class); CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig(); + if(cloudConfig != null){ - cloudConfig.populateId(); + cloudConfig.populateId(); } return cloudConfig; @@ -68,12 +96,12 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro return "/application" + profile + ".yaml"; } - private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws Exception { + private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->IdentityService"); String insert = "INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?,?);"; - PreparedStatement ps = connection.prepareStatement(insert); - try (Statement stmt = connection.createStatement()) { + + try (Statement stmt = connection.createStatement();PreparedStatement ps = connection.prepareStatement(insert)) { for (CloudIdentity cloudIdentity : entities) { try (ResultSet rows = stmt.executeQuery("Select count(1) from identity_services where id='" + cloudIdentity.getId() + "'")) { int count = 0; @@ -98,12 +126,12 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws Exception { + private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->CloudSite"); String insert = "INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?);"; - PreparedStatement ps = connection.prepareStatement(insert); - try (Statement stmt = connection.createStatement()) { + + try (Statement stmt = connection.createStatement();PreparedStatement ps = connection.prepareStatement(insert)) { for (CloudSite cloudSite : entities) { try (ResultSet rows = stmt.executeQuery("Select count(1) from cloud_sites where id='" + cloudSite.getId() + "'")) { int count = 0; @@ -127,11 +155,11 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws Exception { + private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws SQLException { String insert = "INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`)" + " VALUES (?,?,?,?,?,?);"; - PreparedStatement ps = connection.prepareStatement(insert); - try (Statement stmt = connection.createStatement()) { + + try (Statement stmt = connection.createStatement();PreparedStatement ps = connection.prepareStatement(insert)) { for (CloudifyManager cloudifyManager : entities) { try (ResultSet rows = stmt.executeQuery("Select count(1) from cloudify_managers where id='" + cloudifyManager.getId() + "'")) { int count = 0; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java index b483d40b8a..83db2add0a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -643,13 +645,14 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <> (); - sMap = hMap.value; + Map <String, String> sMap = hMap.value; CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry (); - for (String key : sMap.keySet ()) { + for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) { + String key = mapEntry.getKey(); + String value = mapEntry.getValue(); entry.setKey (key); - entry.setValue (sMap.get (key)); + entry.setValue (value); subnetIdMap.getEntry ().add (entry); } } @@ -661,8 +664,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <> (); - sMap = hMap.value; + Map <String, String> sMap = hMap.value; UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry (); for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) { @@ -681,8 +683,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <> (); - sMap = hMap.value; + Map <String, String> sMap = hMap.value; QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry (); for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) { diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 4a4c83e4a5..4b2cf8eb60 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -41,4 +41,6 @@ management: flyway: outOfOrder: true - ignoreMissingMigrations: true
\ No newline at end of file + ignoreMissingMigrations: true + baseline-on-migrate: true + validate-on-migrate: false diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java index dea6512d38..34bf9cb0f5 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java @@ -24,12 +24,13 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; + -import javax.ws.rs.PathParam; import java.util.List; import java.util.Map; @@ -38,20 +39,24 @@ public class InfraActiveRequestsRepositoryCustomController { @Autowired InfraActiveRequestsRepository infraActiveRequestsRepository; + @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive") - public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(@RequestBody Map<String, String> orchestrationMap){ + public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(@RequestBody Map<String, String> orchestrationMap) { return infraActiveRequestsRepository.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap); } + @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive") - public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(@RequestBody Map<String, List<String>> orchestrationMap){ - return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap); + public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(@RequestBody Map<String, List<String>> orchestrationMap) { + return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap); } - @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/checkVnfIdStatus/{nsInstanceId}") - public InfraActiveRequests checkVnfIdStatus(@PathParam("nsInstanceId") String operationalEnvironmentId){ + + @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}") + public InfraActiveRequests checkVnfIdStatus(@PathVariable("operationalEnvironmentId") String operationalEnvironmentId) { return infraActiveRequestsRepository.checkVnfIdStatus(operationalEnvironmentId); } + @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/checkInstanceNameDuplicate") - public InfraActiveRequests checkInstanceNameDuplicate(@RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest){ - return infraActiveRequestsRepository.checkInstanceNameDuplicate(instanceNameDuplicateCheckRequest.getInstanceIdMap(), instanceNameDuplicateCheckRequest.getInstanceName(),instanceNameDuplicateCheckRequest.getRequestScope()); + public InfraActiveRequests checkInstanceNameDuplicate(@RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) { + return infraActiveRequestsRepository.checkInstanceNameDuplicate(instanceNameDuplicateCheckRequest.getInstanceIdMap(), instanceNameDuplicateCheckRequest.getInstanceName(), instanceNameDuplicateCheckRequest.getRequestScope()); } } diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java new file mode 100644 index 0000000000..58eb0085ad --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java @@ -0,0 +1,244 @@ +package org.onap.so.adapters.requestsdb; + + +import org.junit.Before; +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.requestsdb.application.MSORequestDBApplication; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.UUID; +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = MSORequestDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@Transactional +public class InfraActiveRequestsRepositoryCustomControllerTest { + + @LocalServerPort + private int port; + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } + + private InfraActiveRequests infraActiveRequests; + private InfraActiveRequests infraActiveRequestsResponse; + private HttpHeaders headers; + private TestRestTemplate restTemplate; + + private void verifyInfraActiveRequests() { + assertEquals(infraActiveRequests.getRequestId(), infraActiveRequestsResponse.getRequestId()); + assertEquals(infraActiveRequests.getServiceInstanceId(), infraActiveRequestsResponse.getServiceInstanceId()); + assertEquals(infraActiveRequests.getServiceInstanceName(), infraActiveRequestsResponse.getServiceInstanceName()); + assertEquals(infraActiveRequests.getVnfId(), infraActiveRequestsResponse.getVnfId()); + assertEquals(infraActiveRequests.getVnfName(), infraActiveRequestsResponse.getVnfName()); + assertEquals(infraActiveRequests.getVfModuleId(), infraActiveRequestsResponse.getVfModuleId()); + assertEquals(infraActiveRequests.getVfModuleName(), infraActiveRequestsResponse.getVfModuleName()); + assertEquals(infraActiveRequests.getVolumeGroupId(), infraActiveRequestsResponse.getVolumeGroupId()); + assertEquals(infraActiveRequests.getVolumeGroupName(), infraActiveRequestsResponse.getVolumeGroupName()); + assertEquals(infraActiveRequests.getNetworkId(), infraActiveRequestsResponse.getNetworkId()); + assertEquals(infraActiveRequests.getNetworkName(), infraActiveRequestsResponse.getNetworkName()); + assertEquals(infraActiveRequests.getConfigurationId(), infraActiveRequestsResponse.getConfigurationId()); + assertEquals(infraActiveRequests.getConfigurationName(), infraActiveRequestsResponse.getConfigurationName()); + assertEquals(infraActiveRequests.getAaiServiceId(), infraActiveRequestsResponse.getAaiServiceId()); + assertEquals(infraActiveRequests.getTenantId(), infraActiveRequestsResponse.getTenantId()); + assertEquals(infraActiveRequests.getRequestScope(), infraActiveRequestsResponse.getRequestScope()); + assertEquals(infraActiveRequests.getRequestorId(), infraActiveRequestsResponse.getRequestorId()); + assertEquals(infraActiveRequests.getSource(), infraActiveRequestsResponse.getSource()); + assertEquals(infraActiveRequests.getOperationalEnvId(), infraActiveRequestsResponse.getOperationalEnvId()); + assertEquals(infraActiveRequests.getOperationalEnvName(), infraActiveRequestsResponse.getOperationalEnvName()); + assertEquals(infraActiveRequests.getRequestStatus(), infraActiveRequestsResponse.getRequestStatus()); + assertEquals(infraActiveRequests.getAction(), infraActiveRequestsResponse.getAction()); + } + + @Before + public void setup() { + + headers = new HttpHeaders(); + restTemplate = new TestRestTemplate("test", "test"); + + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + + infraActiveRequests = new InfraActiveRequests(); + + infraActiveRequests.setRequestId(UUID.randomUUID().toString()); + infraActiveRequests.setOperationalEnvId(UUID.randomUUID().toString()); + infraActiveRequests.setServiceInstanceId(UUID.randomUUID().toString()); + infraActiveRequests.setServiceInstanceName("serviceInstanceNameTest"); + infraActiveRequests.setVnfId(UUID.randomUUID().toString()); + infraActiveRequests.setVnfName("vnfInstanceNameTest"); + infraActiveRequests.setVfModuleId(UUID.randomUUID().toString()); + infraActiveRequests.setVfModuleName("vfModuleInstanceNameTest"); + infraActiveRequests.setVolumeGroupId(UUID.randomUUID().toString()); + infraActiveRequests.setVolumeGroupName("volumeGroupInstanceNameTest"); + infraActiveRequests.setNetworkId(UUID.randomUUID().toString()); + infraActiveRequests.setNetworkName("networkInstanceNameTest"); + infraActiveRequests.setConfigurationId(UUID.randomUUID().toString()); + infraActiveRequests.setConfigurationName("configurationInstanceNameTest"); + infraActiveRequests.setAicCloudRegion("1"); + infraActiveRequests.setTenantId(UUID.randomUUID().toString()); + infraActiveRequests.setRequestScope("operationalEnvironment"); + infraActiveRequests.setRequestorId(UUID.randomUUID().toString()); + infraActiveRequests.setSource("sourceTest"); + infraActiveRequests.setOperationalEnvName(UUID.randomUUID().toString()); + infraActiveRequests.setRequestStatus("IN_PROGRESS"); + infraActiveRequests.setAction("create"); + + HttpEntity<String> entity = new HttpEntity(infraActiveRequests, headers); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests")); + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entity, String.class); + + assertEquals(201, response.getStatusCodeValue()); + } + + + @Test + public void getCloudOrchestrationFiltersFromInfraActiveTest() { + + Map<String, String> requestMap = new HashMap<>(); + requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId()); + requestMap.put("operationalEnvironmentName", infraActiveRequests.getOperationalEnvName()); + requestMap.put("resourceType", "operationalEnvironment"); + + HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestMap, headers); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getCloudOrchestrationFiltersFromInfraActive"); + + ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() { + }); + + List<InfraActiveRequests> iarr = response.getBody(); + assertEquals(200, response.getStatusCodeValue()); + + assertTrue(iarr.size() == 1); + infraActiveRequestsResponse = iarr.get(0); + + verifyInfraActiveRequests(); + + } + + @Test + public void getOrchestrationFiltersFromInfraActiveTest() { + + Map<String, List<String>> requestMap = new HashMap<>(); + List<String> values = new ArrayList<>(); + values.add("EQUALS"); + values.add(infraActiveRequests.getServiceInstanceId()); + requestMap.put("serviceInstanceId", values); + + values = new ArrayList<>(); + values.add("EQUALS"); + values.add(infraActiveRequests.getServiceInstanceName()); + requestMap.put("serviceInstanceName", values); + + HttpEntity<Map<String, List<String>>> entityList = new HttpEntity(requestMap, headers); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/getOrchestrationFiltersFromInfraActive"); + + ResponseEntity<List<InfraActiveRequests>> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entityList, new ParameterizedTypeReference<List<InfraActiveRequests>>() { + }); + + List<InfraActiveRequests> iarr = response.getBody(); + + assertEquals(200, response.getStatusCodeValue()); + + assertTrue(iarr.size() == 1); + infraActiveRequestsResponse = iarr.get(0); + + verifyInfraActiveRequests(); + } + + @Test + public void checkVnfIdStatusTest() { + + HttpEntity<List<String>> entityList = new HttpEntity("", headers); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests" + "/checkVnfIdStatus/" + infraActiveRequests.getOperationalEnvId())); + + ResponseEntity<InfraActiveRequests> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, HttpEntity.EMPTY, InfraActiveRequests.class); + + infraActiveRequestsResponse = response.getBody(); + + assertEquals(200, response.getStatusCodeValue()); + + verifyInfraActiveRequests(); + } + + @Test + public void checkInstanceNameDuplicateTest() { + + InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) null, + infraActiveRequests.getOperationalEnvName(), + infraActiveRequests.getRequestScope()); + + HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate"); + + ResponseEntity<InfraActiveRequests> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() { + }); + + infraActiveRequestsResponse = response.getBody(); + + assertEquals(200, response.getStatusCodeValue()); + + verifyInfraActiveRequests(); + } + + @Test + public void checkInstanceNameDuplicateViaTest() { + + Map<String, String> requestMap = new HashMap<>(); + requestMap.put("operationalEnvironmentId", infraActiveRequests.getOperationalEnvId()); + + InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest = new InstanceNameDuplicateCheckRequest((HashMap<String, String>) requestMap, + null, + infraActiveRequests.getRequestScope()); + + HttpEntity<InstanceNameDuplicateCheckRequest> entityList = new HttpEntity(instanceNameDuplicateCheckRequest, headers); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/infraActiveRequests") + "/checkInstanceNameDuplicate"); + + ResponseEntity<InfraActiveRequests> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entityList, new ParameterizedTypeReference<InfraActiveRequests>() { + }); + + infraActiveRequestsResponse = response.getBody(); + + assertEquals(200, response.getStatusCodeValue()); + + verifyInfraActiveRequests(); + } +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml index c3be9323fb..6a5db78f8b 100644 --- a/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-requests-db-adapter/src/test/resources/application-test.yaml @@ -10,7 +10,7 @@ mso: site-name: localSite infra-requests: archived: - period: 1 + period: 0 spring: datasource: url: jdbc:mariadb://localhost:3307/requestdb diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index ba450c1b12..58c8f27de9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -7,9 +7,9 @@ * 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. @@ -281,14 +281,14 @@ class SDNCAdapterUtils { } boolean isAic3 = execution.getVariable("isAic3") - + if(isAic3) { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") } else { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X") } - + String content = """ <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1" xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1"> @@ -319,7 +319,7 @@ class SDNCAdapterUtils { /** * Builds an SDNC "reserve" request and stores it in the specified execution - * variable. + * variable. * @param execution the execution * @param action the type of action: reserve, turnup, etc * @param resultVar the execution variable in which the result will be stored @@ -424,7 +424,7 @@ class SDNCAdapterUtils { if (additionalData == null) { additionalData = "" } - + if(isAic3) { nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") } @@ -470,7 +470,7 @@ class SDNCAdapterUtils { exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error") } } - + public String updateHomingInfo(String homingInfo, String aicVersion) { String newHomingInfo if(homingInfo == null || homingInfo.trim().length() == 0) { @@ -480,7 +480,7 @@ class SDNCAdapterUtils { newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>" } } - + /** * Builds a topology SDNC request and return String request. * As V2 will use 1607-style request, region instead of aic clli code @@ -506,7 +506,7 @@ class SDNCAdapterUtils { } else { hdrRequestId = testHdrRequestId } - + String requestId = "" try { requestId = execution.getVariable("mso-request-id") @@ -561,6 +561,9 @@ class SDNCAdapterUtils { int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/") subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd) subscriberName = UriUtils.decode(subscriberName,"UTF-8") + }else{ + serviceType = execution.getVariable("serviceType") + subscriberName = execution.getVariable("subscriberName") } String content = @@ -635,11 +638,11 @@ class SDNCAdapterUtils { requestId = execution.getVariable("mso-request-id") if (requestId == null) { requestId = execution.getVariable("msoRequestId") - } + } } else { requestId = testRequestId - } - + } + String aicCloudRegion = cloudRegionId String tenantId = "" if (utils.nodeExists(requestXML, "tenant-id")) { @@ -717,7 +720,7 @@ class SDNCAdapterUtils { String content = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/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> @@ -993,7 +996,7 @@ class SDNCAdapterUtils { exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg) } } - + public String modelInfoToEcompModelInformation(String jsonModelInfo) { String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid") String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid") @@ -1004,11 +1007,11 @@ class SDNCAdapterUtils { String modelCustomizationString = "" if (modelCustomizationUuid != null) { modelCustomizationString = "<model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>" - } + } String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion") if (modelVersion == null) { modelVersion = "" - } + } String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName") String ecompModelInformation = """<onap-model-information> @@ -1019,6 +1022,6 @@ class SDNCAdapterUtils { <model-name>${MsoUtils.xmlEscape(modelName)}</model-name> </onap-model-information>""" - return ecompModelInformation - } + return ecompModelInformation + } }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index b5203c676a..67fb6a6f37 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -346,13 +346,15 @@ public class BBInputSetup implements JavaDelegate { ModelInfo vnfModelInfo = new ModelInfo(); vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); this.mapCatalogVnf(tempVnf, vnfModelInfo, service); - for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { - String volumeGroupCustId = - this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, - cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); - if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { - lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - break; + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { + for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { + String volumeGroupCustId = + this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); + if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); + break; + } } } break; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java new file mode 100644 index 0000000000..768bee578c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowProcessorException.java @@ -0,0 +1,19 @@ +package org.openecomp.mso.bpmn.common.workflow.service; + +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + +/** + * Exception thrown when an error occurs while processing the workflow. + * This encapsulates the workflow response so that the same can be sent back to api handler. + */ +public class WorkflowProcessorException extends RuntimeException { + WorkflowResponse workflowResponse; + + public WorkflowProcessorException(WorkflowResponse workflowResponse) { + this.workflowResponse = workflowResponse; + } + + public WorkflowResponse getWorkflowResponse() { + return workflowResponse; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy new file mode 100644 index 0000000000..5deec5b434 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.scripts + +import org.junit.Before +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.NetworkResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.DecomposeJsonUtil +import org.onap.so.bpmn.core.domain.ServiceInstance + +import org.onap.so.bpmn.mock.FileUtil +import static org.mockito.Mockito.* +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import static org.junit.Assert.*; +import org.junit.Test; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; + +class DecomposeServiceTest { + + @Test + public void testDecomposeService() { + + String catalogDbResponse = FileUtil.readResourceFile("__files/decomposition/catalogDbResponse.json"); + + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId("serviceInstanceID"); + serviceDecomposition.setServiceType(""); + serviceDecomposition.setServiceRole(""); + + ArrayList networkResources = new ArrayList(); + NetworkResource networkResource = new NetworkResource(); + networkResource.setNetworkType("testNetworkType"); + networkResource.setNetworkRole("testNetworkRole"); + networkResource.setNetworkScope("testNetworkScope"); + networkResource.setToscaNodeType("testToscaModelType") + networkResource.setNetworkTechnology("testNetworkTechnology"); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelName("testModleName"); + modelInfo.setModelUuid("testModelUuid") + modelInfo.setModelInvariantUuid("testModelInvariantId") + modelInfo.setModelVersion("testModelVersion"); + modelInfo.setModelCustomizationUuid("testModelCustomizationUuid"); + modelInfo.setModelInstanceName("testModelInstanceName"); + networkResource.setModelInfo(modelInfo); + + networkResources.add(networkResource); + serviceDecomposition.setNetworkResources(networkResources) + serviceDecomposition.setServiceInstance(serviceInstance); + + ServiceDecomposition serviceDecompositionExtracted = DecomposeJsonUtil.jsonToServiceDecomposition(catalogDbResponse, "serviceInstanceID") + + assertThat(serviceDecompositionExtracted, sameBeanAs(serviceDecomposition).ignoring("modelInfo").ignoring("vnfResources").ignoring("allottedResources").ignoring("networkResources.resourceId")); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json new file mode 100644 index 0000000000..087233d08b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json @@ -0,0 +1,33 @@ +{ + "serviceResources": { + "serviceType": "", + "workloadContext": "testWorkloadContext", + "serviceAllottedResources": [], + "modelInfo": { + "modelInvariantUuid": "testModelInvariantId", + "modelName": "testModleName", + "modelVersion": "testModelVersion", + "modelUuid": "testModelUuid" + }, + "environmentContext": "testEnvironmentContent", + "serviceRole": "", + "serviceVnfs": [], + "serviceNetworks": [ + { + "toscaNodeType": "testToscaModelType", + "networkTechnology": "testNetworkTechnology", + "networkScope": "testNetworkScope", + "modelInfo": { + "modelInvariantUuid": "testModelInvariantId", + "modelName": "testModleName", + "modelVersion": "testModelVersion", + "modelCustomizationUuid": "testModelCustomizationUuid", + "modelInstanceName": "testModelInstanceName", + "modelUuid": "testModelUuid" + }, + "networkRole": "testNetworkRole", + "networkType": "testNetworkType" + } + ] + } +}
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java index 099f084637..5e7a4796c4 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java @@ -69,7 +69,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { private OwningEntity owningEntity; @JsonProperty("serviceVnfs") private List <VnfResource> vnfResources; - @JsonProperty("networkResource") + @JsonProperty("serviceNetworks") private List <NetworkResource> networkResources; @JsonProperty("serviceAllottedResources") private List <AllottedResource> allottedResources; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java index 6d2db0ca33..4295f50a3c 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java @@ -7,9 +7,9 @@ * 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. @@ -46,6 +46,8 @@ public class ServiceInstance extends JsonWrapper implements Serializable { private String environmentContext; private String workloadContext; private Map serviceParams; + private Customer customer = new Customer(); + private String e2eVpnKey; public String getServiceType() { return serviceType; @@ -113,4 +115,15 @@ public class ServiceInstance extends JsonWrapper implements Serializable { public void setServiceRole(String serviceRole) { this.serviceRole = serviceRole; } -}
\ No newline at end of file + public Customer getCustomer(){ + return customer; + } + + public String getE2eVpnKey(){ + return e2eVpnKey; + } + + public void setE2eVpnKey(String e2eVpnKey){ + this.e2eVpnKey = e2eVpnKey; + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java index 82470f125b..5d8d55152c 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java @@ -103,6 +103,8 @@ public class ServiceDecompositionTest { serviceDecomp.addResource(allottedResource); serviceDecomp.addResource(configResource); + System.out.println(serviceDecomp.toJsonString()); + assertThat(serviceDecomp.getServiceResource(vnfResource.getResourceId()), sameBeanAs(vnfResource)); assertThat(serviceDecomp.getServiceResource(networkResource.getResourceId()), sameBeanAs(networkResource)); assertThat(serviceDecomp.getServiceResource(allottedResource.getResourceId()), sameBeanAs(allottedResource)); diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json index c424293ca2..f094e99782 100644 --- a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json +++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceDecompositionExpected.json @@ -1,51 +1,59 @@ { - "serviceResources" : { - "modelInfo" : { - "modelName" : "modelName", - "modelUuid" : "modelUuid", - "modelInvariantUuid" : "modelInvariantUuid", - "modelVersion" : "modelVersion", - "modelCustomizationUuid" : "modelCustomizationUuid", - "modelCustomizationName" : "modelCustomizationName", - "modelInstanceName" : "modelInstanceName", - "modelType" : "modelType" - }, - "serviceType" : "serviceType", - "serviceRole" : "serviceRole", - "project" : {}, - "owningEntity" : {}, - "serviceInstance" : { - "serviceInstanceId" : "serviceInstanceId" - }, - "serviceVnfs" : [ - { - "resourceId" : "vnfResourceId", - "resourceType" : "VNF", - "resourceInstance" : {}, - "homingSolution" : { - "license" : {}, - "rehome" : false - }, - "vfModules" : [] - } - ], - "networkResource" : [ - { - "resourceId" : "networkResourceId", - "resourceType" : "NETWORK" - } - ], - "serviceAllottedResources" : [ - { - "resourceId" : "allottedResourceId", - "resourceType" : "ALLOTTED_RESOURCE" - } - ], - "configResource" : [ - { - "resourceId" : "configResourceId", - "resourceType" : "CONFIGURATION" - } - ] - } -} + "serviceResources" : { + "serviceInstance" : { + "instanceId" : "serviceInstanceId", + "customer" : { } + }, + "modelInfo" : { + "modelName" : "modelName", + "modelUuid" : "modelUuid", + "modelInvariantUuid" : "modelInvariantUuid", + "modelVersion" : "modelVersion", + "modelCustomizationUuid" : "modelCustomizationUuid", + "modelCustomizationName" : "modelCustomizationName", + "modelInstanceName" : "modelInstanceName", + "modelType" : "modelType" + }, + "serviceType" : "serviceType", + "serviceRole" : "serviceRole", + "project" : { }, + "owningEntity" : { }, + "serviceVnfs" : [ { + "resourceId" : "vnfResourceId", + "resourceType" : "VNF", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + }, + "vfModules" : [ ] + } ], + "serviceNetworks" : [ { + "resourceId" : "networkResourceId", + "resourceType" : "NETWORK", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ], + "serviceAllottedResources" : [ { + "resourceId" : "allottedResourceId", + "resourceType" : "ALLOTTED_RESOURCE", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ], + "configResource" : [ { + "resourceId" : "configResourceId", + "resourceType" : "CONFIGURATION", + "resourceInstance" : { }, + "homingSolution" : { + "license" : { }, + "rehome" : false + } + } ] + } +}
\ No newline at end of file diff --git a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json b/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json deleted file mode 100644 index b8c123eb15..0000000000 --- a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterface.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "interface-name": "Xe-7/1/10", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } -} diff --git a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json b/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json deleted file mode 100644 index 9ea3869121..0000000000 --- a/bpmn/att-services-bpmn/src/test/resources/__files/dhv/DHVChangeSpeed/getPInterfaces.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "p-interface": [ - { - "interface-name": "Xe-7/1/10", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } - }, - { - "interface-name": "Xe-8/2/11", - "port-description": "VVIG EGRESS", - "resource-version": "1494002035673", - "relationship-list": { - "relationship": [ - { - "related-to": "physical-link", - "related-link": "/aai/v11/network/physical-links/physical-link/testPhysicalLinkUcpe2", - "relationship-data": [ - { - "relationship-key": "physical-link.link-name", - "relationship-value": "L4YS.999964..ATI_EGRESS" - } - ] - } - ] - } - } - ] -}
\ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index cfd07d8c39..ef72149d10 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContext; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -92,7 +93,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { /** * Asynchronous JAX-RS method that starts a process instance. - * @param asyncResponse an object that will receive the asynchronous response * @param processKey the process key * @param variableMap input variables to the process * @return @@ -114,7 +114,10 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); return Response.status(202).entity(response).build(); - } catch (Exception e) { + } catch (WorkflowProcessorException e) { + WorkflowResponse response = e.getWorkflowResponse(); + return Response.status(500).entity(response).build(); + }catch (Exception e) { WorkflowResponse response = buildUnkownError(getRequestId(inputVariables),e.getMessage()); return Response.status(500).entity(response).build(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index edc05afba2..da24ba14fd 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -28,11 +28,10 @@ import java.util.UUID; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; -import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -79,13 +78,12 @@ public class WorkflowProcessor extends ProcessEngineAwareService { msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, logMarker + "Error in starting the process: " + e.getMessage()); - WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); - callbackResponse.setStatusCode(500); - callbackResponse.setMessage("Fail"); - callbackResponse.setResponse("Error occurred while executing the process: " + e); - - WorkflowContextHolder.getInstance().processCallback(processKey, processInstanceId, - getRequestId(inputVariables), callbackResponse); + WorkflowResponse workflowResponse = new WorkflowResponse(); + workflowResponse.setResponse("Error occurred while executing the process: " + e); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(500); + workflowResponse.setMessage("Fail"); + throw new WorkflowProcessorException(workflowResponse); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java new file mode 100644 index 0000000000..ff5e18c210 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResourceExceptionHandlingTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.workflow.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.core.Response; + +import org.camunda.bpm.engine.test.Deployment; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; +import org.junit.Test; +import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; + + +public class WorkflowAsyncResourceExceptionHandlingTest { + + @Test + @Deployment(resources = { "testAsyncResource.bpmn" }) + public void asyncRequestSuccess() throws InterruptedException { + VariableMapImpl variableMap = new VariableMapImpl(); + + Map<String, Object> variableValueType = new HashMap<>(); + + Map<String, Object> requestMsg = new HashMap<>(); + requestMsg.put("value", ""); + requestMsg.put("type", "String"); + + Map<String, Object> msorequestId = new HashMap<>(); + msorequestId.put("type", "String"); + msorequestId.put("value",UUID.randomUUID().toString()); + + Map<String, Object> timeout = new HashMap<>(); + timeout.put("type", "String"); + timeout.put("value","5"); + + variableValueType.put("testAsyncRequestMsg", requestMsg); + variableValueType.put("mso-request-id", msorequestId); + variableValueType.put("mso-service-request-timeout", timeout); + + variableMap.put("variables", variableValueType); + WorkflowAsyncResource workflowAsyncResource = new WorkflowAsyncResource(); + workflowAsyncResource.setProcessor(new WorkflowProcessor()); + Response res = workflowAsyncResource.startProcessInstanceByKey("randomKey", variableMap); + assertEquals(500,res.getStatus()); + WorkflowResponse workflowResponse = (WorkflowResponse)res.getEntity(); + assertNotNull(workflowResponse); + assertEquals(500, workflowResponse.getMessageCode()); + assertTrue(workflowResponse.getResponse().startsWith("Error occurred while executing the process:")); + assertEquals("Fail", workflowResponse.getMessage()); + + + } + +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index abc017c957..bd24eeaed7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -29,7 +29,7 @@ <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn index a95dc9ce73..ffe74d1295 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn @@ -28,7 +28,7 @@ <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kfkpbh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_06flg6h</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 07d0b18938..832a96cae7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -24,7 +24,7 @@ <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="deleteVfModuleRequest" target="deleteVfModuleRequest" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="heatStackId" target="heatStackId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml index 0b998c7268..d7bb084195 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml @@ -183,12 +183,14 @@ policy: sniro: conductor: enabled: true - host: http://localhost:8446 + host: http://localhost:${wiremock.server.port} uri: /v1/release-orders headers.auth: Basic dGVzdDp0ZXN0cHdk manager: - host: http://localhost:8446 - uri: /sniro/api/placement/v2 + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 headers.auth: Basic dGVzdDp0ZXN0cHdk headers.patchVersion: 1 headers.minorVersion: 1 @@ -217,4 +219,4 @@ camunda: bpm: metrics: enabled: false - db-reporter-activate: false
\ No newline at end of file + db-reporter-activate: false diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index a376e581fe..731d9c24de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -330,6 +330,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("subscriberName", keys.get("global-customer-id")) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 4f6fbf9966..d7f2087c05 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -328,6 +328,10 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("subscriberName", keys.get("global-customer-id")) } }catch(BpmnError e) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 9c1fba62e9..b059a77641 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -144,9 +144,11 @@ public class AAIUpdateTasks { public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + String heatStackId = execution.getVariable("heatStackId"); VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); + volumeGroup.setHeatStackId(heatStackId); aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); } catch (Exception ex) { @@ -296,8 +298,10 @@ public class AAIUpdateTasks { public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { try { + String heatStackId = execution.getVariable("heatStackId"); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vfModule.setHeatStackId(heatStackId); aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index aa865f0340..554af37924 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -65,6 +65,7 @@ public class VnfAdapterImpl { execution.setVariable("isDebugLogEnabled", "true"); execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); + execution.setVariable("heatStackId", null); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -80,22 +81,25 @@ public class VnfAdapterImpl { String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if(!StringUtils.isEmpty(heatStackId)) { vfModule.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); } } else if(vnfRestResponse instanceof DeleteVfModuleResponse) { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if(null!= vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); + execution.setVariable("heatStackId", null); } } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId(); if(!StringUtils.isEmpty(heatStackId)) { volumeGroup.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); }else{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response."); } - } + } } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index c6a63e1431..0fa0c69118 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -88,6 +88,7 @@ public class WorkflowAction { private static final String VOLUMEGROUP = "VolumeGroup"; private static final String NETWORK = "Network"; private static final String NETWORKCOLLECTION = "NetworkCollection"; + private static final String CONFIGURATION = "Configuration"; private static final String ASSIGNINSTANCE = "assignInstance"; private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; @@ -136,6 +137,7 @@ public class WorkflowAction { RequestDetails requestDetails = sIRequest.getRequestDetails(); Resource resource = extractResourceIdAndTypeFromUri(uri); WorkflowType resourceType = resource.getResourceType(); + execution.setVariable("resourceName", resourceType.toString()); String resourceId = ""; if (resource.isGenerated()) { resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType, @@ -240,7 +242,7 @@ public class WorkflowAction { } if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && !resourceCounter.stream().filter(x -> VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { + && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { execution.setVariable("homing", true); execution.setVariable("calledHoming", false); } @@ -802,6 +804,12 @@ public class WorkflowAction { .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); } + } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { + for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList()).size(); i++) { + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()) + .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + } } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, "", apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 94dfdcc747..8661c8e91e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -96,6 +96,7 @@ public class AAIObjectMapper { map().setModelInvariantId(source.getModelInfoVfModule().getModelInvariantUUID()); map().setModelVersionId(source.getModelInfoVfModule().getModelUUID()); map().setPersonaModelVersion(source.getModelInfoVfModule().getModelInvariantUUID()); + map().setIsBaseVfModule(source.getModelInfoVfModule().getIsBaseBoolean()); } }); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 1d87b70754..515f04b218 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -178,6 +178,9 @@ public class VnfAdapterVfModuleObjectMapper { if (requestContext.getUserParams() != null) { paramsMap.putAll(requestContext.getUserParams()); } + if (vfModule.getCloudParams() != null) { + paramsMap.putAll(vfModule.getCloudParams()); + } return paramsMap; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 99256fd507..af670d13d5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -128,6 +128,15 @@ public class VfModuleTopologyOperationRequestMapper { } } + if (vfModule.getCloudParams() != null) { + for (Map.Entry<String, String> entry : vfModule.getCloudParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(entry.getValue()); + vfModuleInputParameters.addParamItem(paramItem); + } + } + if (volumeGroup != null) { GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName("volume-group-id"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index c9433a6212..b45752957e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -204,11 +204,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateHeatStackIdVfModuleTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); aaiUpdateTasks.updateHeatStackIdVfModule(execution); verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); + assertEquals("newHeatStackId", vfModule.getHeatStackId()); } @Test @@ -270,11 +272,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test public void updateHeatStackIdVolumeGroupTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + assertEquals("newHeatStackId", volumeGroup.getHeatStackId()); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 283f8881c7..3869988c40 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -427,14 +427,20 @@ public class WorkflowActionTest extends BaseTaskTest { orch12.setFlowName("ActivateVfModuleBB"); orchFlows.add(orch12); OrchestrationFlow orch13 = new OrchestrationFlow(); - orch13.setFlowName("ActivateVnfBB"); + orch13.setFlowName("AssignFabricConfigurationBB"); orchFlows.add(orch13); OrchestrationFlow orch14 = new OrchestrationFlow(); - orch14.setFlowName("ActivateNetworkCollectionBB"); + orch14.setFlowName("ActivateFabricConfigurationBB"); orchFlows.add(orch14); OrchestrationFlow orch15 = new OrchestrationFlow(); - orch15.setFlowName("ActivateServiceInstanceBB"); + orch15.setFlowName("ActivateVnfBB"); orchFlows.add(orch15); + OrchestrationFlow orch16 = new OrchestrationFlow(); + orch16.setFlowName("ActivateNetworkCollectionBB"); + orchFlows.add(orch16); + OrchestrationFlow orch17 = new OrchestrationFlow(); + orch17.setFlowName("ActivateServiceInstanceBB"); + orchFlows.add(orch17); Service service = new Service(); doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); @@ -772,7 +778,7 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(UUID.randomUUID().toString().length(),ebbs.get(14).getWorkflowResourceIds().getVnfId().length()); assertEquals(ebbs.get(15).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB"); assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length()); - + assertEquals(true, execution.getVariable("homing")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 6edda44c0a..c3b0048e07 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -245,6 +245,32 @@ public class AAIObjectMapperTest{ assertThat(reqMapper1, sameBeanAs(AAIVfModule)); } + + @Test + public void vfModuleBaseMap() throws Exception { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("a"); + vfModule.setVfModuleName("b"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelCustomizationUUID("f"); + modelInfoVfModule.setModelInvariantUUID("g"); + modelInfoVfModule.setModelUUID("h"); + modelInfoVfModule.setIsBaseBoolean(true); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json"))); + + ObjectMapper omapper = new ObjectMapper(); + org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue( + jsonToCompare, + org.onap.aai.domain.yang.VfModule.class); + + assertThat(reqMapper1, sameBeanAs(AAIVfModule)); + + } @Test public void testMapInstanceGroup() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 1bb59e7b8d..0c9e281fc7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -103,6 +103,9 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { modelInfoVfModule.setModelUUID("vfModuleModelUuid"); modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); vfModule.setModelInfoVfModule(modelInfoVfModule); + HashMap<String, String> cloudParams = new HashMap<String, String>(); + cloudParams.put("key3", "value3"); + vfModule.setCloudParams(cloudParams); CloudRegion cloudRegion = new CloudRegion(); cloudRegion.setLcpCloudRegionId("cloudRegionId"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 369a7321e2..b3999a788c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -100,6 +100,9 @@ public class VfModuleTopologyOperationRequestMapperTest { modelInfoVfModule.setModelUUID("vfModuleModelUuid"); modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); vfModule.setModelInfoVfModule(modelInfoVfModule); + HashMap<String, String> cloudParams = new HashMap<String, String>(); + userParams.put("key2", "value2"); + vfModule.setCloudParams(cloudParams); VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("volumeGroupId"); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json index 0db327eae4..0132068fe4 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequest.json @@ -39,6 +39,7 @@ "fw_subint_ctrl_port_0_floating_v6_ip": "floatingIpV60", "workload_context": "workloadContext", "key1": "value2", + "key3": "value3", "availability_zone_0": "zone0", "availability_zone_1": "zone1", "availability_zone_2": "zone2", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json new file mode 100644 index 0000000000..9637e00fe1 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json @@ -0,0 +1,12 @@ +{ + + "modelCustomizationId" : "f", + "vfModuleId" : "a", + "vfModuleName" : "b", + "modelInvariantId" : "g", + "modelVersionId" : "h", + "orchestrationStatus" : "Assigned", + "personaModelVersion" : "g", + "isBaseVfModule" : true + +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json index 4231152d86..50d5642fee 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json @@ -23,6 +23,10 @@ "value" : "value1" }, { + "name" : "key2", + "value" : "value2" + }, + { "name" : "volume-group-id", "value" : "volumeGroupId" } ] diff --git a/common/pom.xml b/common/pom.xml index 0f1070309a..18b30a26bf 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -58,11 +58,6 @@ <version>4.3.6.Final</version> </dependency> <dependency> - <groupId>com.wordnik</groupId> - <artifactId>swagger-annotations_2.9.1</artifactId> - <version>1.3.0</version> - </dependency> - <dependency> <groupId>org.onap.appc.client</groupId> <artifactId>client-kit</artifactId> <version>1.3.0</version> diff --git a/docs/Install_Configure_SO.rst b/docs/Install_Configure_SO.rst index 29b5e9fc0a..e06385e39b 100644 --- a/docs/Install_Configure_SO.rst +++ b/docs/Install_Configure_SO.rst @@ -65,11 +65,11 @@ Auto-mount: <checked> Read-only: <unchecked>
-.. image:: images/Configure_ubuntu_SO_3.png
+.. image:: ../images/Configure_ubuntu_SO_3.png
.
-.. image:: images/Configure_ubuntu_SO_4.png
+.. image:: ../images/Configure_ubuntu_SO_4.png
Install Ubuntu in the VM
------------------------
@@ -111,7 +111,7 @@ Connect to the VM from your host computer -----------------------------------------
The PuTTY SSH client is popular. A connection to localhost:1022 (or whatever port you have forwarded) will go to the VM.
-.. image:: images/Configure_ubuntu_SO_7.png
+.. image:: ../images/Configure_ubuntu_SO_7.png
Install VirtualBox Guest Additions
----------------------------------
@@ -159,6 +159,6 @@ Further Reading .. toctree::
:maxdepth: 1
- Install_Docker.rst
- Configure_git_and_gerrit.rst
- Workspace_and_Development_Tools.rst
\ No newline at end of file + installconfigure/Install_Docker.rst
+ installconfigure/Configure_git_and_gerrit.rst
+ installconfigure/Workspace_and_Development_Tools.rst
\ No newline at end of file diff --git a/docs/installconfigure/Configure_git_and_gerrit.rst b/docs/installconfigure/Configure_git_and_gerrit.rst new file mode 100644 index 0000000000..c4598faf7b --- /dev/null +++ b/docs/installconfigure/Configure_git_and_gerrit.rst @@ -0,0 +1,93 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2017 Huawei Technologies Co., Ltd. + +Configure git and gerrit +======================== + +Basics +------ +The recommended version of git is 2.7.4 or later. Check the installed version in the Ubuntu VM: + +.. code-block:: bash + + git --version + +Create an SSH key to user with gerrit. Use no passphrase. + +.. code-block:: bash + + ssh-keygen -t rsa + +Enter your SSH public key (id_rsa) into gerrit: + +- Browse to https://gerrit.onap.org +- Log in +- Open the menu next to your name (under the green search button) + +.. image:: images/Configure_git_1.png + +- Select "Settings" +- In the "Settings" sidebar, click "SSH Public Keys"` +- Click "Add Key..." +- Paste the entire contents of $HOME/.ssh/id_rsa.pub into the text area and click "Add". + +.. image:: images/Configure_git_2.png + +Install the git-review package. + +.. code-block:: bash + + sudo apt update + sudo apt install git-review + +Create $HOME/.gitconfig (replace highlighted values with your own information): + [user] + + name = FirstName LastName + + email = you@yourcompany.com + + [core] + + autocrlf = false + + [merge] + + tool = vimdiff + + [gitreview] + + username = YourLinuxFoundationId + +**If you're behind a corporate firewall and your proxy server has SOCKS support...** + +You may be able to use the SSH protocol with git, which is preferred versus HTTP. This method is known to work in the AT&T corporate network. +Install the socat package, which allows you to tunnel SSH connections through a proxy that supports SOCKS: + +.. code-block:: bash + + sudo apt update + sudo apt install socat + +Create (or append to) $HOME/.ssh/config (replace highlighted values with your information) + + Host gerrit.onap.org + + User userid + + Hostname gerrit.onap.org + + ProxyCommand socat - PROXY:host:%h:%p,proxyport=port + + IdentityFile /home/userid/.ssh/id_rsa + + ServerAliveInterval 10 + +Verify that you have connectivity to gerrit through the proxy. Answer "yes" to continue connecting, if prompted. + +.. code-block:: bash + + ssh -p 29418 gerrit.onap.org + +.. image:: images/Configure_git_3.png diff --git a/docs/installconfigure/Install_Docker.rst b/docs/installconfigure/Install_Docker.rst new file mode 100644 index 0000000000..91e40ca138 --- /dev/null +++ b/docs/installconfigure/Install_Docker.rst @@ -0,0 +1,85 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2018 Huawei Technologies Co., Ltd. + +Install Docker +=============== + +Make sure curl is installed on the Ubuntu VM: + +.. code-block:: bash + + sudo apt update + sudo apt install curl + +If you are behind a corporate firewall (replace "proxyhost:port" with your actual proxy information) + https_proxy="https://*proxyhost:port*" curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - + +Otherwise: + curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add - +Expected Response: + OK +Add the docker package repository: + sudo apt-add-repository "deb https://apt.dockerproject.org/repo ubuntu-xenial main" + +Install packages: + +.. code-block:: bash + + sudo apt update + sudo apt-cache policy docker-engine + sudo apt install docker-engine + sudo apt install docker-compose + +If you are behind a corporate firewall, you will need to configure proxy settings for docker so that images may be obtained from internet repositories. In the commands shown here, replace *"proxyhost:port"*, *"yourdomain1.com"*, and *"yourdomain2.com"* with appropriate values. + + Make the docker configuration directory: + +.. code-block:: bash + + sudo mkdir -p /etc/systemd/system/docker.service.d + + Edit (create) this file: + +.. code-block:: bash + + sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf + + Add these lines: + + [Service] + + Environment="HTTP_PROXY=https://*proxyhost:port*" + + Environment="HTTPS_PROXY=https://*proxyhost:port*" + + Environment="NO_PROXY=localhost,127.0.0.1,.yourdomain1.com,.yourdomain2.com" + + Restart docker: + +.. code-block:: bash + + sudo systemctl daemon-reload + sudo systemctl restart docker + +Add yourself to the docker user group (replace "userid" with your user ID): + +.. code-block:: bash + + sudo usermod -a -G docker *userid* + +Log out and log back in so that the user group change will takeeffect. + +Verify that you can connect to docker as yourself (i.e. not as root): + +.. code-block:: bash + + docker ps + +Verify that you can download and run the hello-world container + +.. code-block:: bash + + docker run hello-world + +.. image:: images/Docker_install_1.png
\ No newline at end of file diff --git a/docs/installconfigure/Workspace_and_Development_Tools.rst b/docs/installconfigure/Workspace_and_Development_Tools.rst new file mode 100644 index 0000000000..598439f75f --- /dev/null +++ b/docs/installconfigure/Workspace_and_Development_Tools.rst @@ -0,0 +1,107 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2017 Huawei Technologies Co., Ltd. + +Workspace and Development Tools +=============================== + +We recognize that there are different ways to set up a workspace and different tools that may be chosen. This is just one way to set things up. + +Suggested Directory Structure +------------------------------ +*NOTE*: You may have different versions of eclipse and java. + + onap + + .m2 + + apache-maven-3.3.9 + + camunda-modeler + + eclipse-jee-neon-3-linux-gtk-x86_64 + + jdk1.8.0_131 + + workspace + + SO + chef-repo + + docker-config + + libs + + so + + so-config + +Java +----- +Download the latest Java_8_SE_Development_Kit_ from Oracle. Select a Linux x64 package. + +Unpack it. + +.. _Java_8_SE_Development_Kit: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html + +Maven +------ + +Download the Apache_Maven_3.3.9_ binary. NOTE: 3.3.9 is the recommended version, even though much higher versions are available. + +Unpack it. + +.. _Apache_Maven_3.3.9: https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/ + +Create an .m2 directory for maven and put settings.xml_ in it. Edit the local repository path in settings.xml to make it correct for your environment. Everything else should be OK. + +.. _settings.xml: https://wiki.onap.org/download/attachments/15997820/settings.xml?version=1&modificationDate=1506156303000&api=v2 + +Camunda Modeler +--------------- + +Download the Camunda_Modeler_. Select the Linux x64 package. +Unpack it. + +.. _Camunda_Modeler: https://camunda.org/download/modeler/ + +Eclipse +------- + +Download Eclipse_for_Linux_. Select the 64-bit Eclipse IDE for Java EE Developers. Oxygen seems to be the latest version. These instructions were written for Neon. +Unpack it. + +.. _Eclipse_for_Linux: https://www.eclipse.org/downloads/eclipse-packages/?osType=linux + +In the eclipse directory, edit eclipse.ini + + Add (or change) the -vm setting so that it points to your JDK. + + Adjust the maximum heap space (2GB is recommended). + + Example: + +.. image:: images/Workspace_and_Development_Tools.png + +Eclipse Settings +---------------- + +**Configure eclipse to use your external maven 3.3.9 installation:** + Go to Window→Preferences→Maven→Installations + + Click "Add" and browse to your apache-maven-3.3.9 directory. Click "OK" to select it. + + Click "Finish" + +.. image:: images/Workspace_and_Development_Tools_2.png + +Make sure the external installation is selected: + +.. image:: images/Workspace_and_Development_Tools_3.png + +**Configure eclipse to use your settings.xml** + Go to Window→Preferences→Maven→User Settings + + Type the full path to your settings.xml file into the "User Settings" box and click "OK". + +.. image:: images/Workspace_and_Development_Tools_4.png
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index e8a6beb278..923909e39b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -73,8 +73,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + @Component @Path("/e2eServiceInstances") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 4d8c4ffbd8..dcfe40aa51 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -61,7 +61,8 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.ApiOperation; @Path("/tasks") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index a9cf35796b..a14554c8a1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -20,9 +20,25 @@ package org.onap.so.apihandlerinfra.tenantisolation; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; @@ -33,8 +49,12 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.apihandlerinfra.tenantisolationbeans.*; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse; +import org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.Request; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; @@ -44,15 +64,10 @@ import org.onap.so.utils.UUIDChecker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; @Component @Path("onap/so/infra/cloudResourcesRequests") diff --git a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml index dbba5da9b0..df6d92163b 100644 --- a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml +++ b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml @@ -166,6 +166,7 @@ name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" level="WARN" /> + <logger name="db.migration" level="DEBUG" /> <logger name="org.apache.wire" level="DEBUG" /> <logger name="org.onap" level="DEBUG" /> <logger name="com.att.ecomp" level="DEBUG" /> @@ -185,4 +186,4 @@ <appender-ref ref="asyncError" /> </root> -</configuration>
\ No newline at end of file +</configuration> |