/** * Wrapper method to executes read as a blocking transaction. * Read is open for all instances to execute their normal * control flow. Because with current implementation all the * net-virt instances execute in similar way, because they want * to build their local caches so that all the instances has same * state of internal cache. * * @param store {@link LogicalDatastoreType} to read * @param path {@link InstanceIdentifier} for path to read * @param <D> the data object type * @return the result as the data object requested */ public <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read( final LogicalDatastoreType store, final InstanceIdentifier<D> path) { return mdsalUtils.read(store,path); } }
public Node getOvsdbNode(final ConnectionInfo connectionInfo) { return mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, createInstanceIdentifier(connectionInfo)); }
/** * Extract the node contents from <code>store</code> type data store for the * bridge identified by <code>bridgeName</code>. * * @param connectionInfo address for the node * @param bridgeName name of the bridge * @param store defined by the <code>LogicalDatastoreType</code> enumeration * @return <code>store</code> type data store contents */ public Node getBridgeNode(ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store) { InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName)); return mdsalUtils.read(store, bridgeIid); }
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; }
@SuppressWarnings("unchecked") private Node getPortsNode(BigInteger dpnId) throws Exception{ InstanceIdentifier<BridgeRefEntry> bridgeRefInfoPath = InstanceIdentifier. create(BridgeRefInfo.class).child(BridgeRefEntry.class, new BridgeRefEntryKey(dpnId)); BridgeRefEntry bridgeRefEntry = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeRefInfoPath); if (bridgeRefEntry == null) { throw new Exception("no bridge ref entry found for dpnId: " + dpnId); } InstanceIdentifier<Node> nodeId = ((InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry .getBridgeReference().getValue()).firstIdentifierOf(Node.class); Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodeId); if (node == null) { throw new Exception("missing node for dpnId: " + dpnId); } return node; } }
public OvsdbBridgeAugmentation getBridgeFromConfig(Node node, String bridge) { OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null; InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(node.getKey(), bridge); Node bridgeNode = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, bridgeIid); if (bridgeNode != null) { ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class); } return ovsdbBridgeAugmentation; }
private void addTransportZone(TransportZone zone, String interName) { InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build(); TransportZones zones = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); if (zones == null) { List<TransportZone> zoneList = new ArrayList<>(); zoneList.add(zone); zones = new TransportZonesBuilder().setTransportZone(zoneList).build(); } else { zones.getTransportZone().add(zone); } MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, zones); LOG.info("updating transport zone {} due to {} handling", zone.getZoneName(), interName); }
/** * Get all OVSDB nodes from topology. * @return a list of nodes or null if the topology could not found */ public List<Node> getOvsdbNodes() { InstanceIdentifier<Topology> inst = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID)); Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, inst); return topology != null ? topology.getNode() : null; }
/** * read the list of <code>OvsdbTerminationPointAugmentation</code> for the particular <code>node</code>. * * @param node * @return */ public List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentations(Node node) { if (node == null) { LOG.error("readTerminationPointAugmentations: Node value is null"); return Collections.<OvsdbTerminationPointAugmentation>emptyList(); } Node operNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID)) .child(Node.class, new NodeKey(node.getNodeId()))); if (operNode != null) { return extractTerminationPointAugmentations(operNode); } return new ArrayList<>(); }
private boolean checkIfVxlanNetwork(Port port) { InstanceIdentifier<Network> networkPath = InstanceIdentifier.create(Neutron.class) .child(Networks.class).child(Network.class, new NetworkKey(port.getNetworkId())); Network network = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, networkPath); if (network == null || !NeutronvpnUtils.isNetworkOfType(network, NetworkTypeVxlan.class)) { LOG.debug("port in non-VXLAN network " + port.getName()); return false; } return true; }
Interfaces interfaces = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, interPath); if (interfaces == null) { LOG.error("No interfaces in configuration"); InstanceIdentifier<Port> pathPort = InstanceIdentifier.create(Neutron.class).child(Ports.class) .child(Port.class, new PortKey(portUid)); Port port = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, pathPort);
/** * Check that the netvirt topology is in the operational mdsal. * @return true if the netvirt topology was successfully retrieved */ public Boolean getNetvirtTopology() { LOG.info("getNetvirtTopology: looking for {}...", ItConstants.NETVIRT_TOPOLOGY_ID); final TopologyId topologyId = new TopologyId(new Uri(ItConstants.NETVIRT_TOPOLOGY_ID)); InstanceIdentifier<Topology> path = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId)); NotifyingDataChangeListener waitForIt = new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, null); waitForIt.registerDataChangeListener(dataBroker); try { waitForIt.waitForCreation(60 * 1000); } catch (InterruptedException e) { LOG.info("getNetvirtTopology: InterruptedException while wait(ing)ForCreation"); } boolean found = null != mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path); LOG.info("getNetvirtTopology: found {} == {}", ItConstants.NETVIRT_TOPOLOGY_ID, found); return found; }
public Node readBridgeNode(Node node, String name) { Node ovsdbNode = node; if (extractNodeAugmentation(ovsdbNode) == null) { ovsdbNode = readOvsdbNode(node); if (ovsdbNode == null) { return null; } } Node bridgeNode = null; ConnectionInfo connectionInfo = getConnectionInfo(ovsdbNode); if (connectionInfo != null) { InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(node.getKey(), name); bridgeNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid); } return bridgeNode; }
/** * Remove integration bridge and teardown connection. Contains assertions for unexpected states. * @throws InterruptedException if interrupted while waiting for disconnect to complete */ public void disconnect() throws Exception { ovsdbWaiter.setMask(NotifyingDataChangeListener.BIT_DELETE); bridgeWaiter.setMask(NotifyingDataChangeListener.BIT_DELETE); assertTrue(itUtils.southboundUtils.deleteBridge(connectionInfo, INTEGRATION_BRIDGE_NAME, 0)); bridgeWaiter.waitForDeletion(); Node bridgeNode = itUtils.mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid); assertNull("Bridge should not be found", bridgeNode); assertTrue(itUtils.southboundUtils.disconnectOvsdbNode(connectionInfo, 0)); ovsdbWaiter.waitForDeletion(); Node ovsdbNode = itUtils.mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbIid); assertNull("Ovsdb node should not be found", ovsdbNode); closeWaiters(); }
public void updateTrasportZone(RouterDpnList routerDpnList) { try{ InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class). child(TransportZone.class, new TransportZoneKey(routerDpnList.getRouterId())); TransportZone zone = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, inst); String subnetIp = ALL_SUBNETS; if (zone == null) { zone = createZone(subnetIp, routerDpnList.getRouterId()); } int addedTeps = 0; for (DpnVpninterfacesList dpnVpninterfacesList : routerDpnList.getDpnVpninterfacesList()) { BigInteger dpnId = dpnVpninterfacesList.getDpnId(); addedTeps += addVtep(zone, subnetIp, dpnId); } if (addedTeps > 0) { addTransportZone(zone, "router " + routerDpnList.getRouterId()); } } catch (Exception e) { LOG.warn("failed to add tunnels on router added of routerDpnList {} due to {}", routerDpnList, e.getMessage()); } }
Node bridgeNode = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, bridgeNodeIid); if (bridgeNode == null) { LOG.info("setBridgeController could not find bridge in configuration {}", bridgeNodeIid);
/** * Update/add TransportZone for interface State inter.<br> * If Transport zone for given Network doesn't exist, then it will be added.<br> * If the TEP of the port's node exists in the TZ, it will not be added. * @param inter - the interface to update */ public void updateTrasportZone(Interface inter) { List<Port> ports = getPortsFromInterface(inter); //supports VPN aware VMs (multiple ports for one interface) for (Port port : ports) { try { if (!checkIfVxlanNetwork(port)) { continue; } String subnetIp = getSubnetIPFromPort(port); BigInteger dpnId = getDpnIdFromInterfaceState(inter); InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class) .child(TransportZone.class, new TransportZoneKey(port.getNetworkId().getValue())); TransportZone zone = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, inst); if (zone == null) { zone = createZone(subnetIp, port.getNetworkId().getValue()); } if (addVtep(zone, subnetIp, dpnId) > 0) { addTransportZone(zone, inter.getName()); } } catch (Exception e) { LOG.warn("failed to add tunnels on interface added to subnet {} due to {}", inter, e.getMessage()); } } }