blob: 562279feb50c30bffbf446b5a7baa40679861573 [file] [log] [blame]
Jonathan Hart3604bbc2016-01-07 11:16:42 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hart3604bbc2016-01-07 11:16:42 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.vrouter;
17
18import com.google.common.collect.ImmutableList;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
Charles Chan0214ded2016-11-18 17:48:37 -080024import org.onosproject.cfg.ComponentConfigService;
Jonathan Hart3604bbc2016-01-07 11:16:42 -080025import org.onosproject.core.ApplicationId;
26import org.onosproject.core.CoreService;
27import org.onosproject.incubator.component.ComponentService;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
31import java.util.List;
32
33/**
34 * Virtual router (vRouter) application.
35 */
36@Component(immediate = true)
37public class Vrouter {
38
39 private final Logger log = LoggerFactory.getLogger(getClass());
40
41 private static final String APP_NAME = "org.onosproject.vrouter";
42
43 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
44 protected CoreService coreService;
45
46 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
47 protected ComponentService componentService;
48
Charles Chan0214ded2016-11-18 17:48:37 -080049 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
50 protected ComponentConfigService componentConfigService;
51
Jonathan Hart3604bbc2016-01-07 11:16:42 -080052 private ApplicationId appId;
53
54 private final List<String> components = ImmutableList.<String>builder()
55 .add("org.onosproject.routing.fpm.FpmManager")
Jonathan Hart3604bbc2016-01-07 11:16:42 -080056 .add("org.onosproject.routing.impl.SingleSwitchFibInstaller")
Jonathan Hart6344f572015-12-15 08:26:25 -080057 .add("org.onosproject.routing.impl.ControlPlaneRedirectManager")
Jonathan Hart63eeac32016-06-20 15:55:16 -070058 .add("org.onosproject.routing.impl.DirectHostManager")
Jonathan Hart3604bbc2016-01-07 11:16:42 -080059 .build();
60
Jonathan Hart63eeac32016-06-20 15:55:16 -070061
Jonathan Hart3604bbc2016-01-07 11:16:42 -080062 @Activate
63 protected void activate() {
64 appId = coreService.registerApplication(APP_NAME);
65
Charles Chan0214ded2016-11-18 17:48:37 -080066 componentConfigService.preSetProperty(
67 "org.onosproject.incubator.store.routing.impl.RouteStoreImpl",
68 "distributed", "true");
69
Jonathan Hart3604bbc2016-01-07 11:16:42 -080070 components.forEach(name -> componentService.activate(appId, name));
71
72 log.info("Started");
73 }
74
75 @Deactivate
76 protected void deactivate() {
Charles Chan0214ded2016-11-18 17:48:37 -080077 componentConfigService.preSetProperty(
78 "org.onosproject.incubator.store.routing.impl.RouteStoreImpl",
79 "distributed", "false");
80
Jonathan Hart3604bbc2016-01-07 11:16:42 -080081 log.info("Stopped");
82 }
83
84}