private NodeHolder(final NodeId id) { this.inab = new IgpNodeAttributesBuilder(); this.nb = new NodeBuilder().setKey(new NodeKey(id)).setNodeId(id); }
public static Node createBasicNode(String nodeIdStr) { NodeId nodeId = new NodeId(nodeIdStr); NodeKey nodeKey = new NodeKey(nodeId); NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setKey(nodeKey); nodeBuilder.setNodeId(nodeId); List<SupportingNode> childNodeList = new ArrayList<>(); nodeBuilder.setSupportingNode(childNodeList); List<TerminationPoint> ports = new ArrayList<>(); TerminationPoint tpWest = createTp(VC_NODE_TP_WEST); ports.add(tpWest); TerminationPoint tpEast = createTp(VC_NODE_TP_EAST); ports.add(tpEast); nodeBuilder.setTerminationPoint(ports); return nodeBuilder.build(); }
private void unadvertized() { this.inab = new IgpNodeAttributesBuilder(); this.nb = new NodeBuilder().setKey(this.nb.getKey()).setNodeId(this.nb.getNodeId()); this.advertized = false; LOG.debug("Node {} is unadvertized", this.nb.getNodeId()); }
private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) { final NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setKey(new NodeKey(new NodeId(id.getName()))); return nodeBuilder; }
/** * Creates a NodeBuilder based on the given HostNodeBuilder. * * @param hostNode * The HostNodeBuilder where the AttachmentPoints and Id are. * @return A NodeBuilder with the same Id of HostNodeBuilder and a list of * TerminationPoint corresponding to each HostNodeBuilder's * AttachmentPoints. */ private NodeBuilder createNodeBuilder(HostNodeBuilder hostNode, List<AttachmentPointsBuilder> apbs) { List<TerminationPoint> tps = new ArrayList<>(); for (AttachmentPointsBuilder atb : apbs) { TerminationPoint tp = createTerminationPoint(hostNode); tps.add(tp); atb.setCorrespondingTp(tp.getTpId()); } NodeBuilder node = new NodeBuilder().setNodeId(createNodeId(hostNode)).setTerminationPoint(tps); node.setKey(new NodeKey(node.getNodeId())); return node; }
/** * Creates a NodeBuilder based on the given HostNodeBuilder. * * @param hostNode The HostNodeBuilder where the AttachmentPoints and Id * are. * @return A NodeBuilder with the same Id of HostNodeBuilder and a list of * TerminationPoint corresponding to each HostNodeBuilder's * AttachmentPoints. */ private NodeBuilder createNodeBuilder(HostNodeBuilder hostNode, List<AttachmentPointsBuilder> apbs) { List<TerminationPoint> tps = new ArrayList<>(); for (AttachmentPointsBuilder atb : apbs) { TerminationPoint tp = createTerminationPoint(hostNode); tps.add(tp); atb.setCorrespondingTp(tp.getTpId()); } NodeBuilder node = new NodeBuilder().setNodeId(createNodeId(hostNode)) .setTerminationPoint(tps); node.setKey(new NodeKey(node.getNodeId())); return node; }
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.<Prefix>emptyList()).build()).build()).build()); this.nodes.put(ni, new NodeUsage(ret)); return ret; }
private void putTopologyNode() { final Node node = new NodeBuilder().setKey(nodeId.getKey()).setNodeId(nodeId.getKey().getNodeId()).build(); final WriteTransaction t = beginTransaction(); t.put(LogicalDatastoreType.OPERATIONAL, nodeId, node); t.submit(); }
/** * Creates a submit an OvsdbNode to the Configuration DataStore. * @param dataBroker The instance of the Data Broker to create transactions. * @param ovsdbNodeId The Ovsdb Node Id to use on creation * @param uni The UNI's data */ public static void createOvsdbNode(DataBroker dataBroker, NodeId ovsdbNodeId, Uni uni) { final InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(uni.getIpAddress()); try { final NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId); final Node nodeData = new NodeBuilder() .setNodeId(ovsdbNodeId) .setKey(ovsdbNodeKey) .addAugmentation(OvsdbNodeAugmentation.class, OvsdbUtils.createOvsdbNodeAugmentation(uni)) .build(); // Submit the node to the datastore final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodeIid, nodeData); transaction.submit(); LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId()); } catch (final Exception e) { LOG.error("Exception while creating OvsdbNodeAugmentation, Uni is null. Node Id: {}", ovsdbNodeId, e); } }
private void buildNodeAttribute(NodeBuilder builder, ComposeFabricInput input, FabricId fabricId) { builder.setKey(new NodeKey(fabricId)); List<DeviceNodes> devices = input.getDeviceNodes(); if (devices != null) { List<SupportingNode> snodes = Lists.newArrayList(); for (DeviceNodes device : devices) { InstanceIdentifier<?> nodeRef = device.getDeviceRef().getValue(); NodeId nodeid = nodeRef.firstKeyOf(Node.class).getNodeId(); TopologyId topoId = nodeRef.firstKeyOf(Topology.class).getTopologyId(); SupportingNodeBuilder snodeBuilder = new SupportingNodeBuilder(); snodeBuilder.setNodeRef(nodeid); snodeBuilder.setTopologyRef(topoId); snodeBuilder.setKey(new SupportingNodeKey(nodeid, topoId)); snodes.add(snodeBuilder.build()); } builder.setSupportingNode(snodes); } }
/** * Creates and submit an UNI Node by using the Data contained in the UniAugmentation. * @param dataBroker The instance of the DataBroker to create transactions * @param uni The UNI's data * @return true if uni created */ public static boolean createUniNode(DataBroker dataBroker, UniAugmentation uni) { final NodeId uniNodeId = new NodeId(createUniNodeId(uni.getIpAddress())); boolean result = false; try { final InstanceIdentifier<Node> uniNodeIid = UnimgrMapper.getUniNodeIid(uniNodeId); final NodeKey uniNodeKey = new NodeKey(uniNodeId); final Node nodeData = new NodeBuilder() .setNodeId(uniNodeId) .setKey(uniNodeKey) .addAugmentation(UniAugmentation.class, uni) .build(); final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, uniNodeIid, nodeData); final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit(); future.checkedGet(); result = true; LOG.info("Created and submitted a new Uni node {}", nodeData.getNodeId()); } catch (final Exception e) { LOG.error("Exception while creating Uni Node, Uni Node Id: {}", uniNodeId, e); } return result; }
/** * Creates and submit an OvsdbNode by using the Data contained in the UniAugmentation. * @param dataBroker The instance of the DataBroker to create transactions * @param uni The UNI's data * @return The instance of the Node */ public static Node createOvsdbNode(DataBroker dataBroker, UniAugmentation uni) { final NodeId ovsdbNodeId = new NodeId(createOvsdbNodeId(uni.getIpAddress())); try { final InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNodeId); final NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId); final Node nodeData = new NodeBuilder() .setNodeId(ovsdbNodeId) .setKey(ovsdbNodeKey) .addAugmentation(OvsdbNodeAugmentation.class, OvsdbUtils.createOvsdbNodeAugmentation(uni)) .build(); // Submit the node to the datastore final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodeIid, nodeData); transaction.submit(); LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId()); return nodeData; } catch (final Exception e) { LOG.error("Exception while creating OvsdbNodeAugmentation, Uni is null. Node Id: {}", ovsdbNodeId, e); } return null; }
/** * @param nodeName NodeId used for initialization * @param logicalDatastoreType Logical datastore type where topology will be initialized * @param datastoreAccess Datastore access used for initialization * @return If Topology was successfully initialized */ public static boolean initTopologyNode(final String nodeName, final LogicalDatastoreType logicalDatastoreType, final DatastoreAccess datastoreAccess) { InstanceIdentifier<Node> nodeIdentifier = NodeIdentityListener.SUBSCRIBED_PATH.child(Node.class, new NodeKey( new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId( nodeName))); return datastoreAccess.checkAndPut(nodeIdentifier, new NodeBuilder().setKey(new NodeKey( new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId( nodeName))).build(), logicalDatastoreType, false); }
nb.setKey(new NodeKey(nb.getNodeId()));
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setKey(node.getKey()); nodeBuilder.setNodeId(node.getNodeId()); nodeBuilder.addAugmentation(UniAugmentation.class, updatedUniBuilder.build());
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setKey(node.getKey()); nodeBuilder.setNodeId(node.getNodeId()); nodeBuilder.addAugmentation(UniAugmentation.class, updatedUniBuilder.build());
nodeBuilder.setKey(new NodeKey(newNodeId)); nodeBuilder.setNodeId(newNodeId);
nodeBuilder.setKey(new NodeKey(newNodeId)); nodeBuilder.setNodeId(newNodeId);
private InstanceIdentifier<TerminationPoint> createTP(final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl, final ReadWriteTransaction trans) { final String url = "ip://" + addr.toString(); final TerminationPointKey tpk = new TerminationPointKey(new TpId(url)); final TerminationPointBuilder tpb = new TerminationPointBuilder(); tpb.setKey(tpk).setTpId(tpk.getTpId()); tpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes( new IgpTerminationPointAttributesBuilder().setTerminationPointType( new IpBuilder().setIpAddress(Lists.newArrayList(addr)).build()).build()).build()); final NodeKey nk = new NodeKey(new NodeId(url)); final NodeBuilder nb = new NodeBuilder(); nb.setKey(nk).setNodeId(nk.getNodeId()); nb.setTerminationPoint(Lists.newArrayList(tpb.build())); if (sni != null) { nb.setSupportingNode(Lists.newArrayList(createSupportingNode(InstanceIdentifier.keyOf(sni).getNodeId(), inControl))); } final InstanceIdentifier<Node> nid = this.target.child(Node.class, nb.getKey()); trans.put(LogicalDatastoreType.OPERATIONAL, nid, nb.build()); return nid.child(TerminationPoint.class, tpb.getKey()); }