Search in sources :

Example 11 with GenericVnf

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());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) RestClient(org.onap.so.client.RestClient) Test(org.junit.Test)

Example 12 with GenericVnf

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());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GraphInventoryPatchConverter(org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter) Test(org.junit.Test)

Example 13 with GenericVnf

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);
    }
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnfNotFoundException(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException) GenericVnfNotFoundException(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.exception.GenericVnfNotFoundException)

Example 14 with GenericVnf

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;
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) DuplicateNameException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException) GenericVnfs(org.onap.aai.domain.yang.GenericVnfs)

Example 15 with GenericVnf

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));
            }
        }
    }
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Aggregations

GenericVnf (org.onap.aai.domain.yang.GenericVnf)63 Test (org.junit.Test)42 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)11 File (java.io.File)9 GenericVnfs (org.onap.aai.domain.yang.GenericVnfs)9 VfModule (org.onap.aai.domain.yang.VfModule)9 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)9 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)9 ArrayList (java.util.ArrayList)8 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)8 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)7 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)7 RestClient (org.onap.so.client.RestClient)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)4 List (java.util.List)3 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3