use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project bgpcep by opendaylight.
the class NodeChangedListenerTest method createNode.
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId, final String dstIpv4Address) throws TransactionCommitFailedException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.setKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
pathBuilder.addAugmentation(Path1.class, new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4Address(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4Address(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().setKey(new ReportedLspKey(lspName)).setPath(Collections.singletonList(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(Lists.newArrayList(reportedLps)).setIpAddress(new IpAddress(new Ipv4Address(ipv4Address))).build());
nodeBuilder.addAugmentation(Node1.class, node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project bgpcep by opendaylight.
the class PcepStateUtilsTest method createDefaultProtocol.
private void createDefaultProtocol() throws ExecutionException, InterruptedException {
final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
final Node node = new NodeBuilder().setNodeId(new NodeId(NODE_ID)).addAugmentation(PcepTopologyNodeStatsAug.class, new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(createPcepSessionState()).build()).build();
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId(PCEP_TOPOLOGY))).child(Node.class, new NodeKey(new NodeId(NODE_ID))).build();
wt.put(LogicalDatastoreType.OPERATIONAL, topology, node, true);
wt.submit().get();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project bgpcep by opendaylight.
the class AbstractReachabilityTopologyBuilder method ensureNodePresent.
private InstanceIdentifier<IgpNodeAttributes> ensureNodePresent(final ReadWriteTransaction trans, final NodeId ni) {
final NodeUsage present = this.nodes.get(ni);
if (present != null) {
return present.attrId;
}
final KeyedInstanceIdentifier<Node, NodeKey> nii = nodeInstanceId(ni);
final InstanceIdentifier<IgpNodeAttributes> ret = nii.builder().augmentation(Node1.class).child(IgpNodeAttributes.class).build();
trans.merge(LogicalDatastoreType.OPERATIONAL, nii, new NodeBuilder().setKey(nii.getKey()).setNodeId(ni).addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes(new IgpNodeAttributesBuilder().setPrefix(Collections.emptyList()).build()).build()).build());
this.nodes.put(ni, new NodeUsage(ret));
return ret;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createNode.
private void createNode(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final NodeCase nodeCase, final Attributes attributes) {
final NodeAttributes na;
// defensive lookup
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType != null) {
na = ((NodeAttributesCase) attrType).getNodeAttributes();
} else {
LOG.debug("Missing attribute type in node {} route {}, skipping it", nodeCase, value);
na = null;
}
} else {
LOG.debug("Missing attributes in node {} route {}, skipping it", nodeCase, value);
na = null;
}
final IgpNodeAttributesBuilder inab = new IgpNodeAttributesBuilder();
final List<IpAddress> ids = new ArrayList<>();
if (na != null) {
if (na.getIpv4RouterId() != null) {
ids.add(new IpAddress(na.getIpv4RouterId()));
}
if (na.getIpv6RouterId() != null) {
ids.add(new IpAddress(na.getIpv6RouterId()));
}
if (na.getDynamicHostname() != null) {
inab.setName(new DomainName(na.getDynamicHostname()));
}
}
if (!ids.isEmpty()) {
inab.setRouterId(ids);
}
ProtocolUtil.augmentProtocolId(value, inab, na, nodeCase.getNodeDescriptors());
final NodeId nid = buildNodeId(base, nodeCase.getNodeDescriptors());
final NodeHolder nh = getNode(nid);
/*
* Eventhough the the holder creates a dummy structure, we need to duplicate it here,
* as that is the API requirement. The reason for it is the possible presence of supporting
* node -- something which the holder does not track.
*/
final NodeBuilder nb = new NodeBuilder();
nb.setNodeId(nid);
nb.setKey(new NodeKey(nb.getNodeId()));
nh.advertized(nb, inab);
putNode(trans, nh);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method _testAllFlows.
/*
* usage testAllFlows <dp>
* ex: _perfFlowTest 1
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public void _testAllFlows(final CommandInterpreter ci) {
String dataPathID = ci.nextArgument();
final int numberOfFlows = 82;
if (dataPathID == null || dataPathID.trim().equals("")) {
dataPathID = "1";
}
ci.println("* Test All Flows *");
ci.println("* dataPathID:::" + dataPathID + "");
final String dataPath = "openflow:" + dataPathID;
final String tableId = "0";
final NodeBuilder tn = createTestNode(dataPath);
FlowBuilder tf;
for (int flow = 1; flow < numberOfFlows; flow++) {
final String flowID = "f" + flow;
try {
tf = createTestFlow(tn, flowID, tableId);
writeFlow(ci, tf, tn);
} catch (RuntimeException e) {
ci.println("--Test Failed--Issue found while adding flow" + flow);
break;
}
}
}
Aggregations