Search in sources :

Example 11 with VpnBondingLink

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

the class SniroHomingV2IT method testProcessSolution_success_1VpnLink_2Solutions.

@Test
public void testProcessSolution_success_1VpnLink_2Solutions() {
    beforeVpnBondingLink("1");
    JSONObject asyncResponse = new JSONObject();
    asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
    JSONArray solution1 = new JSONArray();
    solution1.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId1"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName1")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")).put(new JSONObject().put("key", "aicVersion").put("value", "3")).put(new JSONObject().put("key", "vnfId").put("value", "testVnfId1")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId1"))));
    solution1.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId2"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName2")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3")).put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName2")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId2"))));
    JSONArray solution2 = new JSONArray();
    solution2.put(new JSONObject().put("serviceResourceId", "testProxyId1").put("solution", new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId3"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName3")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli3")).put(new JSONObject().put("key", "aicVersion").put("value", "3")).put(new JSONObject().put("key", "vnfId").put("value", "testVnfId3")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId3"))));
    solution2.put(new JSONObject().put("serviceResourceId", "testProxyId2").put("solution", new JSONObject().put("identifierType", "serviceInstanceId").put("identifiers", new JSONArray().put("testServiceInstanceId4"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "primaryPnfName").put("value", "testPrimaryPnfName4")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli4")).put(new JSONObject().put("key", "aicVersion").put("value", "3")).put(new JSONObject().put("key", "secondaryPnfName").put("value", "testSecondaryPnfName4")).put(new JSONObject().put("key", "cloudRegionId").put("value", "testSloudRegionId4"))));
    asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1).put(solution2)).put("licenseSolutions", new JSONArray()));
    sniroHoming.processSolution(execution, asyncResponse.toString());
    ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
    assertFalse(si.getVpnBondingLinks().isEmpty());
    VpnBondingLink link = si.getVpnBondingLinks().get(0);
    VpnBondingLink link2 = si.getVpnBondingLinks().get(1);
    assertNotNull(link);
    assertFalse(link.getServiceProxies().isEmpty());
    assertEquals("testServiceInstanceId1", link.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
    assertNotNull(link.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName1", link.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
    assertEquals("testServiceInstanceId2", link.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
    assertNotNull(link.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
    assertFalse(link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
    assertEquals("testPrimaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
    assertEquals("primary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
    assertEquals("testSecondaryPnfName2", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
    assertEquals("secondary", link.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
    assertNotNull(link2);
    assertFalse(link2.getServiceProxies().isEmpty());
    assertEquals("testServiceInstanceId3", link2.getServiceProxy("testProxyId1").getServiceInstance().getServiceInstanceId());
    assertNotNull(link2.getServiceProxy("testProxyId1").getServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName3", link2.getServiceProxy("testProxyId1").getServiceInstance().getVnfs().get(0).getVnfName());
    assertEquals("testServiceInstanceId4", link2.getServiceProxy("testProxyId2").getServiceInstance().getServiceInstanceId());
    assertNotNull(link2.getServiceProxy("testProxyId2").getServiceInstance().getSolutionInfo());
    assertFalse(link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().isEmpty());
    assertEquals("testPrimaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getPnfName());
    assertEquals("primary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(0).getRole());
    assertEquals("testSecondaryPnfName4", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getPnfName());
    assertEquals("secondary", link2.getServiceProxy("testProxyId2").getServiceInstance().getPnfs().get(1).getRole());
}
Also used : VpnBondingLink(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 12 with VpnBondingLink

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

the class SniroHomingV2 method processPlacementSolution.

/**
 * Processes a placement solution list then correlates and sets each placement solution to its corresponding
 * resource
 */
private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i) {
    List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks();
    List<AllottedResource> allottes = serviceInstance.getAllottedResources();
    List<GenericVnf> vnfs = serviceInstance.getVnfs();
    List<ServiceProxy> serviceProxies = serviceInstance.getServiceProxies();
    logger.debug("Processing placement solution " + i + 1);
    for (int p = 0; p < placements.length(); p++) {
        JSONObject placement = placements.getJSONObject(p);
        SolutionInfo solutionInfo = new SolutionInfo();
        solutionInfo.setSolutionId(i + 1);
        search: {
            for (VpnBondingLink vbl : links) {
                List<ServiceProxy> proxies = vbl.getServiceProxies();
                for (ServiceProxy sp : proxies) {
                    if (placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())) {
                        if (i > 0) {
                            if (p % 2 == 0) {
                                VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl);
                                vblNew.setVpnBondingLinkId(UUID.randomUUID().toString());
                                links.add(vblNew);
                            }
                            links.get(links.size() - 1).getServiceProxy(sp.getId()).setServiceInstance(setSolution(solutionInfo, placement));
                        } else {
                            sp.setServiceInstance(setSolution(solutionInfo, placement));
                        }
                        break search;
                    }
                }
            }
            for (AllottedResource ar : allottes) {
                if (placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())) {
                    ar.setParentServiceInstance(setSolution(solutionInfo, placement));
                    break search;
                }
            }
            for (GenericVnf vnf : vnfs) {
                if (placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())) {
                    ServiceInstance si = setSolution(solutionInfo, placement);
                    serviceInstance.setSolutionInfo(si.getSolutionInfo());
                    serviceInstance.getVnfs().add(si.getVnfs().get(0));
                    break search;
                }
            }
            for (ServiceProxy proxy : serviceProxies) {
                if (placement.getString(SERVICE_RESOURCE_ID).equals(proxy.getId())) {
                    proxy.setServiceInstance(setSolution(solutionInfo, placement));
                    break search;
                }
            }
        }
    }
}
Also used : SolutionInfo(org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo) VpnBondingLink(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) JSONObject(org.json.JSONObject) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) AllottedResource(org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)

Example 13 with VpnBondingLink

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

the class BuildingBlockTestDataSetup method buildVpnBondingLink.

public VpnBondingLink buildVpnBondingLink() {
    vpnBondingLinkCounter++;
    VpnBondingLink vpnBondingLink = new VpnBondingLink();
    vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
    Configuration vnrConfiguration = buildConfiguration();
    vnrConfiguration.setNetwork(buildL3Network());
    vpnBondingLink.setVnrConfiguration(vnrConfiguration);
    vpnBondingLink.setVrfConfiguration(buildConfiguration());
    vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
    vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
    return vpnBondingLink;
}
Also used : VpnBondingLink(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ModelInfoConfiguration(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration)

Example 14 with VpnBondingLink

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

the class BuildingBlockTestDataSetup method setVpnBondingLink.

public VpnBondingLink setVpnBondingLink() {
    VpnBondingLink vpnBondingLink = buildVpnBondingLink();
    ServiceInstance serviceInstance = null;
    try {
        serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    } catch (BBObjectNotFoundException e) {
        serviceInstance = setServiceInstance();
    }
    serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
    lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
    return vpnBondingLink;
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) VpnBondingLink(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)

Aggregations

VpnBondingLink (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink)14 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)8 JSONObject (org.json.JSONObject)6 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)6 JSONArray (org.json.JSONArray)4 Test (org.junit.Test)4 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)4 AllottedResource (org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)4 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)4 ArrayList (java.util.ArrayList)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 Candidate (org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate)2 SolutionInfo (org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo)2 ModelInfoConfiguration (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration)2 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)2 PlacementDemand (org.onap.so.client.oof.beans.PlacementDemand)1 Demand (org.onap.so.client.sniro.beans.Demand)1