Search in sources :

Example 6 with Relationships

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

the class WorkflowAction method getRelatedResourcesInVnfc.

protected <T> T getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectName name) throws VnfcMultipleRelationshipException {
    T configuration = null;
    AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfc.getVnfcName()));
    AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
    Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
    if (relationshipsOp.isEmpty()) {
        logger.debug("No relationships were found for VNFC in AAI");
    } else {
        Relationships relationships = relationshipsOp.get();
        List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, name);
        if (configurationResultWrappers.size() > 1) {
            throw new VnfcMultipleRelationshipException(vnfc.getVnfcName());
        }
        if (!configurationResultWrappers.isEmpty()) {
            Optional<T> configurationOp = configurationResultWrappers.get(0).asBean(resultClass);
            if (configurationOp.isPresent()) {
                configuration = configurationOp.get();
            }
        }
    }
    return configuration;
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 7 with Relationships

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

the class CreateVFModule method getNodeType.

protected NodeType getNodeType(CloudRegion cloudRegion) {
    AAIResourceUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()));
    AAIResourcesClient client = getAAIClient();
    Optional<Relationships> relationships = client.get(cloudRegionUri).getRelationships();
    if (relationships.isPresent()) {
        AAIPluralResourceUri networkTechsGreenfieldUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())).relatedTo(Types.NETWORK_TECHNOLOGIES.getFragment()).queryParam("network-technology-name", NodeType.GREENFIELD.getNetworkTechnologyName());
        AAIResultWrapper networkTechsGreenfield = client.get(networkTechsGreenfieldUri);
        if (networkTechsGreenfield != null && !networkTechsGreenfield.isEmpty()) {
            return NodeType.GREENFIELD;
        }
    }
    return NodeType.BROWNFIELD;
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 8 with Relationships

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

the class BBInputSetup method mapGenericVnf.

protected GenericVnf mapGenericVnf(AAIResourceUri aaiResourceUri) {
    AAIResultWrapper aaiGenericVnfWrapper = this.bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri);
    Optional<org.onap.aai.domain.yang.GenericVnf> aaiGenericVnfOp = aaiGenericVnfWrapper.asBean(org.onap.aai.domain.yang.GenericVnf.class);
    if (!aaiGenericVnfOp.isPresent()) {
        return null;
    }
    GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnfOp.get());
    Optional<Relationships> relationshipsOp = aaiGenericVnfWrapper.getRelationships();
    if (relationshipsOp.isPresent()) {
        Relationships relationships = relationshipsOp.get();
        this.mapPlatform(relationships.getByType(Types.PLATFORM, uri -> uri.nodesOnly(true)), genericVnf);
        this.mapLineOfBusiness(relationships.getByType(Types.LINE_OF_BUSINESS, uri -> uri.nodesOnly(true)), genericVnf);
        genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(Types.VOLUME_GROUP)));
        genericVnf.getInstanceGroups().addAll(mapInstanceGroups(relationships.getByType(Types.INSTANCE_GROUP)));
    }
    return genericVnf;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) Vnfs(org.onap.so.serviceinstancebeans.Vnfs) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) StringUtils(org.apache.commons.lang3.StringUtils) ServiceProxyResourceCustomization(org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) Service(org.onap.so.db.catalog.beans.Service) Map(java.util.Map) Tenant(org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ServiceProxy(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy) ConfigurationResourceCustomization(org.onap.so.db.catalog.beans.ConfigurationResourceCustomization) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) LineOfBusiness(org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) UUID(java.util.UUID) Pair(org.javatuples.Pair) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) Objects(java.util.Objects) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Vnfc(org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) HashMap(java.util.HashMap) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) VfModules(org.onap.so.serviceinstancebeans.VfModules) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) CollectionNetworkResourceCustomization(org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization) Logger(org.slf4j.Logger) ServiceModel(org.onap.so.bpmn.servicedecomposition.entities.ServiceModel) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VnfcInstanceGroupCustomization(org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) Networks(org.onap.so.serviceinstancebeans.Networks) Component(org.springframework.stereotype.Component) Platform(org.onap.so.bpmn.servicedecomposition.bbobjects.Platform) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Resources(org.onap.so.serviceinstancebeans.Resources) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 9 with Relationships

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

the class ServicePluginFactory method isRemotePInterface.

// this method check if pInterface is remote
private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) {
    String uriString = uri.build().toString();
    if (uriString != null) {
        // get the pnfname
        String[] token = uriString.split("/");
        AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(token[4]));
        AAIResultWrapper wrapper = client.get(parent);
        Optional<Relationships> optRelationships = wrapper.getRelationships();
        if (optRelationships.isPresent()) {
            Relationships relationships = optRelationships.get();
            return !relationships.getRelatedUris(Types.EXT_AAI_NETWORK).isEmpty();
        }
    }
    return false;
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 10 with Relationships

use of org.onap.aaiclient.client.aai.entities.Relationships 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

Relationships (org.onap.aaiclient.client.aai.entities.Relationships)36 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)27 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)20 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)10 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)6 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)6 HashMap (java.util.HashMap)4 List (java.util.List)4 VpnBinding (org.onap.aai.domain.yang.VpnBinding)4 IPAddressString (inet.ipaddr.IPAddressString)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 NotFoundException (javax.ws.rs.NotFoundException)2