org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology Java Examples

The following examples show how to use org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OvsdbControllerUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the {@link InstanceIdentifier} for the {@link ControllerEntry}.
 *
 * @param controllerEntry the {@link ControllerEntry}
 * @param bridgeName the name of the bridge
 * @return the {@link InstanceIdentifier}
 */
@VisibleForTesting
InstanceIdentifier<ControllerEntry> getControllerEntryIid(
        final ControllerEntry controllerEntry, final String bridgeName) {

    OvsdbConnectionInstance client = getOvsdbConnectionInstance();
    String nodeString = client.getNodeKey().getNodeId().getValue()
            + "/bridge/" + bridgeName;
    NodeId nodeId = new NodeId(new Uri(nodeString));
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class,nodeKey)
            .build();

    return bridgeIid
            .augmentation(OvsdbBridgeAugmentation.class)
            .child(ControllerEntry.class, controllerEntry.key());
}
 
Example #2
Source File: HwvtepSouthboundIT.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private Boolean getHwvtepTopology() {
    LOG.info("getHwvtepTopology: looking for {}...", HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
    Boolean found = false;
    final TopologyId topologyId = HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID;
    InstanceIdentifier<Topology> path =
            InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
    for (int i = 0; i < 60; i++) {
        Boolean topology = mdsalUtils.exists(LogicalDatastoreType.OPERATIONAL, path);
        if (topology) {
            LOG.info("getHwvtepTopology: found {}...", HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
            found = true;
            break;
        } else {
            LOG.info("getHwvtepTopology: still looking ({})...", i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                LOG.warn("Interrupted while waiting for {}",
                        HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue(), e);
            }
        }
    }
    return found;
}
 
Example #3
Source File: NetworkTopologyConfigFileProcessorTest.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void configFileTest() throws InterruptedException, ExecutionException {
    final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIIdKeyed =
            InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
                    new TopologyKey(new TopologyId("topology-test")));
    checkNotPresentConfiguration(getDataBroker(), topologyIIdKeyed);

    assertNotNull(ClassLoader.getSystemClassLoader().getResource("initial/network-topology-config.xml"));
    final NetworkTopologyConfigFileProcessor processor = new NetworkTopologyConfigFileProcessor(this.configLoader,
            getDataBroker());
    processor.init();
    checkPresentConfiguration(getDataBroker(), topologyIIdKeyed);

    assertEquals(SchemaPath.create(true, NetworkTopology.QNAME), processor.getSchemaPath());
    processor.close();
}
 
Example #4
Source File: AutoAttachUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private static OvsdbBridgeAugmentation getBridge(final InstanceIdentifier<OvsdbNodeAugmentation> key,
        final Uri bridgeUri) {
    final InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class, new NodeKey(new NodeId(bridgeUri)))
            .augmentation(OvsdbBridgeAugmentation.class);

    OvsdbBridgeAugmentation bridge = null;
    try (ReadTransaction transaction = SouthboundProvider.getDb().newReadOnlyTransaction()) {
        final Optional<OvsdbBridgeAugmentation> bridgeOptional =
                transaction.read(LogicalDatastoreType.OPERATIONAL, bridgeIid).get();
        if (bridgeOptional.isPresent()) {
            bridge = bridgeOptional.get();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Error reading from datastore", e);
    }
    return bridge;
}
 
Example #5
Source File: SouthboundProvider.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private void initializeOvsdbTopology(final LogicalDatastoreType type) {
    InstanceIdentifier<Topology> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
    ReadWriteTransaction transaction = db.newReadWriteTransaction();
    FluentFuture<Boolean> ovsdbTp = transaction.exists(type, path);
    try {
        if (!ovsdbTp.get().booleanValue()) {
            TopologyBuilder tpb = new TopologyBuilder();
            tpb.setTopologyId(SouthboundConstants.OVSDB_TOPOLOGY_ID);
            transaction.mergeParentStructurePut(type, path, tpb.build());
            transaction.commit();
        } else {
            transaction.cancel();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error initializing ovsdb topology", e);
    }
}
 
Example #6
Source File: OvsdbManagersUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the {@link InstanceIdentifier} for the {@link ManagerEntry}.
 *
 * @param managerEntry the {@link ManagerEntry}
 * @return the {@link InstanceIdentifier}
 */
private InstanceIdentifier<ManagerEntry> getManagerEntryIid(ManagerEntry managerEntry) {

    OvsdbConnectionInstance client = getOvsdbConnectionInstance();
    String nodeString = client.getNodeKey().getNodeId().getValue();
    NodeId nodeId = new NodeId(new Uri(nodeString));
    NodeKey nodeKey = new NodeKey(nodeId);
    InstanceIdentifier<Node> ovsdbNodeIid = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class,nodeKey)
            .build();

    return ovsdbNodeIid
            .augmentation(OvsdbNodeAugmentation.class)
            .child(ManagerEntry.class, managerEntry.key());
}
 
Example #7
Source File: TunnelProviderDeployer.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
private synchronized void createTunnelTopologyProvider(final Topology topology) {
    if (!filterPcepTopologies(topology.getTopologyTypes())) {
        return;
    }
    final TopologyId topologyId = topology.getTopologyId();
    if (this.pcepTunnelServices.containsKey(topology.getTopologyId())) {
        LOG.warn("Tunnel Topology {} already exist. New instance won't be created", topologyId);
        return;
    }
    LOG.debug("Create Tunnel Topology {}", topologyId);

    final PcepTunnelTopologyConfig config = topology.augmentation(PcepTunnelTopologyConfig.class);
    final String pcepTopoID = StringUtils
            .substringBetween(config.getPcepTopologyReference().getValue(), "=\"", "\"");
    final InstanceIdentifier<Topology> pcepTopoRef = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId(pcepTopoID))).build();


    final PCEPTunnelClusterSingletonService tunnelTopoCss =
            new PCEPTunnelClusterSingletonService(this.dependencies, pcepTopoRef, topologyId);
    this.pcepTunnelServices.put(topology.getTopologyId(), tunnelTopoCss);
}
 
