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

The following examples show how to use org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology. 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: 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 #2
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 #3
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 #4
Source File: PCEPTopologyProviderUtil.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
static KeyMapping contructKeys(final @NonNull Topology topology) {
    final KeyMapping ret = KeyMapping.getKeyMapping();
    if (topology.getNode() == null) {
        return ret;
    }
    topology.nonnullNode().values().stream()
            .filter(Objects::nonNull)
            .filter(node -> node.augmentation(PcepNodeConfig.class) != null)
            .filter(node -> node.augmentation(PcepNodeConfig.class).getSessionConfig() != null)
            .filter(node -> node.augmentation(PcepNodeConfig.class)
                    .getSessionConfig().getPassword() != null)
            .filter(node -> !node.augmentation(PcepNodeConfig.class)
                    .getSessionConfig().getPassword().getValue().isEmpty())
            .forEach(node -> {
                final PcepNodeConfig config = node.augmentation(PcepNodeConfig.class);
                final Rfc2385Key rfc2385KeyPassword = config.getSessionConfig().getPassword();
                final InetAddress address = InetAddresses.forString(node.getNodeId().getValue());
                ret.put(address, rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
            });

    return ret;
}
 
Example #5
Source File: PCEPTopologyProviderUtil.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
static SpeakerIdMapping contructSpeakersId(final Topology topology) {
    final SpeakerIdMapping ret = SpeakerIdMapping.getSpeakerIdMap();
    if (topology.getNode() == null) {
        return ret;
    }
    topology.nonnullNode().values().stream()
            .filter(Objects::nonNull)
            .filter(node -> node.augmentation(PcepNodeConfig.class) != null)
            .filter(node -> node.augmentation(PcepNodeConfig.class).getSessionConfig() != null)
            .filter(node -> node.augmentation(PcepNodeConfig.class).getSessionConfig()
                    .augmentation(PcepNodeSyncConfig.class) != null)
            .forEach(node -> {
                final PcepNodeConfig config = node.augmentation(PcepNodeConfig.class);
                final PcepNodeSyncConfig nodeSyncConfig = config.getSessionConfig()
                        .augmentation(PcepNodeSyncConfig.class);
                final InetAddress address = InetAddresses.forString(node.getNodeId().getValue());
                ret.put(address, nodeSyncConfig.getSpeakerEntityIdValue());
            });

    return ret;
}
 
Example #6
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 #7
Source File: DestroyTunnelInstructionExecutor.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
    final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.pcepDestroyTunnelInput);
    final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.pcepDestroyTunnelInput);
    try (ReadTransaction t = this.dataProvider.newReadOnlyTransaction()) {
        final Node node;
        final Link link;
        try {
            // The link has to exist
            link = t.read(LogicalDatastoreType.OPERATIONAL, lii).get().get();
            // The source node has to exist
            node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
        } catch (final InterruptedException | ExecutionException e) {
            LOG.debug("Link or node does not exist.", e);
            return TunelProgrammingUtil.RESULT;
        }
        final RemoveLspInputBuilder ab = new RemoveLspInputBuilder();
        ab.setName(link.augmentation(Link1.class).getSymbolicPathName());
        ab.setNode(node.nonnullSupportingNode().values().iterator().next().key().getNodeRef());
        return Futures.transform(
                this.topologyService.removeLsp(ab.build()),
                RpcResult::getResult, MoreExecutors.directExecutor());
    }
}
 
Example #8
Source File: CreateTunnelInstructionExecutor.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
private AddLspInput createAddLspInput(final ReadTransaction transaction) {
    final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.p2pTunnelInput);
    final TpReader dr = new TpReader(transaction, tii, this.p2pTunnelInput.getDestination());
    final TerminationPoint dp = requireNonNull(dr.getTp());

    final TpReader sr = new TpReader(transaction, tii, this.p2pTunnelInput.getSource());
    final TerminationPoint sp = requireNonNull(sr.getTp());

    final Node sn = requireNonNull(sr.getNode());
    final AddLspInputBuilder ab = new AddLspInputBuilder();
    ab.setNode(requireNonNull(TunelProgrammingUtil.supportingNode(sn)));
    ab.setName(this.p2pTunnelInput.getSymbolicPathName());

    checkLinkIsnotExistent(tii, ab, transaction);

    ab.setArguments(buildArguments(sp, dp));
    return ab.build();
}
 
