Thejaswi N K | 0db36e7 | 2016-02-02 22:10:54 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Thejaswi N K | 0db36e7 | 2016-02-02 22:10:54 +0530 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.provider.bgp.flow.impl; |
| 17 | |
| 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.bgp.controller.BgpController; |
| 24 | import org.onosproject.cfg.ComponentConfigService; |
| 25 | import org.onosproject.core.ApplicationId; |
| 26 | import org.onosproject.net.flow.FlowRule; |
| 27 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
| 28 | import org.onosproject.net.flow.FlowRuleProvider; |
| 29 | import org.onosproject.net.flow.FlowRuleProviderRegistry; |
| 30 | import org.onosproject.net.flow.FlowRuleProviderService; |
| 31 | import org.onosproject.net.provider.AbstractProvider; |
| 32 | import org.onosproject.net.provider.ProviderId; |
| 33 | import org.osgi.service.component.ComponentContext; |
| 34 | import org.slf4j.Logger; |
| 35 | |
| 36 | import static org.slf4j.LoggerFactory.getLogger; |
| 37 | |
| 38 | /** |
| 39 | * Bgp Flow provider. |
| 40 | */ |
| 41 | @Component(immediate = true) |
| 42 | public 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 | } |