Search in sources :

Example 1 with ModelInfoNetwork

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork in project so by onap.

the class BuildingBlockTestDataSetup method buildL3Network.

public L3Network buildL3Network() {
    l3NetworkCounter++;
    L3Network network = new L3Network();
    network.setNetworkId("testNetworkId" + l3NetworkCounter);
    network.setNetworkName("testNetworkName" + l3NetworkCounter);
    network.setNetworkType("testNetworkType" + l3NetworkCounter);
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
    modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
    modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
    modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
    network.setModelInfoNetwork(modelInfoNetwork);
    return network;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)

Example 2 with ModelInfoNetwork

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork in project so by onap.

the class ServiceEBBLoader method traverseAAIService.

public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) {
    try {
        ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
        org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
        var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
        serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
        serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId());
        resourceList.add(serviceResource);
        traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
        if (serviceInstanceMSO.getNetworks() != null) {
            for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO.getNetworks()) {
                aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
                Resource networkResource = new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource);
                ModelInfoNetwork modelInfoNetwork = network.getModelInfoNetwork();
                if (modelInfoNetwork != null) {
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                    networkResource.setModelVersionId(modelInfoNetwork.getModelUUID());
                    networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
                }
                resourceList.add(networkResource);
            }
        }
        if (serviceInstanceMSO.getCollection() != null) {
            logger.debug("found networkcollection");
            aaiResourceIds.add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
            resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId(), false, serviceResource));
        }
        if (serviceInstanceMSO.getConfigurations() != null) {
            for (Configuration config : serviceInstanceMSO.getConfigurations()) {
                Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId());
                if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
                    for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
                        if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) {
                            aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
                            resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false, serviceResource));
                            break;
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        logger.error("Exception in traverseAAIService", ex);
        buildAndThrowException(execution, "Could not find existing Service Instance or related Instances to execute the request on.");
    }
}
Also used : Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) Relationship(org.onap.aai.domain.yang.Relationship) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)

Example 3 with ModelInfoNetwork

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork in project so by onap.

the class NetworkAdapterObjectMapper method deleteNetworkRequestMapper.

public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) {
    DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
    deleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
    String messageId = getRandomUuid();
    deleteNetworkRequest.setMessageId(messageId);
    ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
    if (modelInfoNetwork != null) {
        deleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
    }
    deleteNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
    deleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
    if (!StringUtils.isEmpty(l3Network.getHeatStackId())) {
        deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
    } else {
        deleteNetworkRequest.setNetworkStackId(l3Network.getNetworkName());
    }
    deleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
    deleteNetworkRequest.setSkipAAI(true);
    deleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
    deleteNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
    return deleteNetworkRequest;
}
Also used : DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)

Example 4 with ModelInfoNetwork

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork in project so by onap.

the class NetworkAdapterObjectMapperTest method updateNetworkRequestMapperTest.