Example #9
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 #10
Source File: PCEPTopologyDeployerImpl.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
private synchronized void createTopologyProvider(final Topology topology) {
    if (!filterPcepTopologies(topology.getTopologyTypes())) {
        return;
    }
    final TopologyId topologyId = topology.getTopologyId();
    if (this.pcepTopologyServices.containsKey(topology.getTopologyId())) {
        LOG.warn("Topology Provider {} already exist. New instance won't be created", topologyId);
        return;
    }
    LOG.info("Creating Topology {}", topologyId);
    LOG.trace("Topology {}.", topology);

    final SessionConfig config = topology.augmentation(PcepTopologyTypeConfig.class).getSessionConfig();
    final InstructionScheduler instructionScheduler = this.instructionSchedulerFactory
            .createInstructionScheduler(topologyId.getValue());

    final PCEPTopologyConfiguration dependencies = new PCEPTopologyConfiguration(config, topology);

    final PCEPTopologyProviderBean pcepTopologyProviderBean = (PCEPTopologyProviderBean) this.container
            .getComponentInstance(PCEPTopologyProviderBean.class.getSimpleName());
    this.pcepTopologyServices.put(topologyId, pcepTopologyProviderBean);
    pcepTopologyProviderBean.start(dependencies, instructionScheduler);
}
 
Example #11
Source File: UpdateTunnelInstructionExecutor.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
    final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.updateTunnelInput);
    final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.updateTunnelInput);
    try (ReadTransaction t = this.dataProvider.newReadOnlyTransaction()) {
        final Link link;
        final Node node;
        try {
            // The link has to exist
            link = t.read(LogicalDatastoreType.OPERATIONAL, lii).get().get();
            // The source node has to exist
            node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
        } catch (final InterruptedException | ExecutionException e) {
            LOG.debug("Link or node does not exist.", e);
            return TunelProgrammingUtil.RESULT;
        }
        return Futures.transform(
                this.topologyService
                        .updateLsp(buildUpdateInput(link, node)),
                RpcResult::getResult, MoreExecutors.directExecutor());
    }
}
 
Example #12
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 #13
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 #14
Source File: NetworkTopologyConfigFileProcessor.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public synchronized void loadConfiguration(final NormalizedNode<?, ?> dto) {
    final ContainerNode networkTopologyContainer = (ContainerNode) dto;
    final MapNode topologyList = (MapNode) networkTopologyContainer.getChild(
            this.topologyYii.getLastPathArgument()).get();
    final Collection<MapEntryNode> networkTopology = topologyList.getValue();
    if (networkTopology.isEmpty()) {
        return;
    }
    final WriteTransaction wtx = this.dataBroker.newWriteOnlyTransaction();

    for (final MapEntryNode topologyEntry : networkTopology) {
        final Map.Entry<InstanceIdentifier<?>, DataObject> bi =
                this.bindingSerializer.fromNormalizedNode(this.topologyYii, topologyEntry);
        if (bi != null) {
            processTopology((Topology) bi.getValue(), wtx);
        }
    }
    try {
        wtx.commit().get();
    } catch (final ExecutionException | InterruptedException e) {
        LOG.warn("Failed to create Network Topologies", e);
    }
}
 
Example #15
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 #16
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
    InstanceIdentifier<Node> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
            .child(Node.class,createNodeKey(ip,port));
    LOG.debug("Created ovsdb path: {}",path);
    return path;
}
 
Example #17
Source File: HwvtepSouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
    InstanceIdentifier<Node> path = InstanceIdentifier
            .create(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
            .child(Node.class,createNodeKey(ip,port));
    LOG.debug("Created hwvtep path: {}",path);
    return path;
}
 
Example #18
Source File: HwvtepSouthboundUtil.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
public static InstanceIdentifier<Node> getGlobalNodeIid(final InstanceIdentifier<Node> physicalNodeIid) {
    String nodeId = physicalNodeIid.firstKeyOf(Node.class).getNodeId().getValue();
    int physicalSwitchIndex = nodeId.indexOf(HwvtepSouthboundConstants.PSWITCH_URI_PREFIX);
    if (physicalSwitchIndex > 0) {
        nodeId = nodeId.substring(0, physicalSwitchIndex - 1);
    } else {
        return null;
    }
    return physicalNodeIid.firstIdentifierOf(Topology.class).child(Node.class , new NodeKey(new NodeId(nodeId)));
}
 
Example #19
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get all OVSDB nodes from topology.
 * @return a list of nodes or null if the topology could not found
 */
public Map<NodeKey, Node> getOvsdbNodes() {
    InstanceIdentifier<Topology> inst = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
            new TopologyKey(OVSDB_TOPOLOGY_ID));
    Topology topology = provider.read(LogicalDatastoreType.OPERATIONAL, inst);
    return topology != null ? topology.getNode() : null;
}
 
