Package net.floodlightcontroller.devicemanager

Examples of net.floodlightcontroller.devicemanager.IDeviceService


            "hex as AA:BB:CC:DD:EE:FF:00:11";
    public static final String PORT_ERROR =
            "Invalid Port: must be a positive integer";
   
    public Iterator<? extends IDevice> getDevices() {
        IDeviceService deviceManager =
                (IDeviceService)getContext().getAttributes().
                    get(IDeviceService.class.getCanonicalName())
               
        Long macAddress = null;
        Short vlan = null;
        Integer ipv4Address = null;
        Long switchDPID = null;
        Integer switchPort = null;
       
        Form form = getQuery();
        String macAddrStr = form.getFirstValue("mac", true);
        String vlanStr = form.getFirstValue("vlan", true);
        String ipv4Str = form.getFirstValue("ipv4", true);
        String dpid = form.getFirstValue("dpid", true);
        String port = form.getFirstValue("port", true);
       
        if (macAddrStr != null) {
            try {
                macAddress = HexString.toLong(macAddrStr);
            } catch (Exception e) {
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST, MAC_ERROR);
                return null;
            }
        }
        if (vlanStr != null) {
            try {
                vlan = Short.parseShort(vlanStr);
                if (vlan > 4095 || vlan < 0) {
                    setStatus(Status.CLIENT_ERROR_BAD_REQUEST, VLAN_ERROR);
                    return null;
                }
            } catch (Exception e) {
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST, VLAN_ERROR);
                return null;
            }
        }
        if (ipv4Str != null) {
            try {
                ipv4Address = IPv4.toIPv4Address(ipv4Str);
            } catch (Exception e) {
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST, IPV4_ERROR);
                return null;
            }
        }
        if (dpid != null) {
            try {
                switchDPID = HexString.toLong(dpid);
            } catch (Exception e) {
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST, DPID_ERROR);
                return null;
            }
        }
        if (port != null) {
            try {
                switchPort = Integer.parseInt(port);
                if (switchPort < 0) {
                    setStatus(Status.CLIENT_ERROR_BAD_REQUEST, PORT_ERROR);
                    return null;
                }
            } catch (Exception e) {
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST, PORT_ERROR);
                return null;
            }
        }
       
        @SuppressWarnings("unchecked")
        Iterator<Device> diter = (Iterator<Device>)
                deviceManager.queryDevices(macAddress,
                                           vlan,
                                           ipv4Address,
                                           switchDPID,
                                           switchPort);
       
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.devicemanager.IDeviceService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.