diff options
Diffstat (limited to 'adapters')
11 files changed, 279 insertions, 17 deletions
diff --git a/adapters/etsi-sol003-adapter/pom.xml b/adapters/etsi-sol003-adapter/pom.xml index fe34ff47c3..9ea25a5eb7 100644 --- a/adapters/etsi-sol003-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/pom.xml @@ -16,7 +16,7 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <version-swagger-codegen>2.3.1</version-swagger-codegen> <gson-fire-version>1.8.2</gson-fire-version> - <retrofit-version>2.3.0</retrofit-version> + <retrofit-version>2.7.2</retrofit-version> <threetenbp-version>1.3.5</threetenbp-version> <oltu-version>1.0.1</oltu-version> <swagger-core-version>1.5.21</swagger-core-version> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index f283af1ba6..aa039c6ac4 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -655,4 +655,36 @@ public class CatalogDbAdapterRest { return Response.status(HttpStatus.SC_NOT_FOUND).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .build(); } + + @GET + @Path("processingFlags") + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Transactional(readOnly = true) + public Response getAllProcessingFlags() { + return getAllProcessingFlagsImpl(); + } + + public Response getAllProcessingFlagsImpl() { + List<ProcessingFlags> processingFlags = null; + + int respStatus = HttpStatus.SC_OK; + try { + processingFlags = processingFlagsRepo.findAll(); + if (processingFlags == null) { + logger.debug("ProcessingFlags not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + + logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString()); + } + return Response.status(respStatus).entity(processingFlags) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build(); + } catch (Exception e) { + logger.error("Exception - queryProcesssingFlags", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build(); + } + } } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index a5e546e093..91a0dbd1f0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -84,16 +84,17 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '8', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '9', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '10', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '11', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '12', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '13', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '14', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '15', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '6', 'DeactivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '7', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '8', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '9', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '10', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '11', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '12', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '13', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '14', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '15', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '1', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -280,6 +281,7 @@ VALUES ('DeactivateVolumeGroupBB', 'VOLUME_GROUP', 'DEACTIVATE'), ('DeactivateVfModuleBB', 'VF_MODULE', 'DEACTIVATE'), ('DeactivateNetworkBB', 'NETWORK', 'DEACTIVATE'), +('DeactivatePnfBB', 'NO_VALIDATE', 'DEACTIVATE'), ('ChangeModelServiceInstanceBB', 'SERVICE', 'CHANGEMODEL'), @@ -929,3 +931,13 @@ VALUES ('VNFConfigModifyActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'); + +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='HealthCheck' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vfmodule', ACTION='ScaleOutReconfiguration' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES +('VFModule-Delete', '1', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck"), +('VFModule-Delete', '2', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vfmodule", "ScaleInReconfiguration"), +('VFModule-Delete', '6', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck");
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 04161e9df9..3906229c2c 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -21,7 +21,9 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; @@ -37,6 +39,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -831,6 +834,34 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { } @Test + public void testGetAllProcessingFlags() throws Exception { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + + List<ProcessingFlags> processingFlagsResponse = + mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {}); + + boolean testFlagFound = false; + for (int i = 0; i < processingFlagsResponse.size(); i++) { + if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) { + assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT"); + assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG"); + testFlagFound = true; + } + } + assertTrue(testFlagFound); + } + + @Test public void testSetProcessingFlagsFlagValue() throws JSONException { ProcessingFlags updatedProcessingFlag = new ProcessingFlags(); updatedProcessingFlag.setFlag("TESTFLAG"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index df4229c985..12751f8c27 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -35,6 +35,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -72,6 +73,10 @@ public class CreateAAIInventory { List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId()); + List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources); + heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), + osNetworks); + List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources); heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index 9c098863f2..a4e6cccc06 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -38,6 +38,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; /** * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to @@ -88,6 +89,14 @@ public interface HeatBridgeApi { List<Server> getAllOpenstackServers(List<Resource> stackResources); /** + * Query the Openstack provider network objects from the list of stack resources + * + * @param stackResources A list of stack based resources + * @return A list of Openstack Network objects + */ + List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources); + + /** * Extract Openstack Image objects from a a list of Server objects * * @param servers A list of Openstack Server objects @@ -104,6 +113,15 @@ public interface HeatBridgeApi { List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers); /** + * Query and build AAI actions for Openstack Compute resources to AAI's l3-network objects with its subnets + * + * @param genericVnfId AAI generic-vnf-id + * @param vfModuleId AAI vf-module-id + * @param networks Openstack Network list + */ + void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks); + + /** * Query and build AAI actions for Openstack Image resources to AAI's image objects * * @param images List of Openstack Image objects diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index fae3539cb5..92958004ca 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -49,11 +49,15 @@ import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.L3InterfaceIpv4AddressList; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovPf; import org.onap.aai.domain.yang.SriovPfs; +import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.SriovVfs; import org.onap.aai.domain.yang.VfModule; @@ -198,6 +202,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } @Override + public List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources) { + Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); + // Filter Openstack Compute resources + List<String> providerNetworkIds = + extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_NEUTRON_PROVIDERNET); + return providerNetworkIds.stream().map(providerNetworkId -> osClient.getNetworkById(providerNetworkId)) + .collect(Collectors.toList()); + } + + @Override public List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); return servers.stream().map(Server::getImage) @@ -211,6 +225,27 @@ public class HeatBridgeImpl implements HeatBridgeApi { .filter(distinctByProperty(org.openstack4j.model.compute.Flavor::getId)).collect(Collectors.toList()); } + public void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, + List<Network> networks) { + networks.forEach(network -> { + L3Network l3Network = aaiHelper.buildNetwork(network); + if (l3Network != null) { + l3Network.setSubnets(buildSunets(network)); + + RelationshipList relationshipList = new RelationshipList(); + List<Relationship> relationships = relationshipList.getRelationship(); + + relationships.add(aaiHelper.getRelationshipToVfModule(genericVnfId, vfModuleId)); + relationships.add(aaiHelper.getRelationshipToTenant(cloudOwner, cloudRegionId, tenantId)); + + l3Network.setRelationshipList(relationshipList); + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3Network.getNetworkId()), + Optional.of(l3Network)); + } + }); + } + @Override public void buildAddImagesToAaiAction(final List<org.openstack4j.model.compute.Image> images) throws HeatBridgeException { @@ -338,6 +373,20 @@ public class HeatBridgeImpl implements HeatBridgeApi { return pserverMap; } + private Subnets buildSunets(Network network) { + Subnets aaiSubnets = new Subnets(); + List<String> subnetIds = network.getSubnets(); + + subnetIds.forEach(subnetId -> { + Subnet subnet = osClient.getSubnetById(subnetId); + org.onap.aai.domain.yang.Subnet aaiSubnet = aaiHelper.buildSubnet(subnet); + if (aaiSubnet != null) { + aaiSubnets.getSubnet().add(aaiSubnet); + } + }); + return aaiSubnets; + } + private void createPServerIfNotExists(Map<String, Pserver> serverHostnames) { for (Pserver pserver : serverHostnames.values()) { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserver.getHostname()); @@ -494,9 +543,9 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(vnfId, "Null vnf-id!"); Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); try { - Optional<VfModule> vfModule = resourcesClient.get( - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId, NotFoundException.class) - .depth(Depth.ONE)) + Optional<VfModule> vfModule = resourcesClient + .get(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE), + NotFoundException.class) .asBean(VfModule.class); AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); @@ -570,9 +619,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vserver vserver = vserverWrapper.asBean(Vserver.class).get(); List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver); if (CollectionUtils.isNotEmpty(pciIds)) { - List<String> matchingPservers = vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER); + List<AAIResourceUri> matchingPservers = + vserverRelationships.get().getRelatedUris(AAIObjectType.PSERVER); if (matchingPservers != null && matchingPservers.size() == 1) { - pserverToPciIdMap.put(matchingPservers.get(0), pciIds); + pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds); } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index fdf7ce38f1..71c6a96cd6 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java @@ -40,6 +40,7 @@ public class HeatBridgeConstants { public static final Integer OS_DEFAULT_HEAT_NESTING = 5; public static final String OS_SERVER_RESOURCE_TYPE = "OS::Nova::Server"; public static final String OS_PORT_RESOURCE_TYPE = "OS::Neutron::Port"; + public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet"; public static final String OS_SRIOV_PORT_TYPE = "direct"; public static final String OS_PCI_SLOT_KEY = "pci_slot"; public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network"; @@ -64,6 +65,8 @@ public class HeatBridgeConstants { public static final String AAI_VF_MODULE_ID = "vf-module.vf-module-id"; public static final String AAI_IMAGE = "image"; public static final String AAI_IMAGE_ID = "image.image-id"; + public static final String AAI_TENANT = "tenant"; + public static final String AAI_TENANT_ID = "tenant.tenant-id"; public static final String AAI_CLOUD_OWNER = "cloud-region.cloud-owner"; public static final String AAI_CLOUD_REGION_ID = "cloud-region.cloud-region-id"; public static final String AAI_FLAVOR = "flavor"; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index c4d9cbe871..7d4e92d9ad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -42,6 +42,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Relationship; @@ -54,7 +55,9 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.openstack4j.model.compute.Server; +import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import com.google.common.base.Preconditions; /** @@ -131,6 +134,49 @@ public class AaiHelper { return relationshipList; } + public Relationship getRelationshipToVfModule(String vnfId, String vfModuleId) { + return buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)); + } + + public Relationship getRelationshipToTenant(String cloudOwner, String cloudRegionId, String tenantId) { + return buildRelationship( + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegionId, tenantId)); + } + + public org.onap.aai.domain.yang.Subnet buildSubnet(Subnet subnet) { + org.onap.aai.domain.yang.Subnet aaiSubnet = new org.onap.aai.domain.yang.Subnet(); + aaiSubnet.setSubnetId(subnet.getId()); + aaiSubnet.setDhcpEnabled(subnet.isDHCPEnabled()); + + aaiSubnet.setSubnetName(subnet.getName()); + aaiSubnet.setGatewayAddress(subnet.getGateway()); + aaiSubnet.setCidrMask(subnet.getCidr()); + aaiSubnet.setIpVersion(subnet.getIpVersion().name()); + return aaiSubnet; + } + + public L3Network buildNetwork(Network network) { + if (network.getId() == null) { + return null; + } + L3Network l3Network = new L3Network(); + l3Network.setNetworkId(network.getId()); + l3Network.setIsBoundToVpn(true); + l3Network.setIsProviderNetwork(true); + + // optional fields + l3Network.setIsSharedNetwork(network.isShared()); + l3Network.setIsExternalNetwork(network.isRouterExternal()); + l3Network.setOperationalStatus(String.valueOf(network.isAdminStateUp())); + if (network.getName() != null) { + l3Network.setNetworkName(network.getName()); + } + if (network.getProviderPhyNet() != null) { + l3Network.setPhysicalNetworkName(network.getProviderPhyNet()); + } + return l3Network; + } + /** * Transform Openstack Server object to AAI Vserver object * diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 643dd4cd9a..8c21e3f7f7 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -85,9 +85,11 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.compute.Server.Status; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.IP; +import org.openstack4j.model.network.IPVersionType; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import org.springframework.core.env.Environment; @@ -450,6 +452,70 @@ public class HeatBridgeImplTest { } @Test + public void testUpdateNetworksToAai() throws HeatBridgeException { + + Subnet subnet1 = mock(Subnet.class); + when(subnet1.getId()).thenReturn("test-subnet1-id"); + when(subnet1.getName()).thenReturn("test-subnet1-name"); + when(subnet1.isDHCPEnabled()).thenReturn(true); + when(subnet1.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet1.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet1.getIpVersion()).thenReturn(IPVersionType.V4); + + Subnet subnet2 = mock(Subnet.class); + when(subnet2.getId()).thenReturn("test-subnet2-id"); + when(subnet2.getName()).thenReturn("test-subnet2-name"); + when(subnet2.isDHCPEnabled()).thenReturn(true); + when(subnet2.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet2.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet2.getIpVersion()).thenReturn(IPVersionType.V6); + + when(osClient.getSubnetById(subnet1.getId())).thenReturn(subnet1); + when(osClient.getSubnetById(subnet2.getId())).thenReturn(subnet2); + + List<String> subnetIds = Arrays.asList(subnet1.getId(), subnet2.getId()); + + // Arrange + Network network1 = mock(Network.class); + when(network1.getId()).thenReturn("test-network1-id"); + when(network1.isShared()).thenReturn(true); + when(network1.isRouterExternal()).thenReturn(true); + when(network1.isAdminStateUp()).thenReturn(true); + when(network1.getProviderPhyNet()).thenReturn("sriov-network1"); + when(network1.getName()).thenReturn("network1"); + when(network1.getSubnets()).thenReturn(subnetIds); + + Network network2 = mock(Network.class); + when(network2.getId()).thenReturn("test-network2-id"); + when(network2.isShared()).thenReturn(true); + when(network2.isRouterExternal()).thenReturn(true); + when(network2.isAdminStateUp()).thenReturn(true); + when(network2.getProviderPhyNet()).thenReturn("sriov-network2"); + when(network2.getName()).thenReturn("network2"); + when(network2.getSubnets()).thenReturn(subnetIds); + + String vnfId = "some-uuiid-of-the-vnf"; + String vfModuleId = "some-uuiid-of-the-vf-module"; + + Subnet subnet = mock(Subnet.class); + + List<Network> networks = Arrays.asList(network1, network2); + + // Act #1 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #1 + verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + // Act #2 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #2 + verify(transaction, times(4)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + } + + @Test public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); diff --git a/adapters/pom.xml b/adapters/pom.xml index 9e703b9dab..56d4328577 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -22,7 +22,6 @@ <module>mso-vfc-adapter</module> <module>mso-openstack-adapters</module> <module>etsi-sol003-adapter</module> - <module>etsi-sol002-adapter</module> <module>mso-nssmf-adapter</module> <module>so-appc-orchestrator</module> </modules> |