blob: 274669c4ef9bad817139d664df0e1064d2e777bf [file] [log] [blame]
Thejaswi N K0db36e72016-02-02 22:10:54 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
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.provider.bgp.flow.impl;
17
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.bgp.controller.BgpController;
24import org.onosproject.cfg.ComponentConfigService;
25import org.onosproject.core.ApplicationId;
26import org.onosproject.net.flow.FlowRule;
27import org.onosproject.net.flow.FlowRuleBatchOperation;
28import org.onosproject.net.flow.FlowRuleProvider;
29import org.onosproject.net.flow.FlowRuleProviderRegistry;
30import org.onosproject.net.flow.FlowRuleProviderService;
31import org.onosproject.net.provider.AbstractProvider;
32import org.onosproject.net.provider.ProviderId;
33import org.osgi.service.component.ComponentContext;
34import org.slf4j.Logger;
35
36import static org.slf4j.LoggerFactory.getLogger;
37
38/**
39 * Bgp Flow provider.
40 */
41@Component(immediate = true)
42public class BgpFlowRuleProvider extends AbstractProvider
43 implements FlowRuleProvider {
44
45 private final Logger log = getLogger(getClass());
46
47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 protected FlowRuleProviderRegistry providerRegistry;
49
50 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 protected ComponentConfigService cfgService;
52
53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 protected BgpController bgpController;
55
56 private FlowRuleProviderService providerService;
57
58 /**
59 * Creates an BgpFlow host provider.
60 */
61 public BgpFlowRuleProvider() {
62 super(new ProviderId("bgp", "org.onosproject.provider.bgp"));
63 }
64
65 @Activate
66 public void activate(ComponentContext context) {
67 cfgService.registerProperties(getClass());
68 providerService = providerRegistry.register(this);
69 }
70
71 @Deactivate
72 public void deactivate(ComponentContext context) {
73 cfgService.unregisterProperties(getClass(), false);
74 providerRegistry.unregister(this);
75 providerService = null;
76 }
77
78 @Override
79 public void applyFlowRule(FlowRule... flowRules) {
80 for (FlowRule flowRule : flowRules) {
81 applyRule(flowRule);
82 }
83 }
84
85 private void applyRule(FlowRule flowRule) {
86 //TODO
87 }
88
89 @Override
90 public void removeFlowRule(FlowRule... flowRules) {
91 for (FlowRule flowRule : flowRules) {
92 removeRule(flowRule);
93 }
94 }
95
96 private void removeRule(FlowRule flowRule) {
97 //TODO
98 }
99
100 @Override
101 public void removeRulesById(ApplicationId id, FlowRule... flowRules) {
102 // TODO
103 removeFlowRule(flowRules);
104 }
105
106 @Override
107 public void executeBatch(FlowRuleBatchOperation batch) {
108 //TODO
109 }
110}