Example #20
Source File: SouthboundUtils.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Read the list of <code>OvsdbTerminationPointAugmentation</code> for the particular <code>node</code>.
 */
public List<OvsdbTerminationPointAugmentation> readTerminationPointAugmentations(Node node) {
    if (node == null) {
        LOG.error("readTerminationPointAugmentations: Node value is null");
        return Collections.emptyList();
    }
    Node operNode = provider.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<>();
}
 
Example #21
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 #22
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 #23
Source File: TopologyStatsRpcServiceImpl.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
public synchronized void init() {
    LOG.info("Initializing PCEP Topology Stats RPC service.");
    this.listenerRegistration = this.dataBroker.registerDataTreeChangeListener(
            DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
                    InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class).child(Node.class)
                            .augmentation(PcepTopologyNodeStatsAug.class).child(PcepSessionState.class).build()),
            this);
}
 
Example #24
Source File: HwvtepSouthboundProvider.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Topology>> collection) {
    openOvsdbPort();

    if (operTopologyRegistration != null) {
        operTopologyRegistration.close();
        operTopologyRegistration = null;
    }
}
 
Example #25
Source File: AbstractTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
protected AbstractTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
        final TopologyId topologyId, final TopologyTypes types, final Class<? extends AddressFamily> afi,
    final Class<? extends SubsequentAddressFamily> safi, final long listenerResetLimitInMillsec,
    final int listenerResetEnforceCounter) {
    this.dataProvider = dataProvider;
    this.locRibReference = requireNonNull(locRibReference);
    this.topologyKey = new TopologyKey(requireNonNull(topologyId));
    this.topologyTypes = types;
    this.afi = afi;
    this.safi = safi;
    this.listenerResetLimitInMillsec = listenerResetLimitInMillsec;
    this.listenerResetEnforceCounter = listenerResetEnforceCounter;
    this.topology = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, this.topologyKey).build();
}
 
Example #26
Source File: LinkstateTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
protected void removeSrAwareTopologyTypeIfRequired(final WriteTransaction trans) {
    if (!this.srAwareTopologyTypeAdded) {
        return;
    }
    final boolean isSidPresent = this.nodes.values().stream().filter(nh -> nh.getSrHolder() != null)
            .map(nh -> nh.getSrHolder().getSegmentCount()).anyMatch(cnt -> cnt != 0);
    if (isSidPresent) {
        return;
    }
    LOG.debug("Removing SR-aware topology-type from topology {}",
            getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
    trans.put(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier().child(TopologyTypes.class),
            LINKSTATE_TOPOLOGY_TYPE);
    this.srAwareTopologyTypeAdded = false;
}
 
Example #27
Source File: LinkstateTopologyBuilder.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
protected void addSrAwareTopologyType(final WriteTransaction trans) {
    if (this.srAwareTopologyTypeAdded) {
        return;
    }
    LOG.debug("Adding SR-aware topology-type for topology {}",
            getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
    trans.put(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier().child(TopologyTypes.class),
            SR_AWARE_LINKSTATE_TOPOLOGY_TYPE);
    this.srAwareTopologyTypeAdded = true;
}
 
Example #28
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 #29
Source File: PcepStateUtils.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
private static Node readNodeFromDataStore(final DataBroker dataBroker,
        final String topologyId, final String nodeId) {
    final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
            .child(Node.class, new NodeKey(new NodeId(nodeId))).build();

    final ReadTransaction rot = dataBroker.newReadOnlyTransaction();

    try {
        return rot.read(LogicalDatastoreType.OPERATIONAL, topology).get().orElse(null);
    } catch (final InterruptedException | ExecutionException e) {
        LOG.warn("Failed to read node {}", nodeId, e);
    }
    return null;
}
 
Example #30
Source File: TopologyDataChangeCounter.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
TopologyDataChangeCounter(final DataBroker dataBroker, final String counterId, final String topologyName) {
    this.dataBroker = dataBroker;
    this.transactionChain = this.dataBroker.createMergingTransactionChain(this);
    this.counterId = counterId;
    this.counterInstanceId = InstanceIdentifier.builder(DataChangeCounter.class)
            .child(Counter.class, new CounterKey(this.counterId)).build();
    putCount(this.count.longValue());
    final InstanceIdentifier<Topology> topoIId = InstanceIdentifier.builder(NetworkTopology.class)
            .child(Topology.class, new TopologyKey(new TopologyId(topologyName))).build();
    this.registration = this.dataBroker.registerDataTreeChangeListener(
        DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, topoIId), this);
    LOG.debug("Data change counter {} initiated", this.counterId);
}