Example #8
Source File: SouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
public static InstanceIdentifier<Node> getInstanceIdentifier(final InstanceIdentifierCodec instanceIdentifierCodec,
        final OpenVSwitch ovs) {
    if (ovs.getExternalIdsColumn() != null
            && ovs.getExternalIdsColumn().getData() != null
            && ovs.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) {
        String iidString = ovs.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY);
        return (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializerOrNull(iidString);
    } else {
        String nodeString = SouthboundConstants.OVSDB_URI_PREFIX + "://" + SouthboundConstants.UUID + "/"
                + ovs.getUuid().toString();
        NodeId nodeId = new NodeId(new Uri(nodeString));
        NodeKey nodeKey = new NodeKey(nodeId);
        return InstanceIdentifier.builder(NetworkTopology.class)
                .child(Topology.class,new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
                .child(Node.class,nodeKey)
                .build();
    }
}
 
Example #9
Source File: HwvtepSouthboundProvider.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private void initializeHwvtepTopology(final LogicalDatastoreType type) {
    InstanceIdentifier<Topology> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
    ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
    FluentFuture<Boolean> hwvtepTp = transaction.exists(type, path);
    try {
        if (!hwvtepTp.get().booleanValue()) {
            TopologyBuilder tpb = new TopologyBuilder();
            tpb.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
            transaction.mergeParentStructurePut(type, path, tpb.build());
            transaction.commit();
        } else {
            transaction.cancel();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error initializing hwvtep topology", e);
    }
}
 
Example #10
Source File: SouthboundIT.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private Boolean getOvsdbTopology() {
    LOG.info("getOvsdbTopology: looking for {}...", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue());
    Boolean found = false;
    final TopologyId topologyId = SouthboundUtils.OVSDB_TOPOLOGY_ID;
    InstanceIdentifier<Topology> path =
            InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
    for (int i = 0; i < 60; i++) {
        Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
        if (topology != null) {
            LOG.info("getOvsdbTopology: found {}...", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue());
            found = true;
            break;
        } else {
            LOG.info("getOvsdbTopology: still looking ({})...", i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                LOG.warn("Interrupted while waiting for {}", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue(), e);
            }
        }
    }
    return found;
}
 
Example #11
Source File: TopologyStatsRpcServiceImplTest.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    rpcService = new TopologyStatsRpcServiceImpl(getDataBroker());
    rpcService.init();

    // PCEP topology with one PCC node
    final Topology t1 = createTopology(TOPOLOGY_ID1, Collections.singletonList(createPcepNode(NODE_ID1)));

    // PCEP topology with two PCC node
    final Topology t2 =
            createTopology(TOPOLOGY_ID2, Arrays.asList(createPcepNode(NODE_ID2), createPcepNode(NODE_ID3)));

    // Non-PCEP topology with one non-PCC node
    final Topology t3 = createTopology(NONPCEP_TOPOLOGY,
            Collections.singletonList(new NodeBuilder().setNodeId(new NodeId(NONPCEP_NODE)).build()));

    final WriteTransaction wtx = getDataBroker().newWriteOnlyTransaction();
    final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder();
    ntb.setTopology(Arrays.asList(t1, t2, t3));
    wtx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(NetworkTopology.class).build(),
            ntb.build());
    wtx.commit().get();
}
 
