Beispiel #1
0
  @Override
  protected void execute() {
    NetworkConfigService configService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);

    BgpConfig config = configService.addConfig(appId, BgpConfig.class);

    if (name != null) {
      BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
      if (speaker != null) {
        log.debug("Speaker already exists: {}", name);
        return;
      }
    }

    if (vlanId == null || vlanId.isEmpty()) {
      vlanIdObj = VlanId.NONE;
    } else {
      vlanIdObj = VlanId.vlanId(Short.valueOf(vlanId));
    }

    addSpeakerToConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());

    print(SPEAKER_ADD_SUCCESS);
  }
Beispiel #2
0
 @Before
 public void setUpIntentService() {
   final IntentService mockIntentService = new IntentServiceAdapter();
   context.registerService(IntentService.class, mockIntentService);
   context.registerService(CoreService.class, mockCoreService);
   expect(mockCoreService.getAppId(appId.name())).andReturn(appId);
   replay(mockCoreService);
 }
Beispiel #3
0
  @Activate
  protected void active() {
    local = clusterService.getLocalNode().id();
    appId = coreService.getAppId(CordVtnService.CORDVTN_APP_ID);

    configService.addListener(configListener);
    configRegistry.registerConfigFactory(configFactory);

    leadershipService.addListener(leadershipListener);
    leadershipService.runForLeadership(CordVtnService.CORDVTN_APP_ID);
  }
Beispiel #4
0
  @Override
  protected void execute() {
    IntentService intentService = get(IntentService.class);
    CoreService coreService = get(CoreService.class);

    ApplicationId appId = appId();
    if (!isNullOrEmpty(applicationIdString)) {
      appId = coreService.getAppId(applicationIdString);
      if (appId == null) {
        print("Cannot find application Id %s", applicationIdString);
        return;
      }
    }

    if (isNullOrEmpty(keyString)) {
      for (Intent intent : intentService.getIntents()) {
        if (intent.appId().equals(appId)) {
          removeIntent(intentService, intent);
        }
      }

    } else {
      final Key key;
      if (keyString.startsWith("0x")) {
        // The intent uses a LongKey
        keyString = keyString.replaceFirst("0x", "");
        key = Key.of(new BigInteger(keyString, 16).longValue(), appId);
      } else {
        // The intent uses a StringKey
        key = Key.of(keyString, appId);
      }

      Intent intent = intentService.getIntent(key);
      if (intent != null) {
        removeIntent(intentService, intent);
      }
    }
  }
  /**
   * Create a variable of the SwitchPacketProcessor class using the PacketProcessor defined above.
   * Activates the app.
   */
  @Activate
  protected void activate() {
    log.info("Started");
    appId =
        coreService.getAppId(
            "org.onosproject.learningswitch"); // equal to the name shown in pom.xml file

    processor = new SwitchPacketProcesser();
    packetService.addProcessor(processor, PacketProcessor.director(3));

    /*
     * Restricts packet types to IPV4 and ARP by only requesting those types.
     */
    packetService.requestPackets(
        DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).build(),
        PacketPriority.REACTIVE,
        appId,
        Optional.empty());
    packetService.requestPackets(
        DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_ARP).build(),
        PacketPriority.REACTIVE,
        appId,
        Optional.empty());
  }