Committed by
Mahesh Poojary Huawei
[ONOS-3114,3115] SFC Service and Manager Implementation
Change-Id: Ifaf8603e3558900f36fe2efec3975fcc5225d8b2
Showing
2 changed files
with
139 additions
and
57 deletions
| ... | @@ -15,6 +15,11 @@ | ... | @@ -15,6 +15,11 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.sfc.manager; | 16 | package org.onosproject.sfc.manager; |
| 17 | 17 | ||
| 18 | +import org.onosproject.vtnrsc.PortPair; | ||
| 19 | +import org.onosproject.vtnrsc.PortPairGroup; | ||
| 20 | +import org.onosproject.vtnrsc.FlowClassifier; | ||
| 21 | +import org.onosproject.vtnrsc.PortChain; | ||
| 22 | + | ||
| 18 | /** | 23 | /** |
| 19 | * SFC application that applies flows to the device. | 24 | * SFC application that applies flows to the device. |
| 20 | */ | 25 | */ |
| ... | @@ -23,48 +28,64 @@ public interface SfcService { | ... | @@ -23,48 +28,64 @@ public interface SfcService { |
| 23 | /** | 28 | /** |
| 24 | * When port-pair is created, check whether Forwarding Rule needs to be | 29 | * When port-pair is created, check whether Forwarding Rule needs to be |
| 25 | * updated in OVS. | 30 | * updated in OVS. |
| 31 | + * | ||
| 32 | + * @param portPair port-pair | ||
| 26 | */ | 33 | */ |
| 27 | - public void onPortPairCreated(); | 34 | + void onPortPairCreated(PortPair portPair); |
| 28 | 35 | ||
| 29 | /** | 36 | /** |
| 30 | * When port-pair is deleted, check whether Forwarding Rule needs to be | 37 | * When port-pair is deleted, check whether Forwarding Rule needs to be |
| 31 | * updated in OVS. | 38 | * updated in OVS. |
| 39 | + * | ||
| 40 | + * @param portPair port-pair | ||
| 32 | */ | 41 | */ |
| 33 | - public void onPortPairDeleted(); | 42 | + void onPortPairDeleted(PortPair portPair); |
| 34 | 43 | ||
| 35 | /** | 44 | /** |
| 36 | * When port-pair-group is created, check whether Forwarding Rule needs to | 45 | * When port-pair-group is created, check whether Forwarding Rule needs to |
| 37 | * be updated in OVS. | 46 | * be updated in OVS. |
| 47 | + * | ||
| 48 | + * @param portPairGroup port-pair-group | ||
| 38 | */ | 49 | */ |
| 39 | - public void onPortPairGroupCreated(); | 50 | + void onPortPairGroupCreated(PortPairGroup portPairGroup); |
| 40 | 51 | ||
| 41 | /** | 52 | /** |
| 42 | * When port-pair-group is deleted, check whether Forwarding Rule needs to | 53 | * When port-pair-group is deleted, check whether Forwarding Rule needs to |
| 43 | * be updated in OVS. | 54 | * be updated in OVS. |
| 55 | + * | ||
| 56 | + * @param portPairGroup port-pair-group | ||
| 44 | */ | 57 | */ |
| 45 | - public void onPortPairGroupDeleted(); | 58 | + void onPortPairGroupDeleted(PortPairGroup portPairGroup); |
| 46 | 59 | ||
| 47 | /** | 60 | /** |
| 48 | * When flow-classifier is created, check whether Forwarding Rule needs to | 61 | * When flow-classifier is created, check whether Forwarding Rule needs to |
| 49 | * be updated in OVS. | 62 | * be updated in OVS. |
| 63 | + * | ||
| 64 | + * @param flowClassifier flow-classifier | ||
| 50 | */ | 65 | */ |
| 51 | - public void onFlowClassifierCreated(); | 66 | + void onFlowClassifierCreated(FlowClassifier flowClassifier); |
| 52 | 67 | ||
| 53 | /** | 68 | /** |
| 54 | * When flow-classifier is deleted, check whether Forwarding Rule needs to | 69 | * When flow-classifier is deleted, check whether Forwarding Rule needs to |
| 55 | * be updated in OVS. | 70 | * be updated in OVS. |
| 71 | + * | ||
| 72 | + * @param flowClassifier flow-classifier | ||
| 56 | */ | 73 | */ |
| 57 | - public void onFlowClassifierDeleted(); | 74 | + void onFlowClassifierDeleted(FlowClassifier flowClassifier); |
| 58 | 75 | ||
| 59 | /** | 76 | /** |
| 60 | * When port-chain is created, check whether Forwarding Rule needs to be | 77 | * When port-chain is created, check whether Forwarding Rule needs to be |
| 61 | * updated in OVS. | 78 | * updated in OVS. |
| 79 | + * | ||
| 80 | + * @param portChain port-chain | ||
| 62 | */ | 81 | */ |
| 63 | - public void onPortChainCreated(); | 82 | + void onPortChainCreated(PortChain portChain); |
| 64 | 83 | ||
| 65 | /** | 84 | /** |
| 66 | * When port-chain is deleted, check whether Forwarding Rule needs to be | 85 | * When port-chain is deleted, check whether Forwarding Rule needs to be |
| 67 | * updated in OVS. | 86 | * updated in OVS. |
| 87 | + * | ||
| 88 | + * @param portChain port-chain | ||
| 68 | */ | 89 | */ |
| 69 | - public void onPortChainDeleted(); | 90 | + void onPortChainDeleted(PortChain portChain); |
| 70 | } | 91 | } | ... | ... |
| ... | @@ -20,9 +20,26 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -20,9 +20,26 @@ import static org.slf4j.LoggerFactory.getLogger; |
| 20 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; | 22 | import org.apache.felix.scr.annotations.Deactivate; |
| 23 | +import org.apache.felix.scr.annotations.Reference; | ||
| 24 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 23 | import org.apache.felix.scr.annotations.Service; | 25 | import org.apache.felix.scr.annotations.Service; |
| 26 | +import org.onlab.util.KryoNamespace; | ||
| 27 | +import org.onosproject.core.ApplicationId; | ||
| 28 | +import org.onosproject.core.CoreService; | ||
| 24 | import org.onosproject.sfc.manager.SfcService; | 29 | import org.onosproject.sfc.manager.SfcService; |
| 30 | +import org.onosproject.vtnrsc.PortPair; | ||
| 31 | +import org.onosproject.vtnrsc.PortPairId; | ||
| 32 | +import org.onosproject.vtnrsc.PortPairGroup; | ||
| 33 | +import org.onosproject.vtnrsc.PortPairGroupId; | ||
| 34 | +import org.onosproject.vtnrsc.FlowClassifier; | ||
| 35 | +import org.onosproject.vtnrsc.FlowClassifierId; | ||
| 25 | import org.onosproject.vtnrsc.PortChain; | 36 | import org.onosproject.vtnrsc.PortChain; |
| 37 | +import org.onosproject.vtnrsc.PortChainId; | ||
| 38 | +import org.onosproject.vtnrsc.TenantId; | ||
| 39 | +import org.onosproject.vtnrsc.event.VtnRscEvent; | ||
| 40 | +import org.onosproject.vtnrsc.event.VtnRscListener; | ||
| 41 | +import org.onosproject.vtnrsc.service.VtnRscService; | ||
| 42 | + | ||
| 26 | import org.slf4j.Logger; | 43 | import org.slf4j.Logger; |
| 27 | 44 | ||
| 28 | /** | 45 | /** |
| ... | @@ -33,93 +50,137 @@ import org.slf4j.Logger; | ... | @@ -33,93 +50,137 @@ import org.slf4j.Logger; |
| 33 | public class SfcManager implements SfcService { | 50 | public class SfcManager implements SfcService { |
| 34 | 51 | ||
| 35 | private final Logger log = getLogger(getClass()); | 52 | private final Logger log = getLogger(getClass()); |
| 53 | + private static final String APP_ID = "org.onosproject.app.vtn"; | ||
| 54 | + | ||
| 55 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 56 | + protected VtnRscService vtnRscService; | ||
| 57 | + | ||
| 58 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 59 | + protected CoreService coreService; | ||
| 60 | + | ||
| 61 | + protected ApplicationId appId; | ||
| 62 | + | ||
| 63 | + private final VtnRscListener vtnRscListener = new InnerVtnRscListener(); | ||
| 36 | 64 | ||
| 37 | @Activate | 65 | @Activate |
| 38 | public void activate() { | 66 | public void activate() { |
| 67 | + appId = coreService.registerApplication(APP_ID); | ||
| 68 | + | ||
| 69 | + vtnRscService.addListener(vtnRscListener); | ||
| 70 | + | ||
| 71 | + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() | ||
| 72 | + .register(TenantId.class) | ||
| 73 | + .register(PortPairId.class) | ||
| 74 | + .register(PortPairGroupId.class) | ||
| 75 | + .register(FlowClassifierId.class) | ||
| 76 | + .register(PortChainId.class); | ||
| 77 | + | ||
| 39 | log.info("Started"); | 78 | log.info("Started"); |
| 40 | } | 79 | } |
| 41 | 80 | ||
| 42 | @Deactivate | 81 | @Deactivate |
| 43 | public void deactivate() { | 82 | public void deactivate() { |
| 83 | + vtnRscService.removeListener(vtnRscListener); | ||
| 84 | + | ||
| 44 | log.info("Stopped"); | 85 | log.info("Stopped"); |
| 45 | } | 86 | } |
| 46 | 87 | ||
| 88 | + /* | ||
| 89 | + * Handle events. | ||
| 90 | + */ | ||
| 91 | + private class InnerVtnRscListener implements VtnRscListener { | ||
| 92 | + @Override | ||
| 93 | + public void event(VtnRscEvent event) { | ||
| 94 | + | ||
| 95 | + if (VtnRscEvent.Type.PORT_PAIR_PUT == event.type()) { | ||
| 96 | + PortPair portPair = (PortPair) event.subject(); | ||
| 97 | + onPortPairCreated(portPair); | ||
| 98 | + } else if (VtnRscEvent.Type.PORT_PAIR_DELETE == event.type()) { | ||
| 99 | + PortPair portPair = (PortPair) event.subject(); | ||
| 100 | + onPortPairDeleted(portPair); | ||
| 101 | + } else if (VtnRscEvent.Type.PORT_PAIR_UPDATE == event.type()) { | ||
| 102 | + PortPair portPair = (PortPair) event.subject(); | ||
| 103 | + onPortPairDeleted(portPair); | ||
| 104 | + onPortPairCreated(portPair); | ||
| 105 | + } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_PUT == event.type()) { | ||
| 106 | + PortPairGroup portPairGroup = (PortPairGroup) event.subject(); | ||
| 107 | + onPortPairGroupCreated(portPairGroup); | ||
| 108 | + } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_DELETE == event.type()) { | ||
| 109 | + PortPairGroup portPairGroup = (PortPairGroup) event.subject(); | ||
| 110 | + onPortPairGroupDeleted(portPairGroup); | ||
| 111 | + } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_UPDATE == event.type()) { | ||
| 112 | + PortPairGroup portPairGroup = (PortPairGroup) event.subject(); | ||
| 113 | + onPortPairGroupDeleted(portPairGroup); | ||
| 114 | + onPortPairGroupCreated(portPairGroup); | ||
| 115 | + } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_PUT == event.type()) { | ||
| 116 | + FlowClassifier flowClassifier = (FlowClassifier) event.subject(); | ||
| 117 | + onFlowClassifierCreated(flowClassifier); | ||
| 118 | + } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_DELETE == event.type()) { | ||
| 119 | + FlowClassifier flowClassifier = (FlowClassifier) event.subject(); | ||
| 120 | + onFlowClassifierDeleted(flowClassifier); | ||
| 121 | + } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_UPDATE == event.type()) { | ||
| 122 | + FlowClassifier flowClassifier = (FlowClassifier) event.subject(); | ||
| 123 | + onFlowClassifierDeleted(flowClassifier); | ||
| 124 | + onFlowClassifierCreated(flowClassifier); | ||
| 125 | + } else if (VtnRscEvent.Type.PORT_CHAIN_PUT == event.type()) { | ||
| 126 | + PortChain portChain = (PortChain) event.subject(); | ||
| 127 | + onPortChainCreated(portChain); | ||
| 128 | + } else if (VtnRscEvent.Type.PORT_CHAIN_DELETE == event.type()) { | ||
| 129 | + PortChain portChain = (PortChain) event.subject(); | ||
| 130 | + onPortChainDeleted(portChain); | ||
| 131 | + } else if (VtnRscEvent.Type.PORT_CHAIN_UPDATE == event.type()) { | ||
| 132 | + PortChain portChain = (PortChain) event.subject(); | ||
| 133 | + onPortChainDeleted(portChain); | ||
| 134 | + onPortChainCreated(portChain); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 47 | @Override | 139 | @Override |
| 48 | - public void onPortPairCreated() { | 140 | + public void onPortPairCreated(PortPair portPair) { |
| 49 | log.debug("onPortPairCreated"); | 141 | log.debug("onPortPairCreated"); |
| 50 | - // TODO: Process port-pair on creation. | 142 | + // TODO: Modify forwarding rule on port-pair creation. |
| 51 | - // TODO: Parameter also needs to be modified. | ||
| 52 | } | 143 | } |
| 53 | 144 | ||
| 54 | @Override | 145 | @Override |
| 55 | - public void onPortPairDeleted() { | 146 | + public void onPortPairDeleted(PortPair portPair) { |
| 56 | log.debug("onPortPairDeleted"); | 147 | log.debug("onPortPairDeleted"); |
| 57 | - // TODO: Process port-pair on deletion. | 148 | + // TODO: Modify forwarding rule on port-pair deletion. |
| 58 | - // TODO: Parameter also needs to be modified. | ||
| 59 | } | 149 | } |
| 60 | 150 | ||
| 61 | @Override | 151 | @Override |
| 62 | - public void onPortPairGroupCreated() { | 152 | + public void onPortPairGroupCreated(PortPairGroup portPairGroup) { |
| 63 | log.debug("onPortPairGroupCreated"); | 153 | log.debug("onPortPairGroupCreated"); |
| 64 | - // TODO: Process port-pair-group on creation. | 154 | + // TODO: Modify forwarding rule on port-pair-group creation. |
| 65 | - // TODO: Parameter also needs to be modified. | ||
| 66 | } | 155 | } |
| 67 | 156 | ||
| 68 | @Override | 157 | @Override |
| 69 | - public void onPortPairGroupDeleted() { | 158 | + public void onPortPairGroupDeleted(PortPairGroup portPairGroup) { |
| 70 | log.debug("onPortPairGroupDeleted"); | 159 | log.debug("onPortPairGroupDeleted"); |
| 71 | - // TODO: Process port-pair-group on deletion. | 160 | + // TODO: Modify forwarding rule on port-pair-group deletion. |
| 72 | - // TODO: Parameter also needs to be modified. | ||
| 73 | } | 161 | } |
| 74 | 162 | ||
| 75 | @Override | 163 | @Override |
| 76 | - public void onFlowClassifierCreated() { | 164 | + public void onFlowClassifierCreated(FlowClassifier flowClassifier) { |
| 77 | log.debug("onFlowClassifierCreated"); | 165 | log.debug("onFlowClassifierCreated"); |
| 78 | - // TODO: Process flow-classifier on creation. | 166 | + // TODO: Modify forwarding rule on flow-classifier creation. |
| 79 | - // TODO: Parameter also needs to be modified. | ||
| 80 | } | 167 | } |
| 81 | 168 | ||
| 82 | @Override | 169 | @Override |
| 83 | - public void onFlowClassifierDeleted() { | 170 | + public void onFlowClassifierDeleted(FlowClassifier flowClassifier) { |
| 84 | log.debug("onFlowClassifierDeleted"); | 171 | log.debug("onFlowClassifierDeleted"); |
| 85 | - // TODO: Process flow-classifier on deletion. | 172 | + // TODO: Modify forwarding rule on flow-classifier deletion. |
| 86 | - // TODO: Parameter also needs to be modified. | ||
| 87 | } | 173 | } |
| 88 | 174 | ||
| 89 | @Override | 175 | @Override |
| 90 | - public void onPortChainCreated() { | 176 | + public void onPortChainCreated(PortChain portChain) { |
| 91 | - log.debug("onPortChainCreated"); | 177 | + log.debug("onPortChainCreated"); |
| 92 | - // TODO: Process port-chain on creation. | 178 | + //TODO: Apply forwarding rule on port-chain creation. |
| 93 | - // TODO: Parameter also needs to be modified. | ||
| 94 | - | ||
| 95 | } | 179 | } |
| 96 | 180 | ||
| 97 | @Override | 181 | @Override |
| 98 | - public void onPortChainDeleted() { | 182 | + public void onPortChainDeleted(PortChain portChain) { |
| 99 | log.debug("onPortChainDeleted"); | 183 | log.debug("onPortChainDeleted"); |
| 100 | - // TODO: Process port-chain on deletion. | 184 | + //TODO: Apply forwarding rule on port-chain deletion. |
| 101 | - // TODO: Parameter also needs to be modified. | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - /** | ||
| 105 | - * Install SF Forwarding rule into OVS. | ||
| 106 | - * | ||
| 107 | - * @param portChain | ||
| 108 | - * port chain | ||
| 109 | - */ | ||
| 110 | - public void installForwardingRule(PortChain portChain) { | ||
| 111 | - log.debug("installForwardingRule"); | ||
| 112 | - // TODO: Installation of SF Forwarding rule into OVS. | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - /** | ||
| 116 | - * Uninstall SF Forwarding rule from OVS. | ||
| 117 | - * | ||
| 118 | - * @param portChain | ||
| 119 | - * port chain | ||
| 120 | - */ | ||
| 121 | - public void unInstallForwardingRule(PortChain portChain) { | ||
| 122 | - log.debug("unInstallForwardingRule"); | ||
| 123 | - // TODO: Uninstallation of SF Forwarding rule from OVS. | ||
| 124 | } | 185 | } |
| 125 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 186 | +} | ... | ... |
-
Please register or login to post a comment