Example #12
Source File: SouthboundIT.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testGetOvsdbNodes() throws InterruptedException {
    ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
    InstanceIdentifier<Topology> topologyPath = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));

    Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, topologyPath);
    InstanceIdentifier<Node> expectedNodeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
    NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class).getNodeId();
    Node foundNode = null;
    Assert.assertNotNull("Expected to find topology: " + topologyPath, topology);
    Assert.assertNotNull("Expected to find some nodes" + topology.getNode());
    LOG.info("expectedNodeId: {}, getNode: {}", expectedNodeId, topology.getNode());
    for (Node node : topology.nonnullNode().values()) {
        if (node.getNodeId().getValue().equals(expectedNodeId.getValue())) {
            foundNode = node;
            break;
        }
    }
    Assert.assertNotNull("Expected to find Node: " + expectedNodeId, foundNode);
}
 
Example #13
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> createInstanceIdentifier(HwvtepConnectionInstance client,
                HwvtepNodeName psName) {
    NodeKey nodeKey = new NodeKey(createManagedNodeId(client, psName));
    return InstanceIdentifier.builder(NetworkTopology.class)
                    .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
                    .child(Node.class, nodeKey).build();
}
 
Example #14
Source File: TransactionInvokerImplTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private InstanceIdentifier<Node> createInstanceIdentifier(final String nodeIdString) {
    NodeId nodeId = new NodeId(new Uri(nodeIdString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #15
Source File: DataChangeListenerTestBase.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public InstanceIdentifier<Node> createInstanceIdentifier(final String nodeIdString) {
    NodeId nodeId = new NodeId(new Uri(nodeIdString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #16
Source File: HwvtepOperationalDataChangeListener.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private InstanceIdentifier<Node> getWildcardPath() {
    InstanceIdentifier<Node> path = InstanceIdentifier
                    .create(NetworkTopology.class)
                    .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
                    .child(Node.class);
    return path;
}
 
Example #17
Source File: HwvtepCacheDisplayCmd.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private InstanceIdentifier<Node> getIid() {
    NodeId nodeId = new NodeId(new Uri(nodeid));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #18
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<LogicalSwitches> createInstanceIdentifier(HwvtepConnectionInstance client,
        LogicalSwitch logicalSwitch) {
    InstanceIdentifier<LogicalSwitches> iid = null;
    iid = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
            .child(Node.class, client.getNodeKey()).augmentation(HwvtepGlobalAugmentation.class)
            .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(logicalSwitch.getName())))
            .build();
    /* TODO: Will this work instead to make it simpler?
    iid = client.getInstanceIdentifier().builder()
        .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(lSwitch.getName())))).build()
     */
    return iid;
}
 
Example #19
Source File: OpenVSwitchUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
void removeOldConfigs(ReadWriteTransaction transaction, Map<String, String> oldOtherConfigs, OpenVSwitch ovs) {
    InstanceIdentifier<OvsdbNodeAugmentation> nodeAugmentataionIid = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class, new NodeKey(getNodeId(ovs)))
            .augmentation(OvsdbNodeAugmentation.class);
    Set<String> otherConfigKeys = oldOtherConfigs.keySet();
    for (String otherConfigKey : otherConfigKeys) {
        KeyedInstanceIdentifier<OpenvswitchOtherConfigs, OpenvswitchOtherConfigsKey> externalIid =
                nodeAugmentataionIid
                .child(OpenvswitchOtherConfigs.class, new OpenvswitchOtherConfigsKey(otherConfigKey));
        transaction.delete(LogicalDatastoreType.OPERATIONAL, externalIid);
    }
}
 
Example #20
Source File: SouthboundIT.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testOvsdbTopology() throws InterruptedException {
    InstanceIdentifier<Topology> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));

    Topology topology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
    Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.CONFIGURATION,
            topology);

    topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);

    Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.OPERATIONAL,
            topology);
}
 
