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);
  }
  /** Tests a corner case, when there is no BGP speakers in the configuration. */
  @Test
  public void testNullBgpSpeakers() {
    reset(bgpConfig);
    expect(bgpConfig.bgpSpeakers()).andReturn(Collections.emptySet()).anyTimes();
    replay(bgpConfig);

    // We don't expect any intents in this case
    reset(intentSynchronizer);
    replay(intentSynchronizer);
    peerConnectivityManager.start();
    verify(intentSynchronizer);
  }
  /** Initializes peer connectivity testing environment. */
  private void initPeerConnectivity() {
    expect(bgpConfig.bgpSpeakers()).andReturn(bgpSpeakers).anyTimes();
    replay(bgpConfig);
    expect(networkConfigService.getConfig(APPID, BgpConfig.class)).andReturn(bgpConfig).anyTimes();
    replay(networkConfigService);
    replay(interfaceService);

    intentSynchronizer = createMock(IntentSynchronizationService.class);
    replay(intentSynchronizer);

    peerConnectivityManager =
        new PeerConnectivityManager(
            APPID, intentSynchronizer, networkConfigService, CONFIG_APP_ID, interfaceService);
  }
Beispiel #4
0
  /**
   * Adds the speaker to the BgpConfig service.
   *
   * @param config the BGP configuration
   */
  private void addSpeakerToConf(BgpConfig config) {
    log.debug("Adding new speaker to configuration: {}", name);
    BgpConfig.BgpSpeakerConfig speaker = getSpeaker();

    config.addSpeaker(speaker);
  }