- private Link createTapiLink(String sourceNode, String sourceTp, String destNode, String destTp, String linkId,
- String valueName, String sourceNodeQual) {
- Map<NodeEdgePointKey, NodeEdgePoint> nepList = new HashMap<>();
- Uuid sourceUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode,
- sourceNodeQual)).getBytes(Charset.forName("UTF-8"))).toString());
- Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", sourceNode, PHTNC_MEDIA,
- sourceTp)).getBytes(Charset.forName("UTF-8"))).toString());
- Uuid destUuidNode = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode,
- PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString());
- Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes((String.join("+", destNode, PHTNC_MEDIA,
- destTp)).getBytes(Charset.forName("UTF-8"))).toString());
- if (!(nodeExists(sourceUuidNode) && nodeExists(destUuidNode)
- && nepExists(sourceUuidTp, sourceUuidNode) && nepExists(destUuidTp, destUuidNode))) {
- LOG.error("Verify the input data. No link can be created, "
- + "as either the node or the tp doesnt exist in the TAPI topology");
- return null;
- }
- NodeEdgePoint sourceNep = new NodeEdgePointBuilder()
- .setTopologyUuid(this.tapiTopoUuid)
- .setNodeUuid(sourceUuidNode)
- .setNodeEdgePointUuid(sourceUuidTp)
- .build();
- nepList.put(sourceNep.key(), sourceNep);
- NodeEdgePoint destNep = new NodeEdgePointBuilder()
- .setTopologyUuid(this.tapiTopoUuid)
- .setNodeUuid(destUuidNode)
- .setNodeEdgePointUuid(destUuidTp)
- .build();
- nepList.put(destNep.key(), destNep);
- Name linkName = new NameBuilder().setValueName(valueName)
- .setValue(linkId)
- .build();
- CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
- .setCostAlgorithm("Restricted Shortest Path - RSP")
- .setCostName("HOP_COUNT")
- .setCostValue("12345678")
- .build();
- LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
- .setFixedLatencyCharacteristic("12345678")
- .setQueingLatencyCharacteristic("12345678")
- .setJitterCharacteristic("12345678")
- .setWanderCharacteristic("12345678")
- .setTrafficPropertyName("FIXED_LATENCY")
- .build();
- RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
- .setRiskCharacteristicName("risk characteristic")
- .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2"))
- .build();
- ValidationMechanism validationMechanism = new ValidationMechanismBuilder()
- .setValidationMechanism("validation mechanism")
- .setValidationRobustness("validation robustness")
- .setLayerProtocolAdjacencyValidated("layer protocol adjacency")
- .build();
- return new LinkBuilder()
- .setUuid(new Uuid(
- UUID.nameUUIDFromBytes(linkId.getBytes(Charset.forName("UTF-8")))
- .toString()))
- .setName(Map.of(linkName.key(), linkName))
- .setLayerProtocolName(List.of(LayerProtocolName.PHOTONICMEDIA))
- .setNodeEdgePoint(nepList)
- .setDirection(ForwardingDirection.BIDIRECTIONAL)
- .setTransitionedLayerProtocolName(new ArrayList<>())
- .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON)
- .setRestorationPolicy(RestorationPolicy.NA)
- .build())
- .setAdministrativeState(AdministrativeState.UNLOCKED)
- .setOperationalState(OperationalState.ENABLED)
- .setLifecycleState(LifecycleState.INSTALLED)
- .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize(
- new TotalSizeBuilder().setUnit(CapacityUnit.GBPS)
- .setValue(Uint64.valueOf(100)).build()).build())
- .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize(
- new TotalSizeBuilder().setUnit(CapacityUnit.MBPS)
- .setValue(Uint64.valueOf(100)).build())
- .build())
- .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
- .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
- .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
- .setErrorCharacteristic("error")
- .setLossCharacteristic("loss")
- .setRepeatDeliveryCharacteristic("repeat delivery")
- .setDeliveryOrderCharacteristic("delivery order")
- .setUnavailableTimeCharacteristic("unavailable time")
- .setServerIntegrityProcessCharacteristic("server integrity process")
- .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism))
- .build();
- }
-
- private boolean nepExists(Uuid nepUuid, Uuid nodeUuid) {
- LOG.info("Checking if nep with uuid {} existis in tapi topology", nepUuid);
- try {
- InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
- .augmentation(Context1.class).child(TopologyContext.class)
- .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
- .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
- .build();
- Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
- LogicalDatastoreType.OPERATIONAL, onepIID).get();
- if (!optionalOnep.isPresent()) {
- LOG.error("ONEP is not present in datastore");
- return false;
- }
- return true;
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Couldnt retrieve nep from datastore");
- return false;
- }
- }
-
- private boolean nodeExists(Uuid nodeUuid) {
- LOG.info("Checking if node with uuid {} existis in tapi topology", nodeUuid);
- try {
- InstanceIdentifier<Node> nodeIID = InstanceIdentifier.builder(Context.class)
- .augmentation(Context1.class).child(TopologyContext.class)
- .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid))
- .build();
- Optional<Node> optionalNode = this.networkTransactionService.read(
- LogicalDatastoreType.OPERATIONAL, nodeIID).get();
- if (!optionalNode.isPresent()) {
- LOG.error("Node is not present in datastore");
- return false;
- }
- return true;
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Couldnt retrieve nep from datastore");
- return false;
- }