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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations