Search in sources :

Example 21 with Pnf

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

the class AAIObjectMapperTest method pnfMap.

@Test
public void pnfMap() {
    final String pnfId = "PNF_id1";
    final String pnfName = "PNF_name1";
    final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb03e";
    final String modelInvariantId = "341a6f84-2cf9-4942-8f9e-2472ffe4e1d8";
    final String modelVersionId = "b13a0706-46b9-4a98-a9f9-5b28431235e7";
    final OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED;
    Pnf pnf = new Pnf();
    pnf.setPnfId(pnfId);
    pnf.setPnfName(pnfName);
    pnf.setModelInfoPnf(new ModelInfoPnf());
    pnf.getModelInfoPnf().setModelCustomizationUuid(modelCustomizationId);
    pnf.getModelInfoPnf().setModelInvariantUuid(modelInvariantId);
    pnf.getModelInfoPnf().setModelUuid(modelVersionId);
    pnf.setOrchestrationStatus(orchestrationStatus);
    org.onap.aai.domain.yang.Pnf aaiPnf = aaiObjectMapper.mapPnf(pnf);
    assertEquals(aaiPnf.getPnfId(), pnfId);
    assertEquals(aaiPnf.getPnfName(), pnfName);
    assertEquals(aaiPnf.getModelCustomizationId(), modelCustomizationId);
    assertEquals(aaiPnf.getModelInvariantId(), modelInvariantId);
    assertEquals(aaiPnf.getModelVersionId(), modelVersionId);
    assertEquals(aaiPnf.getOrchestrationStatus(), orchestrationStatus.toString());
}
Also used : ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) Test(org.junit.Test)

Example 22 with Pnf

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

the class BBInputSetupPnf method populatePnfToServiceInstance.

static void populatePnfToServiceInstance(Pnfs pnfs, String pnfId, ServiceInstance serviceInstance) {
    removePnfFromServiceIfExists(serviceInstance, pnfId);
    Pnf pnf = new Pnf();
    pnf.setPnfId(pnfId);
    pnf.setPnfName(pnfs.getInstanceName());
    pnf.setModelInfoPnf(new ModelInfoPnf());
    pnf.getModelInfoPnf().setModelCustomizationUuid(pnfs.getModelInfo().getModelCustomizationId());
    pnf.getModelInfoPnf().setModelInvariantUuid(pnfs.getModelInfo().getModelInvariantId());
    pnf.getModelInfoPnf().setModelUuid(pnfs.getModelInfo().getModelVersionId());
    pnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    serviceInstance.getPnfs().add(pnf);
}
Also used : ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) ModelInfoPnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf)

Example 23 with Pnf

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

the class RegisterForPnfReadyEvent method getPnfName.

private String getPnfName(DelegateExecution execution) throws BBObjectNotFoundException {
    BuildingBlockExecution buildingBlockExecution = (BuildingBlockExecution) execution.getVariable("gBuildingBlockExecution");
    Pnf pnf = extractPojosForBB.extractByKey(buildingBlockExecution, ResourceKey.PNF);
    String pnfName = pnf.getPnfName();
    if (Strings.isNullOrEmpty(pnfName)) {
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "pnf name is not set");
    }
    return pnfName;
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf)

Example 24 with Pnf

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

the class SniroHomingV2 method setPnf.

/**
 * Sets the pnf data to a pnf object
 */
private Pnf setPnf(Map<String, String> assignmentsMap, String role) {
    Pnf pnf = new Pnf();
    pnf.setRole(role);
    pnf.setOrchestrationStatus(OrchestrationStatus.CREATED);
    pnf.setPnfName(assignmentsMap.get(role + "PnfName"));
    return pnf;
}
Also used : Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf)

Example 25 with Pnf

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

the class SniroHomingV2 method setSolution.

/**
 * Creates and sets necessary pojos with placement solution data for a given demand
 */
private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement) {
    logger.debug("Mapping placement solution");
    String invalidMessage = "Sniro Managers Response contains invalid: ";
    JSONObject solution = placement.getJSONObject("solution");
    String identifierType = solution.getString(IDENTIFIER_TYPE);
    List<String> identifiersList = jsonUtils.StringArrayToList(solution.getJSONArray("identifiers").toString());
    String identifierValue = identifiersList.get(0);
    JSONArray assignments = placement.getJSONArray("assignmentInfo");
    Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value");
    solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome")));
    ServiceInstance si = new ServiceInstance();
    CloudRegion cloud = setCloud(assignmentsMap);
    if (identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())) {
        solutionInfo.setHomed(true);
        si.setServiceInstanceId(identifierValue);
        si.setOrchestrationStatus(OrchestrationStatus.CREATED);
        cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId"));
        if (assignmentsMap.containsKey(VNF_HOST_NAME) && !assignmentsMap.get(VNF_HOST_NAME).isEmpty()) {
            logger.debug("Resources has been homed to a vnf");
            GenericVnf vnf = setVnf(assignmentsMap);
            vnf.setCloudRegion(cloud);
            si.getVnfs().add(vnf);
        } else if (assignmentsMap.containsKey("primaryPnfName")) {
            logger.debug("Resources has been homed to a pnf");
            Pnf priPnf = setPnf(assignmentsMap, "primary");
            priPnf.setCloudRegion(cloud);
            si.getPnfs().add(priPnf);
            if (assignmentsMap.containsKey("secondaryPnfName")) {
                Pnf secPnf = setPnf(assignmentsMap, "secondary");
                secPnf.setCloudRegion(cloud);
                si.getPnfs().add(secPnf);
            }
        }
    } else if (identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())) {
        logger.debug("Resources has been homed to a cloud region");
        cloud.setLcpCloudRegionId(identifierValue);
        solutionInfo.setHomed(false);
        solutionInfo.setTargetedCloudRegion(cloud);
        si.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
    } else {
        logger.debug(invalidMessage + IDENTIFIER_TYPE);
        throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE);
    }
    si.setSolutionInfo(solutionInfo);
    return si;
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) JSONObject(org.json.JSONObject) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) JSONArray(org.json.JSONArray) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Aggregations

Pnf (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf)42 Test (org.junit.Test)22 ModelInfoPnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)8 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)5 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)4 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)3 OrchestrationStatus (org.onap.so.db.catalog.beans.OrchestrationStatus)3 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Objects (java.util.Objects)2