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(); }
/** * 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); }
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()); } }
private InstanceIdentifier<?> getManagedByIidFromOperDS(InstanceIdentifier<?> bridgeIid) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = bridgeIid.firstIdentifierOf(Node.class); Optional<?> bridgeNode = SouthboundUtil.readNode(db.newReadWriteTransaction(),nodeEntryIid); if (bridgeNode.isPresent() && bridgeNode.get() instanceof Node) { Node node = (Node)bridgeNode.get(); OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null) { return bridge.getManagedBy().getValue(); } } return null; }
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); } } } }
public String getDatapathId(OvsdbBridgeAugmentation ovsdbBridgeAugmentation) { String datapathId = null; if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) { datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue(); } return datapathId; }
public Optional<ControllerEntry> getControllerEntry(InstanceIdentifier<?> iid) { if (iid != null) { Optional<OvsdbBridgeAugmentation> ovsdbBridgeOptional = getOvsdbBridgeAugmentation(iid); if (ovsdbBridgeOptional.isPresent() && ovsdbBridgeOptional.get().getControllerEntry() != null) { ControllerEntryKey key = iid.firstKeyOf(ControllerEntry.class, ControllerEntryKey.class); if (key != null) { for (ControllerEntry entry: ovsdbBridgeOptional.get().getControllerEntry()) { if (entry.getKey().equals(key)) { return Optional.of(entry); } } } } } return Optional.absent(); }
private Map<InstanceIdentifier<?>, DataObject> extractBridgeConfigurationChanges( final Node bridgeNode, final OvsdbBridgeAugmentation ovsdbBridge) { Map<InstanceIdentifier<?>, DataObject> changes = new HashMap<>(); final InstanceIdentifier<Node> bridgeNodeIid = SouthboundMapper.createInstanceIdentifier(bridgeNode.getNodeId()); final InstanceIdentifier<OvsdbBridgeAugmentation> ovsdbBridgeIid = bridgeNodeIid.builder().augmentation(OvsdbBridgeAugmentation.class).build(); changes.put(bridgeNodeIid, bridgeNode); changes.put(ovsdbBridgeIid, ovsdbBridge); if (ovsdbBridge.getProtocolEntry() != null) { for (ProtocolEntry protocol : ovsdbBridge.getProtocolEntry()) { if (SouthboundConstants.OVSDB_PROTOCOL_MAP.get(protocol.getProtocol()) != null) { KeyedInstanceIdentifier<ProtocolEntry, ProtocolEntryKey> protocolIid = ovsdbBridgeIid.child(ProtocolEntry.class, protocol.getKey()); changes.put(protocolIid, protocol); } else { throw new IllegalArgumentException("Unknown protocol " + protocol.getProtocol()); } } } if (ovsdbBridge.getControllerEntry() != null) { for (ControllerEntry controller : ovsdbBridge.getControllerEntry()) { KeyedInstanceIdentifier<ControllerEntry, ControllerEntryKey> controllerIid = ovsdbBridgeIid.child(ControllerEntry.class, controller.getKey()); changes.put(controllerIid, controller); } } return changes; }
private void setOpenDaylightOtherConfig(@Nonnull Bridge bridge, @Nonnull OvsdbBridgeAugmentation ovsdbManagedNode) { try { bridge.setOtherConfig(YangUtils.convertYangKeyValueListToMap(ovsdbManagedNode.getBridgeOtherConfigs(), BridgeOtherConfigs::getBridgeOtherConfigKey, BridgeOtherConfigs::getBridgeOtherConfigValue)); } catch (NullPointerException e) { LOG.warn("Incomplete bridge other config", e); } }
private void setOpenDaylightExternalIds(Bridge bridge, InstanceIdentifier<OvsdbBridgeAugmentation> iid, OvsdbBridgeAugmentation ovsdbManagedNode) { // Set the iid external_id Map<String, String> externalIdMap = new HashMap<>(); externalIdMap.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, SouthboundUtil.serializeInstanceIdentifier(iid)); // Set user provided external ids try { YangUtils.copyYangKeyValueListToMap(externalIdMap, ovsdbManagedNode.getBridgeExternalIds(), BridgeExternalIds::getBridgeExternalIdKey, BridgeExternalIds::getBridgeExternalIdValue); } catch (NullPointerException e) { LOG.warn("Incomplete bridge external Id", e); } bridge.setExternalIds(externalIdMap); }
public String getBridgeUuid(Node node, String name) { String uuid = null; OvsdbBridgeAugmentation ovsdbBridgeAugmentation = readBridge(node, name); if (ovsdbBridgeAugmentation != null) { uuid = ovsdbBridgeAugmentation.getBridgeUuid().getValue(); } return uuid; }
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; }
private InstanceIdentifier<?> getManagedByIid(Map<InstanceIdentifier<?>, DataObject> map, InstanceIdentifier<?> iidToCheck) { // Get the InstanceIdentifier of the containing node InstanceIdentifier<Node> nodeEntryIid = iidToCheck.firstIdentifierOf(Node.class); // Look for the Node in the created/updated data DataObject dataObject = null; if (map != null && map.get(nodeEntryIid) != null) { dataObject = map.get(nodeEntryIid); } // If we are contained in a bridge managed by this iid if (dataObject != null && dataObject instanceof Node) { Node node = (Node)dataObject; OvsdbBridgeAugmentation bridge = node.getAugmentation(OvsdbBridgeAugmentation.class); if (bridge != null && bridge.getManagedBy() != null && bridge.getManagedBy().getValue().equals(this.iid)) { return bridge.getManagedBy().getValue(); } } return null; }
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = ovsdbPortMetadata.getOvsdbBridgeNode(); if (ovsdbBridgeAugmentation != null) { ovsBridgeBuilder.setBridgeName(ovsdbBridgeAugmentation.getBridgeName().getValue()); String serviceNode = OvsdbMdsalHelper.getNodeKey(ovsdbBridgeAugmentation.getManagedBy().getValue()); if(serviceNode.isEmpty()) { serviceNode += SFF_DEFAULT_NAME + counter.incrementAndGet(); serviceNode += "/" + ovsdbBridgeAugmentation.getBridgeName().getValue(); sffBuilder.setName(new SffName(serviceNode)); ovsNodeBuilder.setNodeId(ovsdbBridgeAugmentation.getManagedBy()); sffOvsNodeAugBuilder.setOvsNode(ovsNodeBuilder.build()); sffBuilder.addAugmentation(SffOvsNodeAugmentation.class, sffOvsNodeAugBuilder.build());
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); setFailMode(bridge, ovsdbManagedNode); transaction.add(op.insert(bridge)); LOG.info("Added ovsdb Bridge name: {} uuid: {}", ovsdbManagedNode.getBridgeName(), ovsdbManagedNode.getBridgeUuid()); } else { String existingBridgeName = operationalBridgeOptional.get().getBridgeName().getValue();
public String getDatapathId(OvsdbBridgeAugmentation ovsdbBridgeAugmentation) { String datapathId = null; if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) { datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue(); } return datapathId; }
public static Map<UUID, Controller> createOvsdbController(OvsdbBridgeAugmentation omn,DatabaseSchema dbSchema) { List<ControllerEntry> controllerEntries = omn.getControllerEntry(); Map<UUID,Controller> controllerMap = new HashMap<>(); if (controllerEntries != null && !controllerEntries.isEmpty()) { for (ControllerEntry controllerEntry : controllerEntries) { String controllerNamedUuid = "Controller_" + getRandomUuid(); Controller controller = TyperUtils.getTypedRowWrapper(dbSchema, Controller.class); controller.setTarget(controllerEntry.getTarget().getValue()); controllerMap.put(new UUID(controllerNamedUuid), controller); } } return controllerMap; }
case BRIDGE: OvsdbBridgeAugmentation bridge = extractBridgeAugmentation(node); if (bridge != null && bridge.getBridgeOtherConfigs() != null) { for (BridgeOtherConfigs bridgeOtherConfigs : bridge.getBridgeOtherConfigs()) { if (bridgeOtherConfigs.getBridgeOtherConfigKey().equals(key)) { return bridgeOtherConfigs.getBridgeOtherConfigValue();
case BRIDGE: OvsdbBridgeAugmentation bridge = extractBridgeAugmentation(node); if (bridge != null && bridge.getBridgeExternalIds() != null) { for (BridgeExternalIds bridgeExternaIds :bridge.getBridgeExternalIds()) { if (bridgeExternaIds.getBridgeExternalIdKey().equals(key)) { return bridgeExternaIds.getBridgeExternalIdValue();
public String getBridgeUuid(Node node, String name) { String uuid = null; OvsdbBridgeAugmentation ovsdbBridgeAugmentation = readBridge(node, name); if (ovsdbBridgeAugmentation != null) { uuid = ovsdbBridgeAugmentation.getBridgeUuid().getValue(); } return uuid; }