use of org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource in project so by onap.
the class OofHomingV2IT method testProcessSolution_success_3Allotteds_1Solution.
@Test
public void testProcessSolution_success_3Allotteds_1Solution() {
beforeAllottedResource();
JSONObject asyncResponse = new JSONObject();
asyncResponse.put("transactionId", "transactionId").put("requestId", "testRequestId").put("requestState", "completed");
JSONArray solution1 = 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"))));
asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
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());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource in project so by onap.
the class SniroHomingV2IT method testProcessSolution_success_3Allotteds_1Solution.
@Test
public void testProcessSolution_success_3Allotteds_1Solution() {
beforeAllottedResource();
JSONObject asyncResponse = new JSONObject();
asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", "completed");
JSONArray solution1 = 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"))));
asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)).put("licenseSolutions", new JSONArray()));
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());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource in project so by onap.
the class OofHomingV2 method buildPlacementDemands.
/**
* Builds the placement demand list for the homing/licensing request
*/
private PlacementInfo buildPlacementDemands(ServiceInstance serviceInstance, PlacementInfo placementInfo) {
logger.trace("Building placement information demands");
List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
if (!allottedResourceList.isEmpty()) {
logger.debug("Adding allotted resources to placement demands list");
for (AllottedResource ar : allottedResourceList) {
if (isBlank(ar.getId())) {
ar.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
// addCandidates(ar, demand);
placementInfo.getPlacementDemands().add(demand);
}
}
List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
if (!vpnBondingLinkList.isEmpty()) {
logger.debug("Adding vpn bonding links to placement demands list");
for (VpnBondingLink vbl : vpnBondingLinkList) {
List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
for (ServiceProxy sp : serviceProxyList) {
if (isBlank(sp.getId())) {
sp.setId(UUID.randomUUID().toString());
}
PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
// addCandidates(sp, demand);
placementInfo.getPlacementDemands().add(demand);
}
}
}
return placementInfo;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource in project so by onap.
the class OofHomingV2 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();
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;
}
}
}
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource in project so by onap.
the class SniroHomingV2 method buildPlacementDemands.
/**
* Builds the placement demand list for the homing/licensing request
*/
private List<Demand> buildPlacementDemands(ServiceInstance serviceInstance) {
logger.trace("Building placement information demands");
List<Demand> placementDemands = new ArrayList<>();
List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources();
if (!allottedResourceList.isEmpty()) {
logger.debug("Adding allotted resources to placement demands list");
for (AllottedResource ar : allottedResourceList) {
if (isBlank(ar.getId())) {
ar.setId(UUID.randomUUID().toString());
}
Demand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource());
addCandidates(ar, demand);
placementDemands.add(demand);
}
}
List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks();
if (!vpnBondingLinkList.isEmpty()) {
logger.debug("Adding vpn bonding links to placement demands list");
for (VpnBondingLink vbl : vpnBondingLinkList) {
List<ServiceProxy> serviceProxyList = vbl.getServiceProxies();
for (ServiceProxy sp : serviceProxyList) {
if (isBlank(sp.getId())) {
sp.setId(UUID.randomUUID().toString());
}
Demand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
addCandidates(sp, demand);
placementDemands.add(demand);
}
}
}
List<ServiceProxy> serviceProxies = serviceInstance.getServiceProxies();
if (!serviceProxies.isEmpty()) {
logger.debug("Adding service proxies to placement demands list");
for (ServiceProxy sp : serviceProxies) {
if (isBlank(sp.getId())) {
sp.setId(UUID.randomUUID().toString());
}
Demand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy());
addCandidates(sp, demand);
placementDemands.add(demand);
}
}
return placementDemands;
}
Aggregations