Search in sources :

Example 31 with IpAddress

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);
}
Also used : IpAddress(org.onlab.packet.IpAddress) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 32 with IpAddress

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);
}
Also used : IpAddress(org.onlab.packet.IpAddress) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 33 with IpAddress

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);
}
Also used : IpAddress(org.onlab.packet.IpAddress) OvsdbNodeId(org.onosproject.ovsdb.controller.OvsdbNodeId)

Example 34 with IpAddress

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();
}
Also used : RouteStore(org.onosproject.routeservice.RouteStore) FpmRecord(org.onosproject.routing.fpm.api.FpmRecord) DhcpRelayService(org.onosproject.dhcprelay.api.DhcpRelayService) IpAddress(org.onlab.packet.IpAddress) Route(org.onosproject.routeservice.Route) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 35 with IpAddress

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());
    }
}
Also used : Ip4Address(org.onlab.packet.Ip4Address) OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService) Network(org.openstack4j.model.network.Network) VlanId(org.onlab.packet.VlanId) Argument(org.apache.karaf.shell.api.action.Argument) Subnet(org.openstack4j.model.network.Subnet) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Lists(com.google.common.collect.Lists) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Router(org.openstack4j.model.network.Router) Completion(org.apache.karaf.shell.api.action.Completion) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) IpAddress(org.onlab.packet.IpAddress) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) Network(org.openstack4j.model.network.Network) Router(org.openstack4j.model.network.Router) ExternalPeerRouter(org.onosproject.openstacknetworking.api.ExternalPeerRouter) IpAddress(org.onlab.packet.IpAddress) Subnet(org.openstack4j.model.network.Subnet) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) OpenstackRouterService(org.onosproject.openstacknetworking.api.OpenstackRouterService)

Aggregations

IpAddress (org.onlab.packet.IpAddress)288 MacAddress (org.onlab.packet.MacAddress)63 VlanId (org.onlab.packet.VlanId)52 ConnectPoint (org.onosproject.net.ConnectPoint)48 Set (java.util.Set)46 DeviceId (org.onosproject.net.DeviceId)44 Logger (org.slf4j.Logger)40 Test (org.junit.Test)37 Collectors (java.util.stream.Collectors)36 Ethernet (org.onlab.packet.Ethernet)36 IpPrefix (org.onlab.packet.IpPrefix)36 HostId (org.onosproject.net.HostId)33 Host (org.onosproject.net.Host)32 Optional (java.util.Optional)30 HostLocation (org.onosproject.net.HostLocation)30 LoggerFactory (org.slf4j.LoggerFactory)30 ApplicationId (org.onosproject.core.ApplicationId)29 CoreService (org.onosproject.core.CoreService)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)28