Exemplo n.º 1
0
 @Override
 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
   // 模块初始化自身内容
   restApi = context.getServiceImpl(IRestApiService.class);
   floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
   deviceService = context.getServiceImpl(IDeviceService.class);
   linkService = context.getServiceImpl(ILinkDiscoveryService.class);
   topologyService = context.getServiceImpl(ITopologyService.class);
   logger = LoggerFactory.getLogger(DebugModule.class);
 }
Exemplo n.º 2
0
  @Override
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    logger = LoggerFactory.getLogger(FailureDiscovery.class);
    topologyService = context.getServiceImpl(ITopologyService.class);
    this.massivefailurerecoveryservice =
        context.getServiceImpl(IMassiveFailureRecoveryService.class);

    // We create this here because there is no ordering guarantee
    failureDiscoveryListeners = new ArrayList<IFailureDiscoveryListener>();
  }
Exemplo n.º 3
0
  @Override
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    topologyservice = context.getServiceImpl(ITopologyService.class);

    log = LoggerFactory.getLogger(VideoFilter.class);
    messageDamper =
        new OFMessageDamper(
            OFMESSAGE_DAMPER_CAPACITY, EnumSet.of(OFType.FLOW_MOD), OFMESSAGE_DAMPER_TIMEOUT);
    topology = context.getServiceImpl(ITopologyService.class);
    counterStore = context.getServiceImpl(ICounterStoreService.class);
  }
  /** Loads dependencies and initializes data structures. */
  @Override
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    log.info(String.format("Initializing %s...", MODULE_NAME));
    Map<String, String> config = context.getConfigParams(this);
    table = Byte.parseByte(config.get("table"));

    this.floodlightProv = context.getServiceImpl(IFloodlightProviderService.class);
    this.linkDiscProv = context.getServiceImpl(ILinkDiscoveryService.class);
    this.deviceProv = context.getServiceImpl(IDeviceService.class);

    this.knownHosts = new ConcurrentHashMap<IDevice, Host>();
  }
  @Override
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    linkDiscovery = context.getServiceImpl(ILinkDiscoveryService.class);
    threadPool = context.getServiceImpl(IThreadPoolService.class);
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    restApi = context.getServiceImpl(IRestApiService.class);

    switchPorts = new HashMap<Long, Set<Short>>();
    switchPortLinks = new HashMap<NodePortTuple, Set<Link>>();
    directLinks = new HashMap<NodePortTuple, Set<Link>>();
    portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>();
    tunnelLinks = new HashMap<NodePortTuple, Set<Link>>();
    topologyAware = new ArrayList<ITopologyListener>();
    ldUpdates = new LinkedBlockingQueue<LDUpdate>();
    appliedUpdates = new ArrayList<LDUpdate>();
    clearCurrentTopology();
  }
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    FloodlightModuleContext cntx = new FloodlightModuleContext();
    tFSFW = new TestFlowSpaceFirewall();
    cntx.addConfigParam(tFSFW, "configFile", "src/test/resources/good_config.xml");
    MockThreadPoolService tp = new MockThreadPoolService();
    RestApiServer restApi = new RestApiServer();
    cntx.addService(IRestApiService.class, restApi);
    cntx.addService(IThreadPoolService.class, tp);
    cntx.addService(IFlowSpaceFirewallService.class, tFSFW);
    cntx.addService(IStorageSourceService.class, new MemoryStorageSource());
    cntx.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
    restApi.init(cntx);
    tp.init(cntx);
    tFSFW.init(cntx);
    restApi.startUp(cntx);
    tp.startUp(cntx);
    tFSFW.startUp(cntx);

    IOFSwitch sw1 = createMockSwitch(1L);
    IOFSwitch sw2 = createMockSwitch(2L);
    Map<Long, IOFSwitch> switches = new HashMap<Long, IOFSwitch>();
    switches.put(1L, sw1);
    switches.put(2L, sw2);
    getMockFloodlightProvider().setSwitches(switches);
    replay(sw1, sw2);
  }
  @Override
  public void startUp(FloodlightModuleContext context) {
    floodlightProvider.addOFSwitchListener(this);
    Map<String, String> configOptions = context.getConfigParams(this);

    try {
      ROOT_NODE_ROOT_OVS_DPID = configOptions.get("root-node-root-ovs-dpid");
      ROOT_NODE_WIFI_OVS_DPID = configOptions.get("root-node-wifi-ovs-dpid");

      ROOT_NODE_WIMAX_OVS_DPID = configOptions.get("root-node-wimax-ovs-dpid");
      WIFI_NODE_WIFI_OVS_DPID = configOptions.get("wifi-node-wifi-ovs-dpid");
      WIFI_NODE_TUNNEL_OVS_DPID = configOptions.get("wifi-node-tunnel-ovs-dpid");
      ROOT_NODE_ROOT_OVS_IP = IPv4.toIPv4Address(configOptions.get("root-node-root-ovs-ip"));
      ROOT_NODE_WIFI_OVS_PATCH =
          Short.parseShort(configOptions.get("root-node-wifi-ovs-patch-port"));
      ROOT_NODE_WIFI_OVS_TUNNEL =
          Short.parseShort(configOptions.get("root-node-wifi-ovs-tunnel-port"));
      ROOT_NODE_WIMAX_OVS_PATCH =
          Short.parseShort(configOptions.get("root-node-wimax-ovs-patch-port"));
      ROOT_NODE_WIMAX_OVS_VLAN =
          Short.parseShort(configOptions.get("root-node-wimax-ovs-vlan-port"));
      ROOT_NODE_ROOT_OVS_WIFI_PATCH =
          Short.parseShort(configOptions.get("root-node-root-ovs-wifi-patch-port"));
      ROOT_NODE_ROOT_OVS_WIMAX_PATCH =
          Short.parseShort(configOptions.get("root-node-root-ovs-wimax-patch-port"));
      WIFI_NODE_WIFI_OVS_PATCH =
          Short.parseShort(configOptions.get("wifi-node-wifi-ovs-patch-port"));
      WIFI_NODE_TUNNEL_OVS_TUNNEL =
          Short.parseShort(configOptions.get("wifi-node-tunnel-ovs-tunnel-port"));
      WIFI_NODE_TUNNEL_OVS_PATCH =
          Short.parseShort(configOptions.get("wifi-node-tunnel-ovs-patch-port"));
    } catch (IllegalArgumentException ex) {
      log.error("Incorrect DHCP Switch Flow Setter configuration options (illegal arg)", ex);
      throw ex;
    } catch (NullPointerException ex) {
      log.error("Incorrect DHCP Switch Flow Setter configuration options (null ptr)", ex);
      throw ex;
    }
  }
