public ConnectionInfoBuilder(ConnectionInfo base) { this._localIp = base.getLocalIp(); this._localPort = base.getLocalPort(); this._remoteIp = base.getRemoteIp(); this._remotePort = base.getRemotePort(); if (base instanceof ConnectionInfoImpl) { ConnectionInfoImpl impl = (ConnectionInfoImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) { return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort()); }
/** * Returns controller details of the Node. * * @param ovnode OVSDB node augmentation. * @return Controller information. */ private String getControllerTarget(@Nonnull OvsdbNodeAugmentation ovnode) { String setControllerStr = null; String controllerIpStr = null; short openflowPort = OPENFLOW_PORT; // Check if ovsdb node has connection info ConnectionInfo connectionInfo = ovnode.getConnectionInfo(); if (connectionInfo != null && connectionInfo.getLocalIp() != null) { controllerIpStr = new String(connectionInfo.getLocalIp().getValue()); } else { LOG.warn("Ovsdb Node does not contains connection info : {}", ovnode); } if (controllerIpStr != null) { LOG.trace("Target OpenFlow Controller found : {}", controllerIpStr); setControllerStr = OPENFLOW_CONNECTION_PROTOCOL + ":" + controllerIpStr + ":" + openflowPort; } else { LOG.warn("Failed to determine OpenFlow controller ip address"); } return setControllerStr; }
@Override public void onSuccess(Optional<ServiceFunctionForwarders> optionalSffs) { if (optionalSffs.isPresent()) { ServiceFunctionForwarder sff = findSffByIp(optionalSffs.get(), connectionInfo.getRemoteIp()); if(sff != null) { SfcOvsSffEntryDataListener.addOvsdbAugmentations(sff, opendaylightSfc.getExecutor()); } } }
private static PortNumber getRemotePort(DataBroker dataBroker, UniAugmentation uni) { PortNumber remotePort = null; final Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni); if (optionalNode.isPresent()) { remotePort = optionalNode.get() .getAugmentation(OvsdbNodeAugmentation.class) .getConnectionInfo().getRemotePort(); } return remotePort; }
public static NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) { return createManagedNodeId(key.getRemoteIp(), key.getRemotePort(), bridgeName); }
public static String getControllerTarget(Node ovsdbNode) { String target = null; String ipAddr = null; OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class); ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo(); LOG.info("connectionInfo: {}", connectionInfo); if (connectionInfo != null && connectionInfo.getLocalIp() != null) { ipAddr = String.valueOf(connectionInfo.getLocalIp().getValue()); } if (ipAddr == null) { ipAddr = getLocalControllerHostIpAddress(); } if (ipAddr != null) { target = SouthboundConstants.OPENFLOW_CONNECTION_PROTOCOL + ":" + ipAddr + ":" + SouthboundConstants.DEFAULT_OPENFLOW_PORT; } return target; }
public static String getNodeIpAddress(OvsdbNodeAugmentation ovsdbNode) { //Currently we support only ipv4 return ovsdbNode.getConnectionInfo().getRemoteIp().getIpv4Address().getValue(); }
public static String connectionInfoToString(final ConnectionInfo connectionInfo) { return String.valueOf( connectionInfo.getRemoteIp().getValue()) + ":" + connectionInfo.getRemotePort().getValue(); }
if (!Objects.equals(_localIp, other.getLocalIp())) { return false; if (!Objects.equals(_localPort, other.getLocalPort())) { return false; if (!Objects.equals(_remoteIp, other.getRemoteIp())) { return false; if (!Objects.equals(_remotePort, other.getRemotePort())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
private static List<ControllerEntry> getControllerEntries(OvsdbNodeAugmentation connection) { ControllerEntryBuilder controllerBuilder = new ControllerEntryBuilder(); List<ControllerEntry> result = new ArrayList<>(); if (connection.getConnectionInfo().getLocalIp() != null) { String localIp = String.valueOf(connection.getConnectionInfo().getLocalIp().getValue()); String targetString = "tcp:" + localIp + ":" + OF_PORT; controllerBuilder.setTarget(new Uri(targetString)); result.add(controllerBuilder.build()); } return result; }
private String getRemoteIp(Node ovsdbNode) { Preconditions.checkNotNull(ovsdbNode, "The ovsdbNode was null"); String ip = null; OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class); if (ovsdbNodeAugmentation != null && ovsdbNodeAugmentation.getConnectionInfo() != null) { ip = ovsdbNodeAugmentation.getConnectionInfo().getRemoteIp().getIpv4Address().getValue(); } if (ip == null) { LOG.warn("remote_ip was not found for node: {}", ovsdbNode); ip = ""; } return ip; }
public static String connectionInfoToString(final ConnectionInfo connectionInfo) { return String.valueOf( connectionInfo.getRemoteIp().getValue()) + ":" + connectionInfo.getRemotePort().getValue(); }
} else if (tokens[0].equalsIgnoreCase("ptcp")) { ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo(); if (connectionInfo != null && connectionInfo.getLocalIp() != null) { controllerIpStr = String.valueOf(connectionInfo.getLocalIp().getValue()); controllersStr.add(OPENFLOW_CONNECTION_PROTOCOL + ":" + controllerIpStr + ":" + OPENFLOW_PORT);
/** * Search the Operational Datastore for a specific OvsdbNode. * @param dataBroker The dataBroker instance to create transactions * @param uni The UNI's data * @return The Optional OvsdbNode */ public static Optional<Node> findOvsdbNode(DataBroker dataBroker, UniAugmentation uni) { final List<Node> ovsdbNodes = getOvsdbNodes(dataBroker); Optional<Node> optionalOvsdb; if (!ovsdbNodes.isEmpty()) { for (final Node ovsdbNode : ovsdbNodes) { final OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode .getAugmentation(OvsdbNodeAugmentation.class); if (ovsdbNodeAugmentation.getConnectionInfo() .getRemoteIp() .getIpv4Address() .equals(uni.getIpAddress().getIpv4Address())) { LOG.info("Found ovsdb node"); optionalOvsdb = Optional.of(ovsdbNode); return optionalOvsdb; } } } return Optional.absent(); }
public static ConnectionInfo suppressLocalIpPort(ConnectionInfo connectionInfo) { ConnectionInfoBuilder connectionInfoBuilder = new ConnectionInfoBuilder(); connectionInfoBuilder.setRemoteIp(connectionInfo.getRemoteIp()); connectionInfoBuilder.setRemotePort(connectionInfo.getRemotePort()); return connectionInfoBuilder.build(); }
} else if (tokens[0].equalsIgnoreCase("ptcp")) { ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo(); if (connectionInfo != null && connectionInfo.getLocalIp() != null) { controllerIpStr = String.valueOf(connectionInfo.getLocalIp().getValue()); controllersStr.add(Constants.OPENFLOW_CONNECTION_PROTOCOL + ":" + controllerIpStr + ":" + Constants.OPENFLOW_PORT);
private Node readOvsdbNodeByIp(String ipAddress) { Preconditions.checkNotNull(ipAddress, "Cannot READ Node for given ipAddress from OVS operational store, ipAddress is null."); Topology topology = SfcDataStoreAPI.readTransactionAPI(SfcOvsUtil.buildOvsdbTopologyIID(), LogicalDatastoreType.OPERATIONAL); if (topology.getNode() != null) { for (Node node : topology.getNode()) { OvsdbNodeAugmentation ovsdbNodeAug = node.getAugmentation(OvsdbNodeAugmentation.class); if (ovsdbNodeAug != null && ovsdbNodeAug.getConnectionInfo() != null) { IpAddress connectionIp = ovsdbNodeAug.getConnectionInfo().getRemoteIp(); if (connectionIp == null) { return null; } if (connectionIp.getIpv4Address() != null && connectionIp.getIpv4Address().getValue().equals(ipAddress)) { return node; } else if (connectionIp.getIpv6Address() != null && connectionIp.getIpv6Address().getValue().equals(ipAddress)) { return node; } } } } else { LOG.warn( "Cannot READ Node for given ipAddress from OVS operational store, Topology does not contain any Node."); } return null; }
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(); }
} else if (tokens[0].equalsIgnoreCase("ptcp")) { ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo(); if (connectionInfo != null && connectionInfo.getLocalIp() != null) { controllerIpStr = String.valueOf(connectionInfo.getLocalIp().getValue()); controllersStr.add(Constants.OPENFLOW_CONNECTION_PROTOCOL + ":" + controllerIpStr + ":" + Constants.OPENFLOW_PORT);