use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class OvsdbQosConfig 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 < 2) {
return null;
}
IpAddress ipAddress = IpAddress.valueOf(splits[1]);
return new OvsdbNodeId(ipAddress, 0);
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class OvsdbQueueConfig 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);
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class OvsdbBridgeConfig 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 == null || splits.length < 1) {
return null;
}
IpAddress ipAddress = IpAddress.valueOf(splits[1]);
return new OvsdbNodeId(ipAddress, 0);
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class DhcpRelayWebResource method dhcpFpmDelete.
/**
* Deletes the fpm route from fpm record.
* Corresponding route from the route store
*
* @param prefix IpPrefix
* @return 204 NO CONTENT, 404; 401
*/
@DELETE
@Path("fpm/{prefix}")
public Response dhcpFpmDelete(@PathParam("prefix") String prefix) {
DhcpRelayService dhcpRelayService = get(DhcpRelayService.class);
RouteStore routeStore = get(RouteStore.class);
try {
// removes fpm route from fpm record
Optional<FpmRecord> fpmRecord = dhcpRelayService.removeFpmRecord(IpPrefix.valueOf(prefix));
if (fpmRecord.isPresent()) {
IpAddress nextHop = fpmRecord.get().nextHop();
Route route = new Route(Route.Source.DHCP, IpPrefix.valueOf(prefix), nextHop);
// removes DHCP route from route store
routeStore.removeRoute(route);
} else {
LOG.warn("fpmRecord is not present");
}
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException(ex);
}
return Response.noContent().build();
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class UpdateExternalPeerRouterVlanCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkAdminService osNetAdminService = get(OpenstackNetworkAdminService.class);
OpenstackRouterService osRouterService = get(OpenstackRouterService.class);
IpAddress externalPeerIpAddress = IpAddress.valueOf(IpAddress.Version.INET, Ip4Address.valueOf(ipAddress).toOctets());
if (osNetAdminService.externalPeerRouters().isEmpty()) {
print(NO_ELEMENT);
return;
} else if (osNetAdminService.externalPeerRouters().stream().noneMatch(router -> router.ipAddress().toString().equals(ipAddress))) {
print(NO_ELEMENT);
return;
}
Subnet subnet = osNetAdminService.subnets().stream().filter(s -> s.getGateway().equals(ipAddress)).findAny().orElse(null);
if (subnet == null) {
return;
}
Network network = osNetAdminService.network(subnet.getNetworkId());
if (network == null) {
return;
}
Router router = osRouterService.routers().stream().filter(r -> r.getExternalGatewayInfo().getNetworkId().equals(network.getId())).findAny().orElse(null);
if (router == null) {
return;
}
try {
if (vlanId.equals(NONE)) {
osNetAdminService.updateExternalPeerRouterVlan(externalPeerIpAddress, VlanId.NONE);
osNetAdminService.deriveExternalPeerRouterMac(router.getExternalGatewayInfo(), router, VlanId.NONE);
} else {
osNetAdminService.updateExternalPeerRouterVlan(externalPeerIpAddress, VlanId.vlanId(vlanId));
osNetAdminService.deriveExternalPeerRouterMac(router.getExternalGatewayInfo(), router, VlanId.vlanId(vlanId));
}
} catch (IllegalArgumentException e) {
log.error("Exception occurred because of {}", e.toString());
}
print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
List<ExternalPeerRouter> routers = Lists.newArrayList(osNetAdminService.externalPeerRouters());
for (ExternalPeerRouter r : routers) {
print(FORMAT, r.ipAddress(), r.macAddress().toString(), r.vlanId());
}
}
Aggregations