Search in sources :

Example 1 with AAIResourcesClient

use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.

the class AAIClientHelper method updateAaiOperationalEnvironment.

public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws AAIClientCallFailed {
    try {
        AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(operationalEnvironmentId));
        AAIResourcesClient aaiClient = this.getClient();
        aaiClient.update(uri, payload);
    } catch (Exception ex) {
        logStackTrace(ex);
        throw new AAIClientCallFailed("Call to A&AI failed!", ex);
    }
}
Also used : AAIClientCallFailed(org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) NotFoundException(javax.ws.rs.NotFoundException)

Example 2 with AAIResourcesClient

use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.

the class AAIClientHelper method createRelationship.

/**
 * Create a relationship between ECOMP managing and VNF Operational Environments
 *
 * @param managingEcompOperationalEnvironmentId
 * @param vnfOperationalEnvironmentId
 * @throws Exception
 */
public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) {
    AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(managingEcompOperationalEnvironmentId));
    AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(vnfOperationalEnvironmentId));
    AAIResourcesClient client = this.getClient();
    client.connect(vnfEnvUri, ecompEnvUri);
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient)

Example 3 with AAIResourcesClient

use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.

the class AAIClientHelper method getAaiOperationalEnvironment.

/**
 * Get managing ECOMP Environment Info from A&AI
 *
 * @param id = operationalEnvironmentId
 * @return AAIResultWrapper object
 */
public AAIResultWrapper getAaiOperationalEnvironment(String id) {
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(id));
    uri.depth(Depth.ZERO);
    AAIResourcesClient client = this.getClient();
    return client.get(uri, NotFoundException.class);
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient)

Example 4 with AAIResourcesClient

use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.

the class AAIClientHelper method createOperationalEnvironment.

/**
 * Create an Operational Environment object in A&AI
 *
 * @param operationalEnvironment object
 */
public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment) {
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(operationalEnvironment.getOperationalEnvironmentId()));
    AAIResourcesClient client = this.getClient();
    client.create(uri, operationalEnvironment);
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient)

Example 5 with AAIResourcesClient

use of org.onap.aaiclient.client.aai.AAIResourcesClient in project so by onap.

the class ServicePluginFactory method getTPsfromAAI.

// This method returns Local and remote TPs information from AAI
public Map getTPsfromAAI(String serviceName) {
    Map<String, Object> tpInfo = new HashMap<>();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLinks());
    AAIResourcesClient client = new AAIResourcesClient();
    Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri);
    if (result.isPresent()) {
        LogicalLinks links = result.get();
        LogicalLink link = selectLogicalLink(links.getLogicalLink(), serviceName);
        if (link != null) {
            boolean isRemoteLink = false;
            logger.info("processing link :{}", link.getLinkName());
            AAIResultWrapper wrapper = new AAIResultWrapper(link);
            Optional<Relationships> optRelationships = wrapper.getRelationships();
            List<AAIResourceUri> pInterfaces = new ArrayList<>();
            if (optRelationships.isPresent()) {
                Relationships relationships = optRelationships.get();
                if (!relationships.getRelatedUris(Types.EXT_AAI_NETWORK).isEmpty()) {
                    isRemoteLink = true;
                }
                pInterfaces.addAll(relationships.getRelatedUris(Types.P_INTERFACE));
                if (isRemoteLink) {
                    // find remote p interface
                    AAIResourceUri localTP = null;
                    AAIResourceUri remoteTP = null;
                    AAIResourceUri pInterface0 = pInterfaces.get(0);
                    if (isRemotePInterface(client, pInterface0)) {
                        remoteTP = pInterfaces.get(0);
                        localTP = pInterfaces.get(1);
                    } else {
                        localTP = pInterfaces.get(0);
                        remoteTP = pInterfaces.get(1);
                    }
                    tpInfo = getTPInfo(client, localTP, remoteTP);
                }
            }
        }
    }
    return tpInfo;
}
Also used : HashMap(java.util.HashMap) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) LogicalLink(org.onap.aai.domain.yang.LogicalLink) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) LogicalLinks(org.onap.aai.domain.yang.LogicalLinks) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

AAIResourcesClient (org.onap.aaiclient.client.aai.AAIResourcesClient)30 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)23 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)5 NotFoundException (javax.ws.rs.NotFoundException)4 Test (org.junit.Test)4 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Logger (org.slf4j.Logger)3 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Response (javax.ws.rs.core.Response)2 JSONObject (org.json.JSONObject)2 ServiceInstance (org.onap.aai.domain.yang.v16.ServiceInstance)2 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)2 GraphInventoryUriNotFoundException (org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException)2 CamundaResponse (org.onap.so.apihandler.camundabeans.CamundaResponse)2 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)2 GetE2EServiceInstanceResponse (org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse)2 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)2