/** * Gets tunnel name. * * @param tunnelType * @param dstIp the remote ip address * @return tunnel name */ private String getTunnelName(String tunnelType, IpAddress dstIp) { return tunnelType + "-" + dstIp.toString(); }
@Override public String toString() { return address.toString(); }
@Override public String toString() { return ipAddress.toString(); }
@Override public String toString() { return ipAddress.toString(); }
/** * Creates a new node identifier from an IpAddress ipAddress, a long port. * * @param ipAddress node IP address * @param port node port */ public OvsdbNodeId(IpAddress ipAddress, long port) { // TODO: port is currently not in use, need to remove it later super(checkNotNull(ipAddress, "ipAddress is not null").toString()); this.ipAddress = ipAddress.toString(); }
/** * Creates a new node identifier from an IpAddress ipAddress, a long port. * * @param ipAddress node IP address * @param port node port */ public OvsdbNodeId(IpAddress ipAddress, long port) { // TODO: port is currently not in use, need to remove it later super(checkNotNull(ipAddress, "ipAddress is not null").toString()); this.ipAddress = ipAddress.toString(); }
/** * Returns device URI from the given IP address. * * @param ipAddress device IP address * @return device URI */ public static URI uri(IpAddress ipAddress) { try { return new URI(SCHEME, ipAddress.toString(), null); } catch (URISyntaxException e) { return null; } }
/** * Returns device URI from the given IP address. * * @param ipAddress device IP address * @return device URI */ public static URI uri(IpAddress ipAddress) { try { return new URI(SCHEME, ipAddress.toString(), null); } catch (URISyntaxException e) { return null; } }
/** * Produces client URI from the given ip address. * * @param ipAddress ip of client * @return client URI */ public static URI uri(IpAddress ipAddress) { try { return new URI(SCHEME, ipAddress.toString(), null); } catch (URISyntaxException e) { return null; } } }
/** * Produces device URI from the given DPID long. * * @param ipAddress device ip address * @return device URI */ public static URI uri(IpAddress ipAddress) { try { return new URI(SCHEME, ipAddress.toString(), null); } catch (URISyntaxException e) { return null; } } }
@Override public String toString() { return toStringHelper(getClass()) .add("nbrIpAddress", nbrIpAddress.toString()) .add("priorityPresent", Boolean.toString(priorityPresent)) .toString(); // TODO: need to handle options } }
@Override /* * (non-Javadoc) * The format is "x.x.x.x/y" for IPv4 prefixes. * * @see java.lang.Object#toString() */ public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(address.toString()); builder.append("/"); builder.append(String.format("%d", prefixLength)); return builder.toString(); }
@Override public NetconfDevice getNetconfDevice(IpAddress ip, int port) { for (DeviceId info : netconfDeviceMap.keySet()) { if (info.uri().getSchemeSpecificPart().equals(ip.toString() + ":" + port)) { return netconfDeviceMap.get(info); } } return null; }
private JsonNode json(List<Node> nodes) { ObjectMapper mapper = new ObjectMapper(); ArrayNode result = mapper.createArrayNode(); for (Node node : nodes) { ObjectNode newNode = mapper.createObjectNode() .put("id", node.id().toString()) .put("ip", node.ip().toString()) .put("host", node.host()) .put("tcpPort", node.tcpPort()); result.add(newNode); } return result; }
private String getUrlString(DeviceId device, String request) { if (deviceMap.get(device).url() != null) { return deviceMap.get(device).protocol() + COLON + DOUBLESLASH + deviceMap.get(device).url() + request; } else { return deviceMap.get(device).protocol() + COLON + DOUBLESLASH + deviceMap.get(device).ip().toString() + COLON + deviceMap.get(device).port() + request; } }
@Override public ObjectNode encode(ControllerNode node, CodecContext context) { checkNotNull(node, "Controller node cannot be null"); ClusterService service = context.getService(ClusterService.class); return context.mapper().createObjectNode() .put("id", node.id().toString()) .put("ip", node.ip().toString()) .put("tcpPort", node.tcpPort()) .put("status", service.getState(node.id()).toString()) .put("lastUpdate", Long.toString(service.getLastUpdatedInstant(node.id()).toEpochMilli())) .put("humanReadableLastUpdate", service.localStatus(node.id())); }
private void addOrRemoveDevicesConfig() { SnmpProviderConfig cfg = netCfgService.getConfig(appId, SnmpProviderConfig.class); if (cfg != null) { try { cfg.getDevicesInfo().stream().forEach(info -> { SnmpDevice device = new DefaultSnmpDevice(info.ip().toString(), info.port(), info.username(), info.password()); buildDevice(device); }); } catch (ConfigException e) { log.error("Cannot read config error " + e); } } }
@Override protected String nonNullFormat(Object value) { if (value instanceof DefaultOpticalTunnelEndPoint) { DefaultOpticalTunnelEndPoint ep = (DefaultOpticalTunnelEndPoint) value; String e = safeOptional(ep.elementId()); String p = safeOptional(ep.portNumber()); return ep.type() + SLASH + e + SLASH + p; } else if (value instanceof IpTunnelEndPoint) { IpTunnelEndPoint cp = (IpTunnelEndPoint) value; return cp.ip().toString(); } return EMPTY; }