Search in sources :

Example 36 with ApplicationId

use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.

the class DistributedK8sNetworkPolicyStore method activate.

@Activate
protected void activate() {
    ApplicationId appId = coreService.registerApplication(APP_ID);
    networkPolicyStore = storageService.<String, NetworkPolicy>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_NETWORK_POLICY)).withName("k8s-network-policy-store").withApplicationId(appId).build();
    networkPolicyStore.addListener(networkPolicyMapListener);
    log.info("Started");
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate)

Example 37 with ApplicationId

use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.

the class DistributedK8sServiceStore method activate.

@Activate
protected void activate() {
    ApplicationId appId = coreService.registerApplication(APP_ID);
    serviceStore = storageService.<String, Service>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_SERVICE)).withName("k8s-service-store").withApplicationId(appId).build();
    serviceStore.addListener(serviceMapListener);
    log.info("Started");
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate)

Example 38 with ApplicationId

use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.

the class ReactiveRoutingConfiguration method setUpConfiguration.

/**
 * Set up reactive routing information from configuration.
 */
private void setUpConfiguration() {
    ReactiveRoutingConfig config = configService.getConfig(coreService.registerApplication(ReactiveRoutingConfigurationService.REACTIVE_ROUTING_APP_ID), ReactiveRoutingConfigurationService.CONFIG_CLASS);
    if (config == null) {
        log.warn("No reactive routing config available!");
        return;
    }
    for (LocalIpPrefixEntry entry : config.localIp4PrefixEntries()) {
        localPrefixTable4.put(createBinaryString(entry.ipPrefix()), entry);
        gatewayIpAddresses.add(entry.getGatewayIpAddress());
        log.info("adding local IPv4 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
    }
    for (LocalIpPrefixEntry entry : config.localIp6PrefixEntries()) {
        localPrefixTable6.put(createBinaryString(entry.ipPrefix()), entry);
        gatewayIpAddresses.add(entry.getGatewayIpAddress());
        log.info("adding local IPv6 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
    }
    virtualGatewayMacAddress = config.virtualGatewayMacAddress();
    log.info("virtual gateway MAC: {}", virtualGatewayMacAddress);
    // Setup BGP peer connect points
    ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
    if (routerAppId == null) {
        log.info("Router application ID is null!");
        return;
    }
    BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class);
    if (bgpConfig == null) {
        log.info("BGP config is null!");
        return;
    } else {
        bgpPeerConnectPoints = bgpConfig.bgpSpeakers().stream().flatMap(speaker -> speaker.peers().stream()).map(peer -> interfaceService.getMatchingInterface(peer)).filter(Objects::nonNull).map(Interface::connectPoint).collect(Collectors.toSet());
    }
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Interface(org.onosproject.net.intf.Interface) RouteTools.createBinaryString(org.onosproject.routeservice.RouteTools.createBinaryString) DefaultByteArrayNodeFactory(com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory) CoreService(org.onosproject.core.CoreService) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LoggerFactory(org.slf4j.LoggerFactory) InterfaceService(org.onosproject.net.intf.InterfaceService) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SubjectFactories(org.onosproject.net.config.basics.SubjectFactories) ApplicationId(org.onosproject.core.ApplicationId) Activate(org.osgi.service.component.annotations.Activate) IpAddress(org.onlab.packet.IpAddress) RoutingService(org.onosproject.routing.RoutingService) Ip6Address(org.onlab.packet.Ip6Address) ImmutableSet(com.google.common.collect.ImmutableSet) Ip4Address(org.onlab.packet.Ip4Address) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) BgpConfig(org.onosproject.routing.config.BgpConfig) Collectors(java.util.stream.Collectors) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) ConfigFactory(org.onosproject.net.config.ConfigFactory) InvertedRadixTree(com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree) ConcurrentInvertedRadixTree(com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) IpPrefix(org.onlab.packet.IpPrefix) BgpConfig(org.onosproject.routing.config.BgpConfig) ApplicationId(org.onosproject.core.ApplicationId) Interface(org.onosproject.net.intf.Interface)

Example 39 with ApplicationId

use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.

the class RouteConfigTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream jsonStream = RouteConfigTest.class.getResourceAsStream("/route-config.json");
    ApplicationId subject = new TestApplicationId(KEY);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new RouteConfig();
    config.init(subject, KEY, jsonNode, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) TestApplicationId(org.onosproject.TestApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) TestApplicationId(org.onosproject.TestApplicationId) ApplicationId(org.onosproject.core.ApplicationId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 40 with ApplicationId

use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.

the class FlowsListCommand method printFlows.

/**
 * Prints flows.
 *
 * @param d     the device
 * @param flows the set of flows for that device
 * @param coreService core system service
 */
protected void printFlows(Device d, List<FlowEntry> flows, CoreService coreService) {
    List<FlowEntry> filteredFlows = filterFlows(flows);
    boolean empty = filteredFlows == null || filteredFlows.isEmpty();
    print("deviceId=%s, flowRuleCount=%d", d.id(), empty ? 0 : filteredFlows.size());
    if (empty || countOnly) {
        return;
    }
    for (FlowEntry f : filteredFlows) {
        if (shortOutput) {
            print(SHORT_FORMAT, f.state(), f.bytes(), f.packets(), f.table(), f.priority(), f.selector().criteria(), printTreatment(f.treatment()));
        } else {
            ApplicationId appId = coreService.getAppId(f.appId());
            print(LONG_FORMAT, Long.toHexString(f.id().value()), f.state(), f.bytes(), f.packets(), f.life(), f.liveType(), f.priority(), f.table(), appId != null ? appId.name() : "<none>", f.selector().criteria(), f.treatment());
        }
    }
}
Also used : ApplicationId(org.onosproject.core.ApplicationId) FlowEntry(org.onosproject.net.flow.FlowEntry)

Aggregations

ApplicationId (org.onosproject.core.ApplicationId)138 CoreService (org.onosproject.core.CoreService)36 Activate (org.osgi.service.component.annotations.Activate)36 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)25 Path (javax.ws.rs.Path)21 Produces (javax.ws.rs.Produces)16 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)15 GET (javax.ws.rs.GET)14 Test (org.junit.Test)13 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)11 FlowRuleService (org.onosproject.net.flow.FlowRuleService)11 TrafficSelector (org.onosproject.net.flow.TrafficSelector)11 Intent (org.onosproject.net.intent.Intent)11 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 InputStream (java.io.InputStream)9 DeviceId (org.onosproject.net.DeviceId)9 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 IntentService (org.onosproject.net.intent.IntentService)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8