@Test
public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
    org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
    subnet.setSubnetId("subnetId");
    subnet.setGatewayIp("NULL");
    subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
    List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
    subnets.add(subnet);
    ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
    List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
    org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
    expectedRouteTarget.setRouteTarget("globalRouteTarget");
    ContrailNetwork contrailNetwork = new ContrailNetwork();
    contrailNetwork.setPolicyFqdns(policyFqdns);
    contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
    contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
    contrailNetwork.getRouteTargets().add(expectedRouteTarget);
    contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setServiceInstanceId("testServiceInstanceId1");
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    modelInfoNetwork.setNetworkType("networkType");
    modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
    modelInfoNetwork.setModelVersion("modelVersion");
    Subnet actualSubnet = new Subnet();
    actualSubnet.setSubnetId("subnetId");
    actualSubnet.setDhcpEnabled(false);
    actualSubnet.setIpVersion("4");
    RouteTarget routeTarget = new RouteTarget();
    routeTarget.setGlobalRouteTarget("globalRouteTarget");
    VpnBinding vpnBinding = new VpnBinding();
    vpnBinding.setVpnId("vpnId");
    vpnBinding.getRouteTargets().add(routeTarget);
    Customer customer = new Customer();
    customer.getVpnBindings().add(vpnBinding);
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    customer.setServiceSubscription(serviceSubscription);
    // set Customer on service instance
    customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
    NetworkPolicy networkPolicy = new NetworkPolicy();
    networkPolicy.setNetworkPolicyId("networkPolicyId");
    networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
    RouteTableReference routeTableReference = new RouteTableReference();
    routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
    l3Network.setModelInfoNetwork(modelInfoNetwork);
    l3Network.setPhysicalNetworkName("physicalNetworkName");
    l3Network.getSubnets().add(actualSubnet);
    l3Network.getNetworkPolicies().add(networkPolicy);
    l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
    l3Network.setIsSharedNetwork(false);
    l3Network.setIsExternalNetwork(false);
    HashMap<String, String> networkParams = new HashMap<String, String>();
    networkParams.put("shared", "false");
    networkParams.put("external", "false");
    networkParams.put("testUserInputKey", "testUserInputValue");
    UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
    expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
    expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
    expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
    expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
    expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
    expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
    expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
    expectedUpdateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
    expectedUpdateNetworkRequest.setSubnets(subnets);
    expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
    expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
    expectedUpdateNetworkRequest.setNetworkParams(networkParams);
    expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
    expectedUpdateNetworkRequest.setSkipAAI(true);
    expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
    expectedUpdateNetworkRequest.setMessageId("messageId");
    expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
    UpdateNetworkRequest actualUpdateNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
    assertThat(actualUpdateNetworkRequest, sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) MsoRequest(org.onap.so.entity.MsoRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) UpdateNetworkRequest(org.onap.so.adapters.nwrest.UpdateNetworkRequest) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) RouteTarget(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 5 with ModelInfoNetwork

use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork in project so by onap.

the class NetworkAdapterObjectMapperTest method deleteNetworkRequestNoHeatIdMapperTest.

@Test
public void deleteNetworkRequestNoHeatIdMapperTest() throws Exception {
    DeleteNetworkRequest expectedDeleteNetworkRequest = new DeleteNetworkRequest();
    String messageId = "messageId";
    expectedDeleteNetworkRequest.setMessageId(messageId);
    doReturn(messageId).when(SPY_networkAdapterObjectMapper).getRandomUuid();
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    l3Network.setModelInfoNetwork(modelInfoNetwork);
    modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
    expectedDeleteNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedDeleteNetworkRequest.setMsoRequest(msoRequest);
    expectedDeleteNetworkRequest.setNetworkId(l3Network.getNetworkId());
    l3Network.setNetworkName("heatStackId");
    expectedDeleteNetworkRequest.setNetworkStackId("heatStackId");
    expectedDeleteNetworkRequest.setNetworkType(l3Network.getNetworkType());
    expectedDeleteNetworkRequest.setSkipAAI(true);
    expectedDeleteNetworkRequest.setTenantId(cloudRegion.getTenantId());
    expectedDeleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
    expectedDeleteNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
    doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    DeleteNetworkRequest deleteNetworkRequest = SPY_networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network);
    assertThat(expectedDeleteNetworkRequest, sameBeanAs(deleteNetworkRequest));
}
Also used : DeleteNetworkRequest(org.onap.so.adapters.nwrest.DeleteNetworkRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) MsoRequest(org.onap.so.entity.MsoRequest) Test(org.junit.Test)

Aggregations

ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)18 Test (org.junit.Test)10 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)8 CollectionNetworkResourceCustomization (org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization)4 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)4 ArrayList (java.util.ArrayList)3 DeleteNetworkRequest (org.onap.so.adapters.nwrest.DeleteNetworkRequest)3 Service (org.onap.so.db.catalog.beans.Service)3 MsoRequest (org.onap.so.entity.MsoRequest)3 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 File (java.io.File)2 HashMap (java.util.HashMap)2 ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)2 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)2 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)2 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)2 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)2 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)2 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)2