use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class HostEventConverter method buildHostProtoMessage.
private HostNotificationProto buildHostProtoMessage(HostEvent hostEvent) {
HostNotificationProto.Builder notificationBuilder = HostNotificationProto.newBuilder();
HostProto hostCore = HostProto.newBuilder().setHostId(HostIdProtoTranslator.translate(hostEvent.subject().id())).setConfigured(hostEvent.subject().configured()).addAllIpAddresses(hostEvent.subject().ipAddresses().stream().map(IpAddress::toString).collect(Collectors.toList())).setLocation(HostLocationProtoTranslator.translate(hostEvent.subject().location())).setVlan(hostEvent.subject().vlan().toShort()).putAllAnnotations(AnnotationsTranslator.asMap(hostEvent.subject().annotations())).build();
notificationBuilder.setHostEventType(getProtoType(hostEvent)).setHost(hostCore);
return notificationBuilder.build();
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class KubevirtIpPool method getRangedIps.
/**
* Obtains the IP address list from the given start and end range.
*
* @param start start range
* @param end end range
* @return IP address list from the given start and end range
* @throws AddressStringException exception
*/
public Set<IpAddress> getRangedIps(String start, String end) throws AddressStringException {
Set<IpAddress> ips = new HashSet<>();
IPAddress lower = new IPAddressString(start).toAddress();
IPAddress upper = new IPAddressString(end).toAddress();
IPAddressSeqRange range = lower.toSequentialRange(upper);
for (IPAddress addr : range.getIterable()) {
ips.add(IpAddress.valueOf(addr.toString()));
}
return ips;
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class ScaleTestManager method createRoutes.
// Creates the specified number of random routes. Such routes are generated
// using random IP prefices with next hop being an IP address of a randomly
// chosen hosts.
private void createRoutes(int routeCount) {
List<Host> hosts = ImmutableList.copyOf(hostAdminService.getHosts());
ImmutableSet.Builder<Route> routes = ImmutableSet.builder();
for (int i = 0; i < routeCount; i++) {
IpPrefix prefix = randomIp().toIpPrefix();
IpAddress nextHop = randomIp(hosts);
routes.add(new Route(Route.Source.STATIC, prefix, nextHop));
}
routeAdminService.update(routes.build());
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class BasicHostOperator method combine.
/**
* Generates a HostDescription containing fields from a HostDescription and
* a HostConfig.
*
* @param cfg the host config entity from network config
* @param descr a HostDescription
* @return HostDescription based on both sources
*/
public static HostDescription combine(BasicHostConfig cfg, HostDescription descr) {
if (cfg == null || descr == null) {
return descr;
}
Set<HostLocation> locations = descr.locations();
Set<HostLocation> cfgLocations = cfg.locations();
if (cfgLocations != null) {
locations = cfgLocations.stream().map(hostLocation -> new HostLocation(hostLocation, System.currentTimeMillis())).collect(Collectors.toSet());
}
Set<HostLocation> auxLocations = descr.auxLocations();
Set<HostLocation> cfgAuxLocations = cfg.auxLocations();
if (cfgAuxLocations != null) {
auxLocations = cfgAuxLocations.stream().map(hostLocation -> new HostLocation(hostLocation, System.currentTimeMillis())).collect(Collectors.toSet());
}
Set<IpAddress> ipAddresses = descr.ipAddress();
Set<IpAddress> cfgIpAddresses = cfg.ipAddresses();
if (cfgIpAddresses != null) {
ipAddresses = cfgIpAddresses;
}
SparseAnnotations sa = combine(cfg, descr.annotations());
return new DefaultHostDescription(descr.hwAddress(), descr.vlan(), locations, auxLocations, ipAddresses, descr.innerVlan(), descr.tpid(), descr.configured(), sa);
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class OvsdbPortConfig method changeDeviceIdToNodeId.
// OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP)
// is used in the core. So DeviceId need be changed to OvsdbNodeId.
private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
String[] splits = deviceId.toString().split(":");
if (splits.length < 1) {
return null;
}
IpAddress ipAddress = IpAddress.valueOf(splits[1]);
return new OvsdbNodeId(ipAddress, 0);
}
Aggregations