Search in sources :

Example 6 with AllottedResource

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

the class OofHomingV2IT method testProcessSolution_success_3Allotteds1Vnf_1Solution.

@Test
public void testProcessSolution_success_3Allotteds1Vnf_1Solution() {
    beforeVnf();
    beforeAllottedResource();
    JSONObject asyncResponse = new JSONObject();
    asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", "completed");
    JSONArray solution1 = new JSONArray();
    JSONArray licenseSolution = new JSONArray();
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").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", "True")).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", "testCloudRegionId1"))));
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").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", "True")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).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", "testCloudRegionId2"))));
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject().put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
    licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e")).put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
    asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", licenseSolution));
    oofHoming.processSolution(execution, asyncResponse.toString());
    ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
    assertFalse(si.getAllottedResources().isEmpty());
    AllottedResource ar = si.getAllottedResources().get(0);
    assertNotNull(ar);
    assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
    assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
    AllottedResource ar2 = si.getAllottedResources().get(1);
    assertNotNull(ar2);
    assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
    assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
    AllottedResource ar3 = si.getAllottedResources().get(2);
    assertNotNull(ar3);
    assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
    assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
    GenericVnf vnf = si.getVnfs().get(0);
    assertNotNull(vnf);
    assertNotNull(vnf.getLicense());
    assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
    assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
}
Also used : JSONObject(org.json.JSONObject) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) JSONArray(org.json.JSONArray) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) AllottedResource(org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 7 with AllottedResource

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

the class SniroHomingV2IT method testProcessSolution_success_3Allotteds1Vnf_1Solution.

@Test
public void testProcessSolution_success_3Allotteds1Vnf_1Solution() {
    beforeVnf();
    beforeAllottedResource();
    JSONObject asyncResponse = new JSONObject();
    asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
    JSONArray solution1 = new JSONArray();
    JSONArray licenseSolution = new JSONArray();
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId1").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", "True")).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", "testCloudRegionId1"))));
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId2").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", "True")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "vnfHostName").put("value", "testVnfHostName2")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).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", "testCloudRegionId2"))));
    solution1.put(new JSONObject().put("serviceResourceId", "testAllottedResourceId3").put("solution", new JSONObject().put("identifierType", "cloudRegionId").put("identifiers", new JSONArray().put("testCloudRegionId3"))).put("assignmentInfo", new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "True")).put(new JSONObject().put("key", "cloudOwner").put("value", "aic")).put(new JSONObject().put("key", "aicClli").put("value", "testAicClli2")).put(new JSONObject().put("key", "aicVersion").put("value", "3"))));
    licenseSolution.put(new JSONObject().put("serviceResourceId", "testVnfId1").put("entitlementPoolUUID", new JSONArray().put("f1d563e8-e714-4393-8f99-cc480144a05e").put("j1d563e8-e714-4393-8f99-cc480144a05e")).put("licenseKeyGroupUUID", new JSONArray().put("s1d563e8-e714-4393-8f99-cc480144a05e").put("b1d563e8-e714-4393-8f99-cc480144a05e")));
    asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", licenseSolution));
    sniroHoming.processSolution(execution, asyncResponse.toString());
    ServiceInstance si = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0);
    assertFalse(si.getAllottedResources().isEmpty());
    AllottedResource ar = si.getAllottedResources().get(0);
    assertNotNull(ar);
    assertEquals("testServiceInstanceId1", ar.getParentServiceInstance().getServiceInstanceId());
    assertNotNull(ar.getParentServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName1", ar.getParentServiceInstance().getVnfs().get(0).getVnfName());
    AllottedResource ar2 = si.getAllottedResources().get(1);
    assertNotNull(ar2);
    assertEquals("testServiceInstanceId2", ar2.getParentServiceInstance().getServiceInstanceId());
    assertNotNull(ar2.getParentServiceInstance().getSolutionInfo());
    assertEquals("testVnfHostName2", ar2.getParentServiceInstance().getVnfs().get(0).getVnfName());
    AllottedResource ar3 = si.getAllottedResources().get(2);
    assertNotNull(ar3);
    assertNotNull(ar3.getParentServiceInstance().getSolutionInfo());
    assertEquals("testCloudRegionId3", ar3.getParentServiceInstance().getSolutionInfo().getTargetedCloudRegion().getLcpCloudRegionId());
    GenericVnf vnf = si.getVnfs().get(0);
    assertNotNull(vnf);
    assertNotNull(vnf.getLicense());
    assertEquals(2, vnf.getLicense().getEntitlementPoolUuids().size());
    assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0));
}
Also used : JSONObject(org.json.JSONObject) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) JSONArray(org.json.JSONArray) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) AllottedResource(org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 8 with AllottedResource

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

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

the class BuildingBlockTestDataSetup method setAllottedResource.

public AllottedResource setAllottedResource(String uniqueIdentifier) {
    AllottedResource ar = new AllottedResource();
    ar.setId("testAllottedResourceId" + uniqueIdentifier);
    ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
    modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
    modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
    modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
    modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
    modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
    ar.setModelInfoAllottedResource(modelInfo);
    return ar;
}
Also used : ModelInfoAllottedResource(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource) ModelInfoAllottedResource(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource) AllottedResource(org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)

Example 10 with AllottedResource

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

the class TestDataSetup method setAllottedResource.

public AllottedResource setAllottedResource(String uniqueIdentifier) {
    AllottedResource ar = new AllottedResource();
    ar.setId("testAllottedResourceId" + uniqueIdentifier);
    ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
    modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
    modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
    modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
    modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
    modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
    ar.setModelInfoAllottedResource(modelInfo);
    return ar;
}
Also used : ModelInfoAllottedResource(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource) ModelInfoAllottedResource(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource) AllottedResource(org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)

Aggregations

AllottedResource (org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)10 JSONObject (org.json.JSONObject)6 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)6 JSONArray (org.json.JSONArray)4 Test (org.junit.Test)4 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)4 VpnBondingLink (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink)4 SolutionInfo (org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo)2 ModelInfoAllottedResource (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2 ArrayList (java.util.ArrayList)1 PlacementDemand (org.onap.so.client.oof.beans.PlacementDemand)1 Demand (org.onap.so.client.sniro.beans.Demand)1