Example #21
Source File: HwvtepDataChangeListener.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private InstanceIdentifier<Node> getWildcardPath() {
    InstanceIdentifier<Node> path = InstanceIdentifier
                    .create(NetworkTopology.class)
                    .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
                    .child(Node.class);
    return path;
}
 
Example #22
Source File: HwvtepSouthboundIT.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testNetworkTopology() throws InterruptedException {
    NetworkTopology networkTopology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION,
            InstanceIdentifier.create(NetworkTopology.class));
    Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.CONFIGURATION,
            networkTopology);

    networkTopology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
            InstanceIdentifier.create(NetworkTopology.class));
    Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.OPERATIONAL,
            networkTopology);
}
 
Example #23
Source File: HwvtepSouthboundIT.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testHwvtepTopology() throws InterruptedException {
    InstanceIdentifier<Topology> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));

    Topology topology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
    Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.CONFIGURATION,
            topology);

    topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);

    Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.OPERATIONAL,
            topology);
}
 
Example #24
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> getInstanceIdentifier(Global global) {
    String nodeString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://"
            + HwvtepSouthboundConstants.UUID + "/" + global.getUuid().toString();
    NodeId nodeId = new NodeId(new Uri(nodeString));
    NodeKey nodeKey = new NodeKey(nodeId);
    TopologyKey topoKey = new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
    return InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, topoKey)
            .child(Node.class, nodeKey)
            .build();
}
 
Example #25
Source File: HwvtepSouthboundProvider.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private void init2() {
    LOG.info("HwvtepSouthboundProvider Session Initiated");
    txInvoker = new TransactionInvokerImpl(dataBroker);
    cm = new HwvtepConnectionManager(dataBroker, txInvoker, entityOwnershipService, ovsdbConnection);
    registerConfigListenerPostUpgrade();
    //Register listener for entityOnwership changes
    providerOwnershipChangeListener =
            new HwvtepsbPluginInstanceEntityOwnershipListener(this,this.entityOwnershipService);

    //register instance entity to get the ownership of the provider
    Entity instanceEntity = new Entity(ENTITY_TYPE, ENTITY_TYPE);
    try {
        registration = entityOwnershipService.registerCandidate(instanceEntity);
    } catch (CandidateAlreadyRegisteredException e) {
        LOG.warn("HWVTEP Southbound Provider instance entity {} was already "
                + "registered for ownership", instanceEntity, e);
    }
    InstanceIdentifier<Topology> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
    DataTreeIdentifier<Topology> treeId =
            DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, path);

    LOG.trace("Registering listener for path {}", treeId);
    operTopologyRegistration = dataBroker.registerDataTreeChangeListener(treeId, this);
    Scheduler.getScheduledExecutorService().schedule(() -> {
        if (!registered.get()) {
            openOvsdbPort();
            LOG.error("Timed out to get eos notification opening the port now");
        }
    }, HwvtepSouthboundConstants.PORT_OPEN_MAX_DELAY_IN_MINS, TimeUnit.MINUTES);
}
 
