private Node readOvsdbNodeByRef(OvsdbNodeRef nodeRef) { Preconditions.checkNotNull(nodeRef, "Cannot READ OVS Node from OVSDB operational store, nodeRef is null."); InstanceIdentifier<Node> bridgeIID = (InstanceIdentifier<Node>) nodeRef.getValue(); return SfcDataStoreAPI.readTransactionAPI(bridgeIID, LogicalDatastoreType.OPERATIONAL); } }
public Node readOvsdbNode(Node bridgeNode) { Node ovsdbNode = null; OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); if (bridgeAugmentation != null) { InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue(); ovsdbNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid); }else{ LOG.debug("readOvsdbNode: Provided node is not a bridge node : {}",bridgeNode); } return ovsdbNode; }
public Node readOvsdbNode(Node bridgeNode) { Node ovsdbNode = null; OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); if (bridgeAugmentation != null) { InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue(); ovsdbNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid); }else{ LOG.debug("readOvsdbNode: Provided node is not a bridge node : {}",bridgeNode); } return ovsdbNode; }
public Node readOvsdbNode(Node bridgeNode) { Node ovsdbNode = null; OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); if (bridgeAugmentation != null) { InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue(); ovsdbNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid); }else{ LOG.debug("readOvsdbNode: Provided node is not a bridge node : {}",bridgeNode); } return ovsdbNode; }
public static OvsdbNodeAugmentation getOvsdbNodeAugmentation(OvsdbNodeRef nodeRef, ExecutorService executor) { Preconditions.checkNotNull(executor); if (nodeRef.getValue().getTargetType().equals(Node.class)) { Object[] methodParams = {nodeRef}; SfcOvsDataStoreAPI readOvsdbNode = new SfcOvsDataStoreAPI(SfcOvsDataStoreAPI.Method.READ_OVSDB_NODE_BY_REF, methodParams); Node ovsdbNode = (Node) SfcOvsUtil.submitCallable(readOvsdbNode, executor); if (ovsdbNode != null) { return ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class); } else { LOG.warn("Could not find ovsdb-node for connection for {}", ovsdbNode); } } else { LOG.warn("Bridge 'managedBy' non-ovsdb-node. nodeRef {}", nodeRef); } return null; }
try { OvsdbNodeRef ref = mn.getManagedBy(); if (ref != null && ref.getValue() != null) { ReadOnlyTransaction transaction = db.newReadOnlyTransaction(); @SuppressWarnings("unchecked") InstanceIdentifier<Node> path = (InstanceIdentifier<Node>) ref.getValue(); } else { LOG.warn("OvsdbManagedNode {} claims to be managed by {} but " + "that OvsdbNode does not exist", mn, ref.getValue()); return Optional.absent();
private InstanceIdentifier<?> getManagedByIidFromOperDS(InstanceIdentifier<?> bridgeIid) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = bridgeIid.firstIdentifierOf(Node.class); Optional<?> bridgeNode = SouthboundUtil.readNode(db.newReadWriteTransaction(),nodeEntryIid); if (bridgeNode.isPresent() && bridgeNode.get() instanceof Node) { Node node = (Node)bridgeNode.get(); OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null) { return bridge.getManagedBy().getValue(); } } return null; }
private InstanceIdentifier<?> getManagedByIid(Map<InstanceIdentifier<?>, DataObject> map, InstanceIdentifier<?> iidToCheck) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = iidToCheck.firstIdentifierOf(Node.class); // Look for the Node in the created/updated data DataObject dataObject = null; if (map != null && map.get(nodeEntryIid) != null) { dataObject = map.get(nodeEntryIid); } // If we are contained in a bridge managed by this iid if (dataObject != null && dataObject instanceof Node) { Node node = (Node)dataObject; OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null && bridge.getManagedBy().getValue().equals(this.iid)) { return bridge.getManagedBy().getValue(); } } return null; }
private OvsdbNodeAugmentation getOperNode(final OvsdbBridgeAugmentation operBridge) { @SuppressWarnings("unchecked") InstanceIdentifier<Node> iidNode = (InstanceIdentifier<Node>)operBridge.getManagedBy().getValue(); OvsdbNodeAugmentation operNode = null; ReadOnlyTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction(); CheckedFuture<Optional<Node>, ReadFailedException> future = transaction.read(LogicalDatastoreType.OPERATIONAL, iidNode); try { Optional<Node> nodeOptional = future.get(); if (nodeOptional.isPresent()) { operNode = nodeOptional.get().getAugmentation(OvsdbNodeAugmentation.class); } } catch (InterruptedException | ExecutionException e) { LOG.warn("Error reading from datastore", e); } return operNode; }
public NodeId extractBridgeOvsdbNodeId(Node bridgeNode) { NodeId ovsdbNodeId = null; OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); if (bridgeAugmentation != null) { @SuppressWarnings("unchecked") InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) (bridgeAugmentation.getManagedBy().getValue()); ovsdbNodeId = InstanceIdentifier.keyOf(ovsdbNodeIid).getNodeId(); } return ovsdbNodeId; }
public NodeId extractBridgeOvsdbNodeId(Node bridgeNode) { NodeId ovsdbNodeId = null; OvsdbBridgeAugmentation bridgeAugmentation = extractBridgeAugmentation(bridgeNode); if (bridgeAugmentation != null) { @SuppressWarnings("unchecked") InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) (bridgeAugmentation.getManagedBy().getValue()); ovsdbNodeId = InstanceIdentifier.keyOf(ovsdbNodeIid).getNodeId(); } return ovsdbNodeId; }
OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null && bridge.getManagedBy().getValue().equals(ndIid)) { brChanges.putAll(extractBridgeConfigurationChanges(node, bridge)); tpChanges.add(node);
/** * Creates a Bridge Augmentation by using a UNI * @param uni Contains data used to create the augmentation * @return A Built OvsdbBridgeAugmentation with data. * @throws Exception if the Ovsdb Node Reference cannot be found. */ public static OvsdbBridgeAugmentation createOvsdbBridgeAugmentation(Uni uni) throws Exception { final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef(); if ((ovsdbNodeRef != null) && (ovsdbNodeRef.getValue() != null)) { final UUID bridgeUuid = UUID.randomUUID(); final OvsdbBridgeAugmentation ovsdbBridge = new OvsdbBridgeAugmentationBuilder() .setBridgeName( new OvsdbBridgeName(UnimgrConstants.DEFAULT_BRIDGE_NAME)) .setManagedBy(ovsdbNodeRef) .setBridgeUuid( new Uuid(bridgeUuid.toString())) .build(); return ovsdbBridge; } else { throw new Exception("Ovsdb Node Reference does not exist !"); } }
/** * Method builds OVS NodeId which is based on: * 1. OVS Node InstanceIdentifier which manages the OVS Bridge * 2. OVS Bridge name * <p> * If the two aforementioned fields are missing, NullPointerException is raised. * <p> * * @param ovsdbBridge OvsdbBridgeAugmentation * @return NodeId */ private static NodeId getManagedByNodeId(OvsdbBridgeAugmentation ovsdbBridge) { Preconditions.checkNotNull(ovsdbBridge, "Cannot getManagedByNodeId, OvsdbBridgeAugmentation is null."); Preconditions.checkNotNull(ovsdbBridge.getBridgeName(), "Cannot build getManagedByNodeId, BridgeName is null."); Preconditions.checkNotNull(ovsdbBridge.getManagedBy(), "Cannot build getManagedByNodeId, ManagedBy is null."); String bridgeName = (ovsdbBridge.getBridgeName().getValue()); InstanceIdentifier<Node> nodeIID = (InstanceIdentifier<Node>) ovsdbBridge.getManagedBy().getValue(); KeyedInstanceIdentifier keyedInstanceIdentifier = (KeyedInstanceIdentifier) nodeIID.firstIdentifierOf(Node.class); Preconditions.checkNotNull(keyedInstanceIdentifier, "Cannot build getManagedByNodeId, parent OVS Node is null."); NodeKey nodeKey = (NodeKey) keyedInstanceIdentifier.getKey(); String nodeId = nodeKey.getNodeId().getValue(); nodeId = nodeId.concat(OVSDB_BRIDGE_PREFIX + bridgeName); return new NodeId(nodeId); }
uniAugmentation .getOvsdbNodeRef() .getValue() .firstIdentifierOf(Node.class); final Optional<Node> optionalOvsdNode =
@Override public boolean updateUni(final UniAugmentation uni) { // Remove the old UNI with IpAdress and create a new one with updated informations if (uni != null) { LOG.trace("UNI updated {}.", uni.getIpAddress().getIpv4Address()); final InstanceIdentifier<?> uniIID = UnimgrMapper.getUniIid(dataBroker, uni.getIpAddress(), LogicalDatastoreType.OPERATIONAL); Node ovsdbNode; if (uni.getOvsdbNodeRef() != null) { final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef(); ovsdbNode = MdsalUtils.readNode(dataBroker, LogicalDatastoreType.OPERATIONAL, ovsdbNodeRef.getValue()).get(); UniUtils.updateUniNode(LogicalDatastoreType.OPERATIONAL, uniIID, uni, ovsdbNode, dataBroker); LOG.trace("UNI updated {}.", uni.getIpAddress().getIpv4Address()); } else { final Optional<Node> optionalOvsdbNode = OvsdbUtils.findOvsdbNode(dataBroker, uni); ovsdbNode = optionalOvsdbNode.get(); } MdsalUtils.deleteNode(dataBroker, uniIID, LogicalDatastoreType.OPERATIONAL); return (UniUtils.updateUniNode(LogicalDatastoreType.CONFIGURATION, uniIID, uni, ovsdbNode, dataBroker) && UniUtils.updateUniNode(LogicalDatastoreType.OPERATIONAL, uniIID, uni, ovsdbNode, dataBroker)); } return false; } }
NodeKey ovsdbNodeKey = ovsdbNode.getValue().firstKeyOf(Node.class); for (Node node : nodes) { if(node.getKey().equals(ovsdbNodeKey)) {
final OvsdbNodeRef ovsNodedRef = uniAugmentation.getOvsdbNodeRef(); if (ovsNodedRef != null) { final InstanceIdentifier<Node> ovsdbNodeIid = ovsNodedRef.getValue().firstIdentifierOf(Node.class); final Optional<Node> optionalNode = MdsalUtils.readNode(dataBroker, LogicalDatastoreType.OPERATIONAL,
final UniAugmentation uniAugmentation = uniNode.getAugmentation(UniAugmentation.class); if (uniAugmentation.getOvsdbNodeRef() != null && uniAugmentation.getOvsdbNodeRef().getValue() != null) { final InstanceIdentifier<Node> ovsdbNodeRefIid = uniAugmentation .getOvsdbNodeRef() .getValue() .firstIdentifierOf(Node.class); if (ovsdbNodeRefIid.equals(ovsdbIid)) {
String bridgeName) { LOG.info("Creating a bridge on node {}", ovsdbNode.getNodeId().getValue()); final InstanceIdentifier<Node> ovsdbNodeIid = uni.getOvsdbNodeRef().getValue().firstIdentifierOf(Node.class); if (ovsdbNodeIid != null) { final NodeBuilder bridgeNodeBuilder = new NodeBuilder();