private void setName(Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode, Optional<OvsdbBridgeAugmentation> operationalBridgeOptional) { if (ovsdbManagedNode.getBridgeName() != null) { bridge.setName(ovsdbManagedNode.getBridgeName().getValue()); } else if (operationalBridgeOptional.isPresent() && operationalBridgeOptional.get().getBridgeName() != null) { bridge.setName(operationalBridgeOptional.get().getBridgeName().getValue()); } }
public OvsdbBridgeAugmentation getBridge(Node node, String name) { OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if ((bridge != null) && (!bridge.getBridgeName().getValue().equals(name))) { bridge = null; } return bridge; }
public OvsdbBridgeAugmentation getBridge(Node node, String name) { OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if ((bridge != null) && (!bridge.getBridgeName().getValue().equals(name))) { bridge = null; } return bridge; }
public String getBridgeName(Node node) { String bridgeName = null; OvsdbBridgeAugmentation bridge = getBridge(node); if (bridge != null) { bridgeName = bridge.getBridgeName().getValue(); } return bridgeName; }
public String getBridgeName(Node node) { String bridgeName = null; OvsdbBridgeAugmentation bridge = getBridge(node); if (bridge != null) { bridgeName = bridge.getBridgeName().getValue(); } return bridgeName; }
public String extractBridgeName(Node node) { return node.getAugmentation(OvsdbBridgeAugmentation.class).getBridgeName().getValue(); }
public Node getBridgeNode(Node node, String bridgeName) { OvsdbBridgeAugmentation bridge = extractBridgeAugmentation(node); if (bridge != null && bridge.getBridgeName().getValue().equals(bridgeName)) { return node; } else { return readBridgeNode(node, bridgeName); } }
public String extractBridgeName(Node node) { return node.getAugmentation(OvsdbBridgeAugmentation.class).getBridgeName().getValue(); }
public String extractBridgeName(Node node) { return node.getAugmentation(OvsdbBridgeAugmentation.class).getBridgeName().getValue(); }
public Node getBridgeNode(Node node, String bridgeName) { OvsdbBridgeAugmentation bridge = extractBridgeAugmentation(node); if (bridge != null && bridge.getBridgeName().getValue().equals(bridgeName)) { return node; } else { return readBridgeNode(node, bridgeName); } }
public Node getBridgeNode(Node node, String bridgeName) { OvsdbBridgeAugmentation bridge = extractBridgeAugmentation(node); if (bridge != null && bridge.getBridgeName().getValue().equals(bridgeName)) { return node; } else { return readBridgeNode(node, bridgeName); } }
/** * Return the OVSDB bridge augmentation in the given node. * * @param ovh An {@link OVSDBEventHandler} instance. * @param node A {@link Node} instance. * @return The OVSDB bridge augmentation if found. * {@code null} if not found. */ static OvsdbBridgeAugmentation getBridgeNode( @Nonnull OVSDBEventHandler ovh, @Nonnull Node node) { OvsdbBridgeAugmentation ovbr = node.getAugmentation(OvsdbBridgeAugmentation.class); OvsdbBridgeAugmentation result = null; if (ovbr != null) { OvsdbBridgeName name = ovbr.getBridgeName(); if (name != null && ovh.getOvsdbBridgeName().equals(name.getValue())) { result = ovbr; } else { LOG.trace("Ignore OVSDB bridge: node={}, bridge={}", node.getNodeId(), ovbr); } } return result; }
/** * Method builds OVS NodeId which is based on: * 1. OVS Node InstanceIdentifier which manages the OVS Bridge * 2. OVS Bridge name * <p> * If the two aforementioned fields are missing, NullPointerException is raised. * <p> * * @param ovsdbBridge OvsdbBridgeAugmentation * @return NodeId */ private static NodeId getManagedByNodeId(OvsdbBridgeAugmentation ovsdbBridge) { Preconditions.checkNotNull(ovsdbBridge, "Cannot getManagedByNodeId, OvsdbBridgeAugmentation is null."); Preconditions.checkNotNull(ovsdbBridge.getBridgeName(), "Cannot build getManagedByNodeId, BridgeName is null."); Preconditions.checkNotNull(ovsdbBridge.getManagedBy(), "Cannot build getManagedByNodeId, ManagedBy is null."); String bridgeName = (ovsdbBridge.getBridgeName().getValue()); InstanceIdentifier<Node> nodeIID = (InstanceIdentifier<Node>) ovsdbBridge.getManagedBy().getValue(); KeyedInstanceIdentifier keyedInstanceIdentifier = (KeyedInstanceIdentifier) nodeIID.firstIdentifierOf(Node.class); Preconditions.checkNotNull(keyedInstanceIdentifier, "Cannot build getManagedByNodeId, parent OVS Node is null."); NodeKey nodeKey = (NodeKey) keyedInstanceIdentifier.getKey(); String nodeId = nodeKey.getNodeId().getValue(); nodeId = nodeId.concat(OVSDB_BRIDGE_PREFIX + bridgeName); return new NodeId(nodeId); }
&& ovsdbBridge.getBridgeName() != null && entry.getValue() != null && entry.getValue().getProtocol() != null) { if (protocolString != null) { Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class); bridge.setName(ovsdbBridge.getBridgeName().getValue()); try { bridge.setProtocols(Sets.newHashSet(protocolString));
private void setPort(TransactionBuilder transaction, Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode) { Insert<GenericTableSchema> interfaceInsert = setInterface(transaction,ovsdbManagedNode); // Port part String portNamedUuid = "Port_" + SouthboundMapper.getRandomUuid(); Port port = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Port.class); port.setName(ovsdbManagedNode.getBridgeName().getValue()); port.setInterfaces(Sets.newHashSet(TransactUtils.extractNamedUuid(interfaceInsert))); transaction.add(op.insert(port).withId(portNamedUuid)); bridge.setPorts(Sets.newHashSet(new UUID(portNamedUuid))); }
private void execute(TransactionBuilder transaction, BridgeOperationalState state, Set<InstanceIdentifier<OvsdbBridgeAugmentation>> removed, Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> originals) { for (InstanceIdentifier<OvsdbBridgeAugmentation> ovsdbManagedNodeIid: removed) { LOG.debug("Received request to delete ovsdb node : {}", ovsdbManagedNodeIid); OvsdbBridgeAugmentation original = originals.get(ovsdbManagedNodeIid); Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class,null); Optional<OvsdbBridgeAugmentation> ovsdbAugmentationOptional = state .getOvsdbBridgeAugmentation(ovsdbManagedNodeIid); if (ovsdbAugmentationOptional.isPresent() && ovsdbAugmentationOptional.get().getBridgeUuid() != null) { UUID bridgeUuid = new UUID(ovsdbAugmentationOptional.get().getBridgeUuid().getValue()); OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class,null); transaction.add(op.delete(bridge.getSchema()) .where(bridge.getUuidColumn().getSchema().opEqual(bridgeUuid)).build()); transaction.add(op.comment("Bridge: Deleting " + original.getBridgeName())); transaction.add(op.mutate(ovs.getSchema()) .addMutation(ovs.getBridgesColumn().getSchema(), Mutator.DELETE, Sets.newHashSet(bridgeUuid))); transaction.add(op.comment("Open_vSwitch: Mutating " + original.getBridgeName() + " " + bridgeUuid)); LOG.info("Bridge Deleted: {}", ovsdbManagedNodeIid); } else { LOG.warn("Unable to delete bridge {} because it was not found in the operational store, " + "and thus we cannot retrieve its UUID", ovsdbManagedNodeIid); } } } }
InstanceIdentifier<OvsdbBridgeAugmentation> iid, OvsdbBridgeAugmentation ovsdbManagedNode) { LOG.debug("Received request to create ovsdb bridge name: {} uuid: {}", ovsdbManagedNode.getBridgeName(), ovsdbManagedNode.getBridgeUuid()); Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class); transaction.add(op.insert(bridge)); LOG.info("Added ovsdb Bridge name: {} uuid: {}", ovsdbManagedNode.getBridgeName(), ovsdbManagedNode.getBridgeUuid()); } else { String existingBridgeName = operationalBridgeOptional.get().getBridgeName().getValue();
private Insert<GenericTableSchema> setInterface(TransactionBuilder transaction, OvsdbBridgeAugmentation ovsdbManagedNode) { // Interface part String interfaceNamedUuid = "Interface_" + SouthboundMapper.getRandomUuid(); Interface interfaceOvs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Interface.class); interfaceOvs.setName(ovsdbManagedNode.getBridgeName().getValue()); interfaceOvs.setType(SouthboundMapper.createOvsdbInterfaceType(InterfaceTypeInternal.class)); Insert<GenericTableSchema> result = op.insert(interfaceOvs).withId(interfaceNamedUuid); transaction.add(result); return result; }
private void deleteAutoAttach(TransactionBuilder transaction, InstanceIdentifier<OvsdbNodeAugmentation> ovsdbNodeIid, Uuid autoattachUuid) { LOG.debug("Received request to delete Autoattach entry {}", autoattachUuid); final OvsdbBridgeAugmentation bridgeAugmentation = getBridge(ovsdbNodeIid, autoattachUuid); if (autoattachUuid != null && bridgeAugmentation != null) { final UUID uuid = new UUID(autoattachUuid.getValue()); final AutoAttach autoattach = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), AutoAttach.class, null); transaction.add(op.delete(autoattach.getSchema()) .where(autoattach.getUuidColumn().getSchema().opEqual(uuid)) .build()); transaction.add(op.comment("AutoAttach: Deleting {} " + uuid + " attached to " + bridgeAugmentation.getBridgeName().getValue())); final Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class,null); transaction.add(op.mutate(bridge.getSchema()) .addMutation(bridge.getAutoAttachColumn().getSchema(), Mutator.DELETE, Sets.newHashSet(uuid)) .where(bridge.getNameColumn().getSchema() .opEqual(bridgeAugmentation.getBridgeName().getValue())).build()); transaction.add(op.comment("Bridge: Mutating " + bridgeAugmentation.getBridgeName().getValue() + " to remove autoattach column " + uuid)); } else { LOG.debug("Unable to delete AutoAttach {} for node {} because it was not found in the operational store, " + "and thus we cannot retrieve its UUID", autoattachUuid, ovsdbNodeIid); } }
public OvsdbBridgeAugmentationBuilder(OvsdbBridgeAugmentation base) { this._autoAttach = base.getAutoAttach(); this._bridgeExternalIds = base.getBridgeExternalIds(); this._bridgeName = base.getBridgeName(); this._bridgeOpenflowNodeRef = base.getBridgeOpenflowNodeRef(); this._bridgeOtherConfigs = base.getBridgeOtherConfigs(); this._bridgeUuid = base.getBridgeUuid(); this._controllerEntry = base.getControllerEntry(); this._datapathId = base.getDatapathId(); this._datapathType = base.getDatapathType(); this._failMode = base.getFailMode(); this._flowNode = base.getFlowNode(); this._managedBy = base.getManagedBy(); this._protocolEntry = base.getProtocolEntry(); }