Search in sources :

Example 6 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class HeatBridgeImpl method buildAddNetworksToAaiAction.

public void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks) {
    networks.forEach(network -> {
        L3Network l3Network = aaiHelper.buildNetwork(network);
        if (l3Network != null) {
            l3Network.setSubnets(buildSunets(network));
            RelationshipList relationshipList = new RelationshipList();
            List<Relationship> relationships = relationshipList.getRelationship();
            relationships.add(aaiHelper.getRelationshipToVfModule(genericVnfId, vfModuleId));
            relationships.add(aaiHelper.getRelationshipToTenant(cloudOwner, cloudRegionId, tenantId));
            l3Network.setRelationshipList(relationshipList);
            transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3Network.getNetworkId())), Optional.of(l3Network));
        }
    });
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) RelationshipList(org.onap.aai.domain.yang.RelationshipList) Relationship(org.onap.aai.domain.yang.Relationship)

Example 7 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class BBInputSetupUtils method getRelatedNetworkByNameFromServiceInstance.

public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws MultipleObjectsFoundException {
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)).relatedTo(Types.L3_NETWORKS.getFragment()).queryParam("network-name", networkName);
    Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
    L3Network network = null;
    if (!networks.isPresent()) {
        logger.debug("No Networks matched by name");
        return Optional.empty();
    } else {
        if (networks.get().getL3Network().size() > 1) {
            String message = String.format("Multiple networks found for service-instance-id: %s and network-name: %s.", serviceInstanceId, networkName);
            throw new MultipleObjectsFoundException(message);
        } else {
            network = networks.get().getL3Network().get(0);
        }
        return Optional.of(network);
    }
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) MultipleObjectsFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) L3Networks(org.onap.aai.domain.yang.L3Networks)

Example 8 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class NetworkBBUtilsTest method isRelationshipRelatedToExistsTrueTest.

@Test
public void isRelationshipRelatedToExistsTrueTest() throws Exception {
    final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
    Optional<L3Network> l3network = aaiResultWrapper.asBean(L3Network.class);
    boolean isVfModule = networkBBUtils.isRelationshipRelatedToExists(l3network, "vf-module");
    assertTrue(isVfModule);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 9 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class AaiResourceIdValidatorTest method validateNetworkResourceIdInAAIDuplicateNameTest.

@Test
public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    L3Network network = new L3Network();
    network.setModelCustomizationId("9999999");
    Optional<L3Network> opNetwork = Optional.of(network);
    when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique."));
    testedObject.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Example 10 with L3Network

use of org.onap.aai.domain.yang.L3Network in project so by onap.

the class AaiResourceIdValidatorTest method validateResourceIdInAAINetworkTest.

@Test
public void validateResourceIdInAAINetworkTest() throws Exception {
    RequestDetails reqDetails = setupRequestDetails();
    WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
    workflowResourceIds.setServiceInstanceId("siId123");
    L3Network network = new L3Network();
    network.setNetworkId("id123");
    network.setModelCustomizationId("1234567");
    Optional<L3Network> opNetwork = Optional.of(network);
    L3Network network2 = new L3Network();
    network2.setNetworkId("id123");
    network2.setModelCustomizationId("222");
    Optional<L3Network> opNetwork2 = Optional.of(network2);
    when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
    when(bbInputSetupUtilsMock.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222")).thenReturn(opNetwork2);
    String id = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails, workflowResourceIds);
    assertEquals("id123", id);
    String id2 = testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails, workflowResourceIds);
    assertEquals("generatedId123", id2);
    this.expectedException.expect(DuplicateNameException.class);
    this.expectedException.expectMessage(containsString("l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
    testedObject.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails, workflowResourceIds);
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Test(org.junit.Test)

Aggregations

L3Network (org.onap.aai.domain.yang.L3Network)14 Test (org.junit.Test)10 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 L3Networks (org.onap.aai.domain.yang.L3Networks)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)3 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)3 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)3 File (java.io.File)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 VpnBinding (org.onap.aai.domain.yang.VpnBinding)2 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)2 SecureRandom (java.security.SecureRandom)1 Relationship (org.onap.aai.domain.yang.Relationship)1 RelationshipList (org.onap.aai.domain.yang.RelationshipList)1 RouteTarget (org.onap.aai.domain.yang.RouteTarget)1 RouteTargets (org.onap.aai.domain.yang.RouteTargets)1 AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)1 MultipleObjectsFoundException (org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException)1