Search in sources :

Example 21 with Relationship

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

the class AaiConnection method receiveVserverName.

public String receiveVserverName(final String genericId) {
    final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericId));
    final Optional<GenericVnf> response = getResourcesClient().get(GenericVnf.class, resourceUri);
    if (response.isPresent()) {
        final GenericVnf genericVnf = response.get();
        final RelationshipList relationshipList = genericVnf.getRelationshipList();
        if (relationshipList == null || relationshipList.getRelationship() == null) {
            return null;
        }
        for (final Relationship relationship : relationshipList.getRelationship()) {
            if (VSERVER.equals(relationship.getRelatedTo())) {
                final String vserverName = getRelatedToProperty(relationship, VSERVER_NAME);
                if (vserverName == null) {
                    final String cloudOwner = getRelationshipData(relationship, CLOUD_OWNER);
                    final String cloudId = getRelationshipData(relationship, CLOUD_REGION_ID);
                    final String tenantId = getRelationshipData(relationship, TENANT_ID);
                    final String vserverId = getRelationshipData(relationship, VSERVER_ID);
                    return receiveVserverNameFromParams(cloudOwner, cloudId, tenantId, vserverId);
                }
                return vserverName;
            }
        }
    }
    return null;
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) GenericVnf(org.onap.aai.domain.yang.GenericVnf) Relationship(org.onap.aai.domain.yang.Relationship) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)

Example 22 with Relationship

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

the class HeatBridgeImpl method processVlanTag.

protected void processVlanTag(LInterface lInterface, List<String> vlanTags) throws HeatBridgeException {
    for (String vlanTag : vlanTags) {
        Relationship vlanTagRelationship = new Relationship();
        vlanTagRelationship.setRelatedLink(createVlanTagUri(vlanTag));
        lInterface.getRelationshipList().getRelationship().add(vlanTagRelationship);
    }
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship) IPAddressString(inet.ipaddr.IPAddressString)

Example 23 with Relationship

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

the class HeatBridgeImpl method processOVS.

protected void processOVS(LInterface lInterface, String hostName, String interfaceName) {
    Relationship lagRelationship = new Relationship();
    lagRelationship.setRelatedLink(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(hostName).lagInterface(interfaceName)).build().toString());
    lInterface.getRelationshipList().getRelationship().add(lagRelationship);
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship)

Example 24 with Relationship

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

the class AAIPnfResources method isRelatedToService.

private void isRelatedToService(org.onap.aai.domain.yang.Pnf pnfFromAai) throws Exception {
    if (pnfFromAai.getRelationshipList() != null) {
        for (Relationship relationship : pnfFromAai.getRelationshipList().getRelationship()) {
            if (relationship.getRelatedTo().equals("service-instance")) {
                String errorMessage = prepareRelationErrorMessage(pnfFromAai, relationship);
                logger.error(errorMessage);
                throw new Exception(errorMessage);
            }
        }
    }
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship)

Example 25 with Relationship

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

the class AAITransactionalClientTest method testCreate.

@Test
public void testCreate() throws IOException {
    final Relationship body = new Relationship();
    body.setRelatedLink(uriB.build().toString());
    AAITransactionalClient transactions = aaiClient.beginTransaction().create(uriA.clone().relationshipAPI(), body);
    String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
    Map<String, Object> actual = mapper.readValue(serializedTransactions, new TypeReference<Map<String, Object>>() {
    });
    Map<String, Object> expected = mapper.readValue(getJson("test-request-small.json"), new TypeReference<Map<String, Object>>() {
    });
    assertEquals(actual, expected);
}
Also used : Relationship(org.onap.aai.domain.yang.Relationship) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Relationship (org.onap.aai.domain.yang.Relationship)28 Test (org.junit.Test)11 RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)6 VfModule (org.onap.aai.domain.yang.VfModule)5 ArrayList (java.util.ArrayList)4 GenericVnf (org.onap.aai.domain.yang.GenericVnf)4 RelationshipData (org.onap.aai.domain.yang.RelationshipData)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)4 Server (org.openstack4j.model.compute.Server)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)3 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 IOException (java.io.IOException)2 List (java.util.List)2