Exemplo n.º 8
0
  @Override
  @LogMessageDocs({
    @LogMessageDoc(
        level = "WARN",
        message = "Error parsing flow idle timeout, " + "using default of {number} seconds",
        explanation = "The properties file contains an invalid " + "flow idle timeout",
        recommendation = "Correct the idle timeout in the " + "properties file."),
    @LogMessageDoc(
        level = "WARN",
        message = "Error parsing flow hard timeout, " + "using default of {number} seconds",
        explanation = "The properties file contains an invalid " + "flow hard timeout",
        recommendation = "Correct the hard timeout in the " + "properties file."),
  })
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    super.init();
    this.floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    this.deviceManager = context.getServiceImpl(IDeviceService.class);
    this.routingEngine = context.getServiceImpl(IRoutingService.class);
    this.topology = context.getServiceImpl(ITopologyService.class);
    this.counterStore = context.getServiceImpl(ICounterStoreService.class);

    // read our config options
    Map<String, String> configOptions = context.getConfigParams(this);
    try {
      String idleTimeout = configOptions.get("idletimeout");
      if (idleTimeout != null) {
        FLOWMOD_DEFAULT_IDLE_TIMEOUT = Short.parseShort(idleTimeout);
      }
    } catch (NumberFormatException e) {
      log.warn(
          "Error parsing flow idle timeout, " + "using default of {} seconds",
          FLOWMOD_DEFAULT_IDLE_TIMEOUT);
    }
    try {
      String hardTimeout = configOptions.get("hardtimeout");
      if (hardTimeout != null) {
        FLOWMOD_DEFAULT_HARD_TIMEOUT = Short.parseShort(hardTimeout);
      }
    } catch (NumberFormatException e) {
      log.warn(
          "Error parsing flow hard timeout, " + "using default of {} seconds",
          FLOWMOD_DEFAULT_HARD_TIMEOUT);
    }
    log.debug("FlowMod idle timeout set to {} seconds", FLOWMOD_DEFAULT_IDLE_TIMEOUT);
    log.debug("FlowMod hard timeout set to {} seconds", FLOWMOD_DEFAULT_HARD_TIMEOUT);
  }
