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 createBasicVppNodeBuilder(NodeId nodeId) { return new NodeBuilder().setNodeId(nodeId).setSupportingNode(Arrays.asList( new SupportingNodeBuilder().setTopologyRef(SUPPORTING_TOPOLOGY_NETCONF).setNodeRef(nodeId).build())); }
public static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node toTopologyNode( final NodeId nodeId, final NodeRef invNodeRef) { return new NodeBuilder() .setNodeId(nodeId) .addAugmentation(InventoryNode.class, new InventoryNodeBuilder() .setInventoryNodeRef(invNodeRef) .build()) .build(); }
private Node buildConnectionNode( Bridge bridge) { //Update node with managed node reference NodeBuilder connectionNode = new NodeBuilder(); connectionNode.setNodeId(getOvsdbConnectionInstance().getNodeId()); OvsdbNodeAugmentationBuilder ovsdbConnectionAugmentationBuilder = new OvsdbNodeAugmentationBuilder(); List<ManagedNodeEntry> managedBridges = new ArrayList<>(); InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), bridge); ManagedNodeEntry managedBridge = new ManagedNodeEntryBuilder().setBridgeRef( new OvsdbBridgeRef(bridgeIid)).build(); managedBridges.add(managedBridge); ovsdbConnectionAugmentationBuilder.setManagedNodeEntry(managedBridges); connectionNode.addAugmentation(OvsdbNodeAugmentation.class, ovsdbConnectionAugmentationBuilder.build()); LOG.debug("Update node with bridge node ref {}", ovsdbConnectionAugmentationBuilder.getManagedNodeEntry().iterator().next()); return connectionNode.build(); }
/** * 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; }
public static Node createNode(ConnectionInfo key) { NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(), key.getRemotePort())); nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(key)); return nodeBuilder.build(); }
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 static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node prepareTopologyNode(final NodeId nodeIdInTopology, final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory) { final InventoryNode inventoryNode = new InventoryNodeBuilder() .setInventoryNodeRef(new NodeRef(iiToNodeInInventory.firstIdentifierOf(Node.class))) .build(); final NodeBuilder topologyNodeBuilder = new NodeBuilder(); topologyNodeBuilder.setNodeId(nodeIdInTopology); topologyNodeBuilder.addAugmentation(InventoryNode.class, inventoryNode); return topologyNodeBuilder.build(); }
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); } }
/** * Create a new node in the network topology. * * @param node An {@link OfNode} instance. * @return A node in the network topology. */ public static Node newTopologyNode(OfNode node) { InventoryNode invNode = new InventoryNodeBuilder(). setInventoryNodeRef(node.getNodeRef()). build(); return new NodeBuilder(). setNodeId(new NodeId(node.getNodeIdentifier())). addAugmentation(InventoryNode.class, invNode). build(); }
@Override public void execute(ReadWriteTransaction transaction) { Map<UUID, OpenVSwitch> updatedOpenVSwitchRows = TyperUtils .extractRowsUpdated(OpenVSwitch.class, getUpdates(), getDbSchema()); Map<UUID, OpenVSwitch> deletedOpenVSwitchRows = TyperUtils .extractRowsOld(OpenVSwitch.class, getUpdates(), getDbSchema()); for (Entry<UUID, OpenVSwitch> entry : updatedOpenVSwitchRows.entrySet()) { OpenVSwitch openVSwitch = entry.getValue(); final InstanceIdentifier<Node> nodePath = getInstanceIdentifier(openVSwitch); OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder(); setDbVersion(ovsdbNodeBuilder, openVSwitch); setOvsVersion(ovsdbNodeBuilder, openVSwitch); setDataPathTypes(ovsdbNodeBuilder, openVSwitch); setInterfaceTypes(ovsdbNodeBuilder, openVSwitch); OpenVSwitch oldEntry = deletedOpenVSwitchRows.get(entry.getKey()); setExternalIds(transaction, ovsdbNodeBuilder, oldEntry, openVSwitch); setOtherConfig(transaction, ovsdbNodeBuilder, oldEntry, openVSwitch); ovsdbNodeBuilder.setConnectionInfo(getConnectionInfo()); NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setNodeId(getNodeId(openVSwitch)); nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeBuilder.build()); transaction.merge(LogicalDatastoreType.OPERATIONAL, nodePath, nodeBuilder.build()); } }
@Override public void onDeviceFailed(Throwable throwable) { // we need to notify the higher level that something happened, get a current status from all other nodes, and aggregate a new result // no need to remove mountpoint, we should receive onRoleChanged callback after unregistering from election that unregisters the mountpoint LOG.warn("Netconf node {} failed with {}", nodeId, throwable); connected = false; String reason = (throwable != null && throwable.getMessage() != null) ? throwable.getMessage() : UNKNOWN_REASON; currentOperationalNode = new NodeBuilder().setNodeId(new NodeId(nodeId)) .addAugmentation(NetconfNode.class, new NetconfNodeBuilder() .setConnectionStatus(ConnectionStatus.UnableToConnect) .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build()) .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build()) .setClusteredConnectionStatus( new ClusteredConnectionStatusBuilder() .setNodeStatus( Collections.singletonList( new NodeStatusBuilder() .setNode(clusterExtension.selfAddress().toString()) .setStatus(Status.Failed) .build())) .build()) .setConnectedMessage(reason) .build()).build(); topologyManager.notifyNodeStatusChange(new NodeId(nodeId)); }
@Nonnull @Override public Node getFailedState(@Nonnull final NodeId nodeId, @Nullable final Node configNode) { final NetconfNode netconfNode = configNode == null ? currentOperationalNode.getAugmentation(NetconfNode.class) : configNode.getAugmentation(NetconfNode.class); final Node failedNode = new NodeBuilder() .setNodeId(nodeId) .addAugmentation(NetconfNode.class, new NetconfNodeBuilder() .setHost(netconfNode.getHost()) .setPort(netconfNode.getPort()) .setConnectionStatus(ConnectionStatus.UnableToConnect) .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build()) .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build()) .setClusteredConnectionStatus( new ClusteredConnectionStatusBuilder() .setNodeStatus( Collections.singletonList( new NodeStatusBuilder() .setNode(clusterExtension.selfAddress().toString()) .setStatus(Status.Failed) .build())) .build()) .build()) .build(); if (currentOperationalNode == null) { currentOperationalNode = failedNode; } return failedNode; }
@Nullable @Override public Node apply(NetconfDeviceCapabilities input) { // build state data currentOperationalNode = new NodeBuilder().setNodeId(nodeId) .addAugmentation(NetconfNode.class, new NetconfNodeBuilder() .setConnectionStatus(ConnectionStatus.Connected) .setClusteredConnectionStatus( new ClusteredConnectionStatusBuilder() .setNodeStatus( Collections.singletonList( new NodeStatusBuilder() .setNode(clusterExtension.selfAddress().toString()) .setStatus(Status.Connected) .build())) .build()) .setHost(netconfNode.getHost()) .setPort(netconfNode.getPort()) .setAvailableCapabilities(new AvailableCapabilitiesBuilder().setAvailableCapability(new ArrayList<String>()).build()) .setUnavailableCapabilities(new UnavailableCapabilitiesBuilder().setUnavailableCapability(new ArrayList<UnavailableCapability>()).build()) .build()).build(); return currentOperationalNode; } });
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()); }
private Node buildBridgeNode(Bridge bridge) { NodeBuilder bridgeNodeBuilder = new NodeBuilder(); NodeId bridgeNodeId = getNodeId(bridge); bridgeNodeBuilder.setNodeId(bridgeNodeId); OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder(); ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridge.getName())); ovsdbBridgeAugmentationBuilder.setBridgeUuid(new Uuid(bridge.getUuid().toString())); setDataPath(ovsdbBridgeAugmentationBuilder, bridge); setDataPathType(ovsdbBridgeAugmentationBuilder, bridge); setProtocol(ovsdbBridgeAugmentationBuilder, bridge); setExternalIds(ovsdbBridgeAugmentationBuilder, bridge); setOtherConfig(ovsdbBridgeAugmentationBuilder, bridge); setFailMode(ovsdbBridgeAugmentationBuilder, bridge); setOpenFlowNodeRef(ovsdbBridgeAugmentationBuilder, bridge); setManagedBy(ovsdbBridgeAugmentationBuilder); setAutoAttach(ovsdbBridgeAugmentationBuilder, bridge); bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build()); LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder.build()); return bridgeNodeBuilder.build(); }