Example #26
Source File: HwvtepSouthboundMapper.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
private static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
    String uriString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://"
            + ip.stringValue() + ":" + port.getValue();
    Uri uri = new Uri(uriString);
    NodeId nodeId = new NodeId(uri);
    InstanceIdentifier<Node> path = InstanceIdentifier.create(NetworkTopology.class)
                    .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
                    .child(Node.class,new NodeKey(nodeId));
    LOG.debug("Created ovsdb path: {}",path);
    return path;
}
 
Example #27
Source File: SouthboundIT.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testNetworkTopology() throws InterruptedException {
    NetworkTopology networkTopology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION,
            InstanceIdentifier.create(NetworkTopology.class));
    Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.CONFIGURATION,
            networkTopology);

    networkTopology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
            InstanceIdentifier.create(NetworkTopology.class));
    Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.OPERATIONAL,
            networkTopology);
}
 
Example #28
Source File: BridgeOperationalStateTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    iidNode = InstanceIdentifier.create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId("foo")))
            .child(Node.class, new NodeKey(nd.getNodeId()));
    protocolEntry = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class).child(Node.class)
            .augmentation(OvsdbBridgeAugmentation.class).child(ProtocolEntry.class);

    briOperationState = mock(BridgeOperationalState.class, Mockito.CALLS_REAL_METHODS);

    getField(BridgeOperationalState.class,"db").set(briOperationState, db);
    doReturn(mockReadTx).when(db).newReadOnlyTransaction();
    OvsdbOperGlobalListener.OPER_NODE_CACHE.put(nodeIid, brNode);
}
 
Example #29
Source File: OvsdbDataTreeChangeListener.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create an instance and register the listener.
 *
 * @param db The data broker.
 * @param cm The connection manager.
 */
OvsdbDataTreeChangeListener(DataBroker db, OvsdbConnectionManager cm,
        InstanceIdentifierCodec instanceIdentifierCodec) {
    this.cm = cm;
    this.db = db;
    this.instanceIdentifierCodec = instanceIdentifierCodec;
    InstanceIdentifier<Node> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class);
    DataTreeIdentifier<Node> dataTreeIdentifier =
            DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, path);
    registration = db.registerDataTreeChangeListener(dataTreeIdentifier, this);
    LOG.info("OVSDB topology listener has been registered.");
}
 
Example #30
Source File: OpenVSwitchUpdateCommand.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@VisibleForTesting
void removeExternalIds(ReadWriteTransaction transaction, Map<String, String> oldExternalIds, OpenVSwitch ovs) {
    InstanceIdentifier<OvsdbNodeAugmentation> nodeAugmentataionIid = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
            .child(Node.class, new NodeKey(getNodeId(ovs)))
            .augmentation(OvsdbNodeAugmentation.class);
    Set<String> externalIdKeys = oldExternalIds.keySet();
    for (String externalIdKey : externalIdKeys) {
        KeyedInstanceIdentifier<OpenvswitchExternalIds, OpenvswitchExternalIdsKey> externalIid =
                nodeAugmentataionIid
                .child(OpenvswitchExternalIds.class, new OpenvswitchExternalIdsKey(externalIdKey));
        transaction.delete(LogicalDatastoreType.OPERATIONAL, externalIid);
    }
}