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 AAIResourcesClientTest method buildRelationshipTest.
@Test
public void buildRelationshipTest() {
AAIResourcesClient client = aaiClient;
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test"));
Relationship relationship = new Relationship();
relationship.setRelatedLink(uri.build().toString());
Relationship actual = client.buildRelationship(uri);
assertThat("expect equal no label", actual, sameBeanAs(relationship));
relationship.setRelationshipLabel(AAIEdgeLabel.USES.toString());
actual = client.buildRelationship(uri, AAIEdgeLabel.USES);
assertThat("expect equal has label", actual, sameBeanAs(relationship));
}
use of org.onap.aai.domain.yang.Relationship in project so by onap.
the class ServicePluginFactory method getTpInfoFromLocalTp.
private void getTpInfoFromLocalTp(Map<String, Object> tpInfo, Optional<Pnf> optLocalPnf) {
if (optLocalPnf.isPresent()) {
Pnf localPnf = optLocalPnf.get();
for (Relationship rel : localPnf.getRelationshipList().getRelationship()) {
if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) {
String[] networkRef = rel.getRelatedLink().substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-");
if (networkRef.length == 6) {
tpInfo.put("local-access-provider-id", networkRef[1]);
tpInfo.put("local-access-client-id", networkRef[3]);
tpInfo.put("local-access-topology-id", networkRef[5]);
}
}
}
}
}
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);
}
}
Aggregations