Search in sources :

Example 1 with SolutionInfo

use of org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo 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;
                }
            }
        }
    }
}
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) JSONObject(org.json.JSONObject) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) 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 2 with SolutionInfo

use of org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo 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)

Aggregations

JSONObject (org.json.JSONObject)2 AllottedResource (org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)2 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)2 VpnBondingLink (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink)2 SolutionInfo (org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2