use of org.onap.aai.domain.yang.GenericVnf in project so by onap.
the class AAIResourcesClientTest method testGetFirstWrongPluralClass.
@Test
public void testGetFirstWrongPluralClass() {
GenericVnf vnf = new GenericVnf();
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs());
RestClient restClientMock = mock(RestClient.class);
doReturn(restClientMock).when(client).createClient(uri);
when(restClientMock.get(GenericVnf.class)).thenReturn(Optional.of(vnf));
Optional<GenericVnf> result = aaiClient.getFirst(GenericVnf.class, GenericVnf.class, uri);
assertFalse(result.isPresent());
}
use of org.onap.aai.domain.yang.GenericVnf in project so by onap.
the class GraphInventoryPatchConverterTest method convertObjectToPatchFormatTest.
@Test
public void convertObjectToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
GenericVnf vnf = new GenericVnf();
vnf.setIpv4Loopback0Address("");
String result = validator.marshallObjectToPatchFormat(vnf);
GenericVnf resultObj = mapper.readValue(result.toString(), GenericVnf.class);
assertTrue("expect object to become a String to prevent double marshalling", result instanceof String);
assertNull("expect null because of custom mapper", resultObj.getIpv4Loopback0Address());
}
use of org.onap.aai.domain.yang.GenericVnf in project so by onap.
the class MonitorVnfmNodeTask method getNodeStatus.
/**
* Check the final status of vnf in A&AI
*
* @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
*/
public void getNodeStatus(final BuildingBlockExecution execution) {
try {
LOGGER.debug("Executing getNodeStatus ...");
final org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
final String vnfId = vnf.getVnfId();
LOGGER.debug("Query A&AI for generic VNF using vnfID: {}", vnfId);
final Optional<GenericVnf> aaiGenericVnfOptional = aaiVnfResources.getGenericVnf(vnfId);
if (!aaiGenericVnfOptional.isPresent()) {
throw new GenericVnfNotFoundException("Unable to find generic vnf in A&AI using vnfID: " + vnfId);
}
final GenericVnf genericVnf = aaiGenericVnfOptional.get();
final String orchestrationStatus = genericVnf.getOrchestrationStatus();
LOGGER.debug("Found generic vnf with orchestration status : {}", orchestrationStatus);
execution.setVariable(getNodeStatusVariableName(), isOrchestrationStatusValid(orchestrationStatus));
} catch (final Exception exception) {
LOGGER.error("Unable to get vnf from AAI", exception);
exceptionUtil.buildAndThrowWorkflowException(execution, 1220, exception);
}
}
use of org.onap.aai.domain.yang.GenericVnf in project so by onap.
the class AaiResourceIdValidator method validateVnfResourceIdInAAI.
protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName, RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException {
Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName);
if (vnf.isPresent()) {
if (vnf.get().getModelCustomizationId().equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
return vnf.get().getVnfId();
} else {
throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, vnf.get().getModelCustomizationId()));
}
}
GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
if (vnfs != null) {
throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
}
return generatedResourceId;
}
use of org.onap.aai.domain.yang.GenericVnf in project so by onap.
the class ServiceEBBLoader method traverseServiceInstanceMSOVnfs.
private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, Resource serviceResource, List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
if (serviceInstanceMSO.getVnfs() == null) {
return;
}
for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
GenericVnf genericVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource);
vnfResource.setVnfCustomizationId(genericVnf.getModelCustomizationId());
vnfResource.setModelCustomizationId(genericVnf.getModelCustomizationId());
vnfResource.setModelVersionId(genericVnf.getModelVersionId());
resourceList.add(vnfResource);
traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf);
if (vnf.getVolumeGroups() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource));
}
}
}
}
Aggregations