use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class ServicePluginFactory method selectLogicalLink.
private LogicalLink selectLogicalLink(List<LogicalLink> logicalLinks, String svcName) {
Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst();
if (customType.isPresent()) {
String[] allowedList = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local").split(",");
for (String localTp : allowedList) {
for (LogicalLink link : logicalLinks) {
for (Relationship relationship : link.getRelationshipList().getRelationship()) {
if (relationship.getRelatedTo().equals("p-interface") && relationship.getRelatedLink().contains("-ltpId-" + localTp) && link.getOperationalStatus().equalsIgnoreCase("up")) {
logger.info("linkname:{} is matching with allowed list", link.getLinkName());
return link;
}
}
}
}
logger.error("There is no matching logical link for allowed list :{}", Arrays.toString(allowedList));
return null;
} else {
logger.info("link customization is not required");
return logicalLinks.get(0);
}
}
use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class ServicePluginFactory method getTpInfoFromRemoteTp.
private void getTpInfoFromRemoteTp(Map<String, Object> tpInfo, String[] networkRefRemote, Optional<Pnf> optRemotePnf) {
if (optRemotePnf.isPresent()) {
Pnf remotePnf = optRemotePnf.get();
for (Relationship rel : remotePnf.getRelationshipList().getRelationship()) {
if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) {
String[] networkRef = rel.getRelatedLink().substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-");
if (networkRef.length == 6) {
tpInfo.put("remote-access-provider-id", networkRefRemote[1]);
tpInfo.put("remote-access-client-id", networkRefRemote[3]);
tpInfo.put("remote-access-topology-id", networkRefRemote[5]);
}
}
}
}
}
use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class ServiceEBBLoader method traverseAAIService.
public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) {
try {
ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
var serviceResource = new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId());
resourceList.add(serviceResource);
traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
if (serviceInstanceMSO.getNetworks() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO.getNetworks()) {
aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
Resource networkResource = new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource);
ModelInfoNetwork modelInfoNetwork = network.getModelInfoNetwork();
if (modelInfoNetwork != null) {
networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
networkResource.setModelVersionId(modelInfoNetwork.getModelUUID());
networkResource.setModelCustomizationId(modelInfoNetwork.getModelCustomizationUUID());
}
resourceList.add(networkResource);
}
}
if (serviceInstanceMSO.getCollection() != null) {
logger.debug("found networkcollection");
aaiResourceIds.add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId(), false, serviceResource));
}
if (serviceInstanceMSO.getConfigurations() != null) {
for (Configuration config : serviceInstanceMSO.getConfigurations()) {
Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId());
if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) {
for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) {
aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false, serviceResource));
break;
}
}
}
}
}
} catch (Exception ex) {
logger.error("Exception in traverseAAIService", ex);
buildAndThrowException(execution, "Could not find existing Service Instance or related Instances to execute the request on.");
}
}
use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class AAITransactionalClient method buildRelationship.
private Relationship buildRelationship(AAIResourceUri uri, Optional<AAIEdgeLabel> label) {
final Relationship result = new Relationship();
result.setRelatedLink(uri.build().toString());
if (label.isPresent()) {
result.setRelationshipLabel(label.toString());
}
return result;
}
use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class AaiConnectionTest method testRelatedToProperty.
@Test
public void testRelatedToProperty() {
// given
final Relationship relationship = new Relationship();
final RelatedToProperty property = new RelatedToProperty();
property.setPropertyKey(KEY);
property.setPropertyValue(VALUE);
relationship.getRelatedToProperty().add(property);
// when
final String value = AaiConnection.getRelatedToProperty(relationship, KEY);
// then
assertEquals(VALUE, value);
}
Aggregations