예제 #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);
  }
예제 #2
0
  @Before
  public void setUp() throws Exception {
    idGenerator = new TestIdGenerator();
    Intent.bindIdGenerator(idGenerator);

    applicationService = createMock(ApplicationService.class);

    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication(APP_NAME)).andReturn(APPID);
    replay(coreService);

    hostsAvailable = Sets.newHashSet();
    hostService = new TestHostService(hostsAvailable);

    intentService = new TestIntentService();

    TestIntentSynchronizer intentSynchronizer = new TestIntentSynchronizer(intentService);

    interfaceService = createMock(InterfaceService.class);
    interfaceService.addListener(anyObject(InterfaceListener.class));
    expectLastCall().anyTimes();
    addIntfConfig();

    vpls = new Vpls();
    vpls.applicationService = applicationService;
    vpls.coreService = coreService;
    vpls.hostService = hostService;
    vpls.intentService = intentService;
    vpls.interfaceService = interfaceService;
    vpls.intentSynchronizer = intentSynchronizer;
  }
예제 #3
0
  @Activate
  public void activate(ComponentContext context) {
    configService.registerProperties(getClass());

    idGenerator = coreService.getIdGenerator(FlowRuleService.FLOW_OP_TOPIC);

    local = clusterService.getLocalNode().id();

    messageHandlingExecutor =
        Executors.newFixedThreadPool(
            msgHandlerPoolSize, groupedThreads("onos/store/flow", "message-handlers"));

    registerMessageHandlers(messageHandlingExecutor);

    if (backupEnabled) {
      replicaInfoManager.addListener(flowTable);
      backupTask =
          backupSenderExecutor.scheduleWithFixedDelay(
              flowTable::backup, 0, backupPeriod, TimeUnit.MILLISECONDS);
    }

    deviceTableStats =
        storageService
            .<DeviceId, List<TableStatisticsEntry>>eventuallyConsistentMapBuilder()
            .withName("onos-flow-table-stats")
            .withSerializer(SERIALIZER_BUILDER)
            .withAntiEntropyPeriod(5, TimeUnit.SECONDS)
            .withTimestampProvider((k, v) -> new WallClockTimestamp())
            .withTombstonesDisabled()
            .build();
    deviceTableStats.addListener(tableStatsListener);

    logConfig("Started");
  }
예제 #4
0
  @Override
  public void init(DeviceId deviceId, PipelinerContext context) {
    log.debug("Initiate OLT pipeline");
    this.serviceDirectory = context.directory();
    this.deviceId = deviceId;

    flowRuleService = serviceDirectory.get(FlowRuleService.class);
    coreService = serviceDirectory.get(CoreService.class);
    groupService = serviceDirectory.get(GroupService.class);
    flowObjectiveStore = context.store();

    appId = coreService.registerApplication("org.onosproject.driver.OLTPipeline");

    pendingGroups =
        CacheBuilder.newBuilder()
            .expireAfterWrite(20, TimeUnit.SECONDS)
            .removalListener(
                (RemovalNotification<GroupKey, NextObjective> notification) -> {
                  if (notification.getCause() == RemovalCause.EXPIRED) {
                    fail(notification.getValue(), ObjectiveError.GROUPINSTALLATIONFAILED);
                  }
                })
            .build();

    groupService.addListener(new InnerGroupListener());
  }
예제 #5
0
파일: CordVtn.java 프로젝트: nskeeper/onos
  @Activate
  protected void activate() {
    appId = coreService.registerApplication("org.onosproject.cordvtn");
    ruleInstaller =
        new CordVtnRuleInstaller(
            appId,
            flowRuleService,
            deviceService,
            driverService,
            groupService,
            mastershipService,
            DEFAULT_TUNNEL);

    arpProxy = new CordVtnArpProxy(appId, packetService);
    packetService.addProcessor(packetProcessor, PacketProcessor.director(0));
    arpProxy.requestPacket();

    hostService.addListener(hostListener);
    hostProvider = hostProviderRegistry.register(this);

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

    log.info("Started");
  }
예제 #6
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);
 }
예제 #7
0
 @Activate
 public void activate() {
   appId = coreService.registerApplication(APP_NAME);
   providerService = providerRegistry.register(this);
   cfgService.registerConfigFactory(factory);
   cfgService.addListener(cfgLister);
   connectDevices();
   log.info("Started");
 }
예제 #8
0
 @Activate
 public void activate() {
   String nodeId = clusterService.getLocalNode().ip().toString();
   appId = coreService.registerApplication("org.onosproject.demo.installer." + nodeId);
   worker =
       Executors.newFixedThreadPool(
           1, new ThreadFactoryBuilder().setNameFormat("demo-app-worker").build());
   log.info("Started with Application ID {}", appId.id());
 }
 @Activate
 public void activate() {
   providerService = providerRegistry.register(this);
   appId = coreService.registerApplication(APP_NAME);
   cfgService.registerConfigFactory(factory);
   cfgService.addListener(cfgLister);
   controller.addDeviceListener(innerNodeListener);
   executor.execute(NetconfDeviceProvider.this::connectDevices);
   log.info("Started");
 }
