use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink 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.VpnBondingLink 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;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink in project so by onap.
the class OofHomingV2IT method beforeVpnBondingLink.
public void beforeVpnBondingLink(String id) {
VpnBondingLink bondingLink = new VpnBondingLink();
bondingLink.setVpnBondingLinkId("testVpnBondingId" + id);
bondingLink.getServiceProxies().add(setServiceProxy("1", "transport"));
ServiceProxy sp2 = setServiceProxy("2", "infrastructure");
Candidate requiredCandidate = new Candidate();
requiredCandidate.setIdentifierType(CandidateType.VNF_ID);
List<String> c = new ArrayList<String>();
c.add("testVnfId");
requiredCandidate.setIdentifiers(c);
sp2.addRequiredCandidates(requiredCandidate);
bondingLink.getServiceProxies().add(sp2);
serviceInstance.getVpnBondingLinks().add(bondingLink);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink in project so by onap.
the class OofHomingV2IT method testProcessSolution_success_1VpnLink_1Solution.
@Test
public void testProcessSolution_success_1VpnLink_1Solution() {
beforeVpnBondingLink("1");
JSONObject asyncResponse = new JSONObject();
asyncResponse.put("transactionId", "transactionId").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"))));
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.getVpnBondingLinks().isEmpty());
VpnBondingLink link = si.getVpnBondingLinks().get(0);
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());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink in project so by onap.
the class SniroHomingV2IT method testProcessSolution_success_1VpnLink_1Solution.
@Test(expected = Test.None.class)
public void testProcessSolution_success_1VpnLink_1Solution() {
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"))));
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.getVpnBondingLinks().isEmpty());
VpnBondingLink link = si.getVpnBondingLinks().get(0);
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());
}
Aggregations