Exemplo n.º 9
0
 @Override
 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
   floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
   restApi = context.getServiceImpl(IRestApiService.class);
 }
 @Override
 public void init(FloodlightModuleContext context) throws FloodlightModuleException {
   floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
   log = LoggerFactory.getLogger(DHCPServer.class);
   sfp = context.getServiceImpl(IStaticFlowEntryPusherService.class);
 }
Exemplo n.º 11
0
  public void doSetUp(HARole role) throws Exception {
    super.setUp();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    FloodlightProvider cm = new FloodlightProvider();

    fmc.addConfigParam(cm, "role", role.toString());
    controller = (Controller) cm.getServiceImpls().get(IFloodlightProviderService.class);
    fmc.addService(IFloodlightProviderService.class, controller);

    MemoryStorageSource memstorage = new MemoryStorageSource();
    fmc.addService(IStorageSourceService.class, memstorage);

    RestApiServer restApi = new RestApiServer();
    fmc.addService(IRestApiService.class, restApi);

    ThreadPool threadPool = new ThreadPool();
    fmc.addService(IThreadPoolService.class, threadPool);

    MockSwitchManager switchService = new MockSwitchManager();
    fmc.addService(IOFSwitchService.class, switchService);

    PktInProcessingTime ppt = new PktInProcessingTime();
    fmc.addService(IPktInProcessingTimeService.class, ppt);

    // TODO: should mock IDebugCounterService and make sure
    // the expected counters are updated.
    DebugCounterServiceImpl debugCounterService = new DebugCounterServiceImpl();
    fmc.addService(IDebugCounterService.class, debugCounterService);

    DebugEventService debugEventService = new DebugEventService();
    fmc.addService(IDebugEventService.class, debugEventService);

    IShutdownService shutdownService = createMock(IShutdownService.class);
    shutdownService.registerShutdownListener(anyObject(IShutdownListener.class));
    expectLastCall().anyTimes();
    replay(shutdownService);
    fmc.addService(IShutdownService.class, shutdownService);
    verify(shutdownService);

    tp = new MockThreadPoolService();
    fmc.addService(IThreadPoolService.class, tp);

    syncService = new MockSyncService();
    fmc.addService(ISyncService.class, syncService);

    ppt.init(fmc);
    restApi.init(fmc);
    threadPool.init(fmc);
    memstorage.init(fmc);
    tp.init(fmc);
    debugCounterService.init(fmc);
    debugEventService.init(fmc);
    syncService.init(fmc);
    cm.init(fmc);

    ppt.startUp(fmc);
    restApi.startUp(fmc);
    threadPool.startUp(fmc);
    memstorage.startUp(fmc);
    tp.startUp(fmc);
    debugCounterService.startUp(fmc);
    debugEventService.startUp(fmc);
    syncService.startUp(fmc);
    cm.startUp(fmc);

    testPacket =
        new Ethernet()
            .setSourceMACAddress("00:44:33:22:11:00")
            .setDestinationMACAddress("00:11:22:33:44:55")
            .setEtherType(EthType.ARP)
            .setPayload(
                new ARP()
                    .setHardwareType(ARP.HW_TYPE_ETHERNET)
                    .setProtocolType(ARP.PROTO_TYPE_IP)
                    .setHardwareAddressLength((byte) 6)
                    .setProtocolAddressLength((byte) 4)
                    .setOpCode(ARP.OP_REPLY)
                    .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
                    .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
                    .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
                    .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
    byte[] testPacketSerialized = testPacket.serialize();

    // The specific factory can be obtained from the switch, but we don't have one
    pi =
        (OFPacketIn)
            factory
                .buildPacketIn()
                .setBufferId(OFBufferId.NO_BUFFER)
                .setInPort(OFPort.of(1))
                .setData(testPacketSerialized)
                .setReason(OFPacketInReason.NO_MATCH)
                .setTotalLen(testPacketSerialized.length)
                .build();
  }