예제 #10
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);
  }
  @Activate
  public void activate(ComponentContext context) {
    cfgService.registerProperties(getClass());
    appId = coreService.registerApplication("org.onosproject.fwd");

    packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2);
    readComponentConfiguration(context);
    requestPackests();

    log.info("Started with Application ID {}", appId.id());
  }
예제 #12
0
  @Activate
  public void activate(ComponentContext context) {
    componentConfigService.registerProperties(getClass());
    modified(context);

    appId = coreService.registerApplication(APP_NAME);

    if (enabled) {
      enable();
    }
  }
예제 #13
0
 @Activate
 protected void activate() {
   appId = coreService.registerApplication("org.onos.byon");
   /*
    * TODO Lab 6: Remove delegate and event sink
    *
    * 1. Add the listener registry to the event dispatcher using eventDispatcher.addSink()
    * 2. Set the delegate in the store
    */
   log.info("Started");
 }
예제 #14
0
  @Activate
  protected void activate() {
    appId = coreService.registerApplication("org.onosproject.openstackswitching");

    factories.forEach(cfgService::registerConfigFactory);
    packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
    deviceService.addListener(internalDeviceListener);
    cfgService.addListener(internalConfigListener);

    internalConfigListener.configureNetwork();

    log.info("Started");
  }
예제 #15
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);
      }
    }
  }
예제 #16
0
  @Activate
  public void activate(ComponentContext context) {
    appId = coreService.registerApplication("org.onosproject.provider.host");

    modified(context);
    providerService = providerRegistry.register(this);
    pktService.addProcessor(processor, 1);
    deviceService.addListener(deviceListener);

    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
    selectorBuilder.matchEthType(Ethernet.TYPE_ARP);
    pktService.requestPackets(selectorBuilder.build(), PacketPriority.CONTROL, appId);

    log.info("Started");
  }
예제 #17
0
  @Before
  public void setUp() {

    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication(appId.name())).andReturn(appId).anyTimes();
    replay(coreService);

    provider.cfgService = new ComponentConfigAdapter();
    provider.coreService = coreService;

    provider.providerRegistry = hostRegistry;
    provider.topologyService = topoService;
    provider.packetService = packetService;
    provider.deviceService = deviceService;
    provider.hostService = hostService;

    provider.activate(CTX_FOR_NO_REMOVE);
  }
예제 #18
0
  /**
   * 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());
  }
예제 #19
0
  @Override
  public NextObjective decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
      return null;
    }

    CoreService coreService = context.getService(CoreService.class);

    final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class);
    final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class);

    ObjectiveCodecHelper och = new ObjectiveCodecHelper();

    DefaultNextObjective.Builder baseBuilder = DefaultNextObjective.builder();
    final DefaultNextObjective.Builder builder =
        (DefaultNextObjective.Builder) och.decode(json, baseBuilder, context);

    // decode id
    JsonNode idJson = json.get(ID);
    checkNotNull(idJson);
    builder.withId(idJson.asInt());

    // decode application id
    ApplicationId appId = coreService.registerApplication(REST_APP_ID);
    builder.fromApp(appId);

    // decode type
    String typeStr = nullIsIllegal(json.get(TYPE), TYPE + MISSING_MEMBER_MESSAGE).asText();

    switch (typeStr) {
      case "HASHED":
        builder.withType(NextObjective.Type.HASHED);
        break;
      case "BROADCAST":
        builder.withType(NextObjective.Type.BROADCAST);
        break;
      case "FAILOVER":
        builder.withType(NextObjective.Type.FAILOVER);
        break;
      case "SIMPLE":
        builder.withType(NextObjective.Type.SIMPLE);
        break;
      default:
        log.warn(INVALID_TYPE_MESSAGE, typeStr);
        return null;
    }

    // decode treatments
    JsonNode treatmentsJson = json.get(TREATMENTS);
    checkNotNull(treatmentsJson);
    if (treatmentsJson != null) {
      IntStream.range(0, treatmentsJson.size())
          .forEach(
              i -> {
                ObjectNode treatmentJson = get(treatmentsJson, i);
                builder.addTreatment(trafficTreatmentCodec.decode(treatmentJson, context));
              });
    }

    // decode meta
    JsonNode metaJson = json.get(META);
    if (metaJson != null) {
      TrafficSelector trafficSelector = trafficSelectorCodec.decode((ObjectNode) metaJson, context);
      builder.withMeta(trafficSelector);
    }

    // decode operation
    String opStr = nullIsIllegal(json.get(OPERATION), OPERATION + MISSING_MEMBER_MESSAGE).asText();
    NextObjective nextObjective;

    switch (opStr) {
      case "ADD":
        nextObjective = builder.add();
        break;
      case "REMOVE":
        nextObjective = builder.remove();
        break;
      default:
        log.warn(INVALID_OP_MESSAGE, opStr);
        return null;
    }

    return nextObjective;
  }
예제 #20
0
 @Override
 public ApplicationId createSubject(String key) {
   return coreService.registerApplication(key);
 }
예제 #21
0
 @Activate
 public void activate(ComponentContext context) {
   appId = coreSerivice.registerApplication("org.onosproject.Mao.Mao-Ether-igmp");
   log.info("Mao Started, id: {}, name: {}", appId.id(), appId.name());
 }