Search in sources :

Example 36 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.

the class ItmUtils method getBridgeDpid.

/**
 * Gets the bridge datapath ID from Network topology Node's OvsdbBridgeAugmentation, in the Operational DS.
 *
 * @param node Network Topology Node
 *
 * @param bridge bridge name
 *
 * @param dataBroker data broker handle to perform operations on datastore
 *
 * @return the datapath ID of bridge in string form
 */
public static String getBridgeDpid(Node node, String bridge, DataBroker dataBroker) {
    OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null;
    Node bridgeNode = null;
    String datapathId = null;
    NodeId ovsdbNodeId = node.getKey().getNodeId();
    NodeId brNodeId = new NodeId(ovsdbNodeId.getValue() + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
    InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID)).child(Node.class, new NodeKey(brNodeId));
    Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
    if (opBridgeNode.isPresent()) {
        bridgeNode = opBridgeNode.get();
    }
    if (bridgeNode != null) {
        ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
    }
    if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) {
        datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue();
    }
    return datapathId;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 37 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.

the class SouthboundUtils method addAllPortsToBridge.

/*
     * Add all tunnels ports corresponding to the bridge to the topology config DS.
     */
public void addAllPortsToBridge(BridgeEntry bridgeEntry, InterfaceManagerCommonUtils interfaceManagerCommonUtils, InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid, OvsdbBridgeAugmentation bridgeNew) {
    String bridgeName = bridgeNew.getBridgeName().getValue();
    LOG.debug("adding all ports to bridge: {}", bridgeName);
    List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
    if (bridgeInterfaceEntries != null) {
        for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
            String portName = bridgeInterfaceEntry.getInterfaceName();
            InterfaceKey interfaceKey = new InterfaceKey(portName);
            Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
            if (iface != null) {
                IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
                if (ifTunnel != null) {
                    if (!(interfacemgrProvider.isItmDirectTunnelsEnabled() && ifTunnel.isInternal())) {
                        addTunnelPortToBridge(ifTunnel, bridgeIid, iface, portName);
                    }
                    if (isOfTunnel(ifTunnel)) {
                        LOG.debug("Using OFTunnel. Only one tunnel port will be added");
                        return;
                    }
                }
            } else {
                LOG.debug("Interface {} not found in config DS", portName);
            }
        }
    }
}
Also used : IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) BridgeInterfaceEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 38 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.

the class HwVTEPConfigRemoveHelper method removeConfiguration.

public static List<ListenableFuture<Void>> removeConfiguration(ManagedNewTransactionRunner txRunner, Interface interfaceOld, InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId) {
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    LOG.info("removing hwvtep configuration for {}", interfaceOld.getName());
    if (globalNodeId != null) {
        IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
        // removeTunnelTableEntry(defaultOperShardTransaction, ifTunnel, physicalSwitchNodeId);
        // Topology configuration shard
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> removeTerminationEndPoint(tx, ifTunnel, globalNodeId)));
        // Default operational shard
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), tx);
            InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, tx, ifTunnel);
        }));
    }
    return futures;
}
Also used : Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) SouthboundUtils(org.opendaylight.genius.interfacemanager.renderer.hwvtep.utilities.SouthboundUtils) InterfaceMetaUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)

Example 39 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project controller by opendaylight.

the class EventSourceTopologyTest method topicTestHelper.

private void topicTestHelper() throws Exception {
    constructorTestHelper();
    createTopicInputMock = mock(CreateTopicInput.class);
    eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
    NotificationPattern notificationPattern = new NotificationPattern("value1");
    doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
    Pattern pattern = new Pattern("valuePattern1");
    doReturn(pattern).when(createTopicInputMock).getNodeIdPattern();
    listenerRegistrationMock = mock(ListenerRegistration.class);
    doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(EventSourceTopic.class));
    ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
    doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
    CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
    doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
    Optional optionalMock = mock(Optional.class);
    doReturn(optionalMock).when(checkedFutureMock).checkedGet();
    doReturn(true).when(optionalMock).isPresent();
    Topology topologyMock = mock(Topology.class);
    doReturn(topologyMock).when(optionalMock).get();
    Node nodeMock = mock(Node.class);
    List<Node> nodeList = new ArrayList<>();
    nodeList.add(nodeMock);
    doReturn(nodeList).when(topologyMock).getNode();
    NodeId nodeId = new NodeId("nodeIdValue1");
    doReturn(nodeId).when(nodeMock).getNodeId();
}
Also used : Pattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern) NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) Optional(com.google.common.base.Optional) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) NotificationPattern(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) CreateTopicInput(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) CheckedFuture(com.google.common.util.concurrent.CheckedFuture)

Example 40 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.

the class Ipv4ReachabilityTopologyBuilderTest method testIpv4ReachabilityTopologyBuilder.

@Test
public void testIpv4ReachabilityTopologyBuilder() throws TransactionCommitFailedException, ReadFailedException {
    // create route
    updateIpv4Route(createIpv4Route(NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        final TopologyTypes1 topologyTypes = topology.getTopologyTypes().getAugmentation(TopologyTypes1.class);
        assertNotNull(topologyTypes);
        assertNotNull(topologyTypes.getBgpIpv4ReachabilityTopology());
        assertEquals(1, topology.getNode().size());
        final Node node = topology.getNode().get(0);
        assertEquals(NEXT_HOP, node.getNodeId().getValue());
        assertEquals(ROUTE_IP4PREFIX, node.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
        return topology;
    });
    // update route
    updateIpv4Route(createIpv4Route(NEW_NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.getNode().size());
        final Node nodeUpdated = topology.getNode().get(0);
        assertEquals(NEW_NEXT_HOP, nodeUpdated.getNodeId().getValue());
        assertEquals(ROUTE_IP4PREFIX, nodeUpdated.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
        return topology;
    });
    // delete route
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.ipv4RouteIID);
    wTx.submit();
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(0, topology.getNode().size());
        return topology;
    });
    this.ipv4TopoBuilder.close();
    checkNotPresentOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier());
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TopologyTypes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1) Test(org.junit.Test)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)30 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)26 Test (org.junit.Test)20 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)15 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)12 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)10 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)10 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)10 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)9 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)8 Optional (com.google.common.base.Optional)7 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)7 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)7 ExecutionException (java.util.concurrent.ExecutionException)6 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)5 ArrayList (java.util.ArrayList)4