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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations