Search in sources :

Example 1 with VpnBinding

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.

the class NamingServiceCreateTasks method createVpnBondingServiceName.

public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
    VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
    namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
    namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    namingRequestObject.setNetworkNameValue(network.getNetworkName());
    namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
    namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
    String generatedVpnBondingServiceName = "";
    try {
        generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 2 with VpnBinding

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding 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 3 with VpnBinding

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.

the class AAIVpnBindingResourcesTest method createVpnBindingTest.

@Test
public void createVpnBindingTest() {
    doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
    org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
    mappedVpnBinding.setVpnName("test");
    doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
    VpnBinding vpnBinding = buildVpnBinding();
    aaiVpnBindingResources.createVpnBinding(vpnBinding);
    verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
    verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
}
Also used : VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 4 with VpnBinding

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.

the class BBInputSetupMapperLayer method mapAAIVpnBinding.

public VpnBinding mapAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) {
    VpnBinding vpnBinding = modelMapper.map(aaiVpnBinding, VpnBinding.class);
    mapAllRouteTargetsToAAIVpnBinding(aaiVpnBinding, vpnBinding);
    return vpnBinding;
}
Also used : VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding)

Example 5 with VpnBinding

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.

the class BBInputSetup method getGBBMacroNoUserParamsCreate.

protected GeneralBuildingBlock getGBBMacroNoUserParamsCreate(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap, String bbName, String key, GeneralBuildingBlock gBB, Service service) throws Exception {
    ServiceInstance serviceInstance = gBB.getServiceInstance();
    BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setExecuteBB(executeBB).setRequestId(executeBB.getRequestId()).setServiceInstance(serviceInstance).setService(service).setBbName(bbName).setLookupKeyMap(lookupKeyMap).setKey(key).build();
    if (bbName.contains(NETWORK) && !bbName.contains(NETWORK_COLLECTION)) {
        String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
        parameter.setResourceId(networkId);
        parameter.setModelInfo(new ModelInfo());
        if ((!Boolean.TRUE.equals(executeBB.getBuildingBlock().isVirtualLink()))) {
            NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service);
            if (networkCust != null) {
                parameter.getModelInfo().setModelCustomizationUuid(networkCust.getModelCustomizationUUID());
                this.populateL3Network(parameter);
            } else {
                logger.debug("Could not find a network customization with key: {}", key);
            }
        } else {
            logger.debug("Orchestrating on Collection Network Resource Customization");
            CollectionNetworkResourceCustomization collectionNetworkResourceCust = bbInputSetupUtils.getCatalogCollectionNetworkResourceCustByID(key);
            L3Network l3Network = getVirtualLinkL3Network(lookupKeyMap, bbName, key, networkId, collectionNetworkResourceCust, serviceInstance);
            NetworkResourceCustomization networkResourceCustomization = mapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
            if (l3Network != null) {
                l3Network.setModelInfoNetwork(mapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization));
            }
        }
    } else if (bbName.contains("Configuration")) {
        parameter.setResourceId(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID));
        parameter.setModelInfo(new ModelInfo());
        parameter.getModelInfo().setModelCustomizationUuid(key);
        parameter.setConfigurationResourceKeys(executeBB.getConfigurationResourceKeys());
        parameter.setRequestDetails(executeBB.getRequestDetails());
        this.populateConfiguration(parameter);
    }
    if (executeBB.getWorkflowResourceIds() != null) {
        parameter.setResourceId(executeBB.getWorkflowResourceIds().getNetworkCollectionId());
        this.populateNetworkCollectionAndInstanceGroupAssign(parameter);
    }
    RelatedInstance relatedVpnBinding = bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.vpnBinding);
    RelatedInstance relatedLocalNetwork = bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.network);
    if (relatedVpnBinding != null && relatedLocalNetwork != null) {
        org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId());
        org.onap.aai.domain.yang.L3Network aaiLocalNetwork = bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId());
        VpnBinding vpnBinding = mapperLayer.mapAAIVpnBinding(aaiVpnBinding);
        L3Network localNetwork = mapperLayer.mapAAIL3Network(aaiLocalNetwork);
        Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = bbInputSetupUtils.getAICVpnBindingFromNetwork(aaiLocalNetwork);
        if (aaiAICVpnBindingOp.isPresent()) {
            localNetwork.getVpnBindings().add(mapperLayer.mapAAIVpnBinding(aaiAICVpnBindingOp.get()));
        }
        ServiceProxy serviceProxy = getServiceProxy(service);
        gBB.getServiceInstance().getServiceProxies().add(serviceProxy);
        gBB.getCustomer().getVpnBindings().add(vpnBinding);
        lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
        gBB.getServiceInstance().getNetworks().add(localNetwork);
        lookupKeyMap.put(ResourceKey.NETWORK_ID, localNetwork.getNetworkId());
    }
    return gBB;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization)

Aggregations

VpnBinding (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding)10 Test (org.junit.Test)3 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)3 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 RouteTarget (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget)2 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 RouteTargets (org.onap.aai.domain.yang.RouteTargets)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)1 ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)1 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)1 UpdateNetworkRequest (org.onap.so.adapters.nwrest.UpdateNetworkRequest)1 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)1 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)1 NetworkPolicy (org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy)1 RouteTableReference (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference)1 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)1 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)1