2 * Copyright (c) 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netvirt.sfc.translator.flowclassifier;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.netvirt.sfc.translator.DelegatingDataTreeListener;
15 import org.opendaylight.netvirt.sfc.translator.SfcMdsalHelper;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.SfcFlowClassifiers;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 * OpenDaylight Neutron Flow Classifier yang models data change listener.
25 public class NeutronFlowClassifierListener extends DelegatingDataTreeListener<SfcFlowClassifier> {
27 private static final InstanceIdentifier<SfcFlowClassifier> FLOW_CLASSIFIERS_IID =
28 InstanceIdentifier.create(Neutron.class).child(SfcFlowClassifiers.class).child(SfcFlowClassifier.class);
30 private final SfcMdsalHelper sfcMdsalHelper;
32 public NeutronFlowClassifierListener(DataBroker db) {
33 super(db, new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CLASSIFIERS_IID));
34 sfcMdsalHelper = new SfcMdsalHelper(db);
39 * Method removes Acl respective to SfcFlowClassifier which is identified by InstanceIdentifier.
41 * @param deletedSfcFlowClassifier - SfcFlowClassifier for removing
44 public void remove(SfcFlowClassifier deletedSfcFlowClassifier) {
45 Acl aclFlowClassifier = FlowClassifierTranslator.buildAcl(deletedSfcFlowClassifier);
46 sfcMdsalHelper.removeAclFlowClassifier(aclFlowClassifier);
50 * Method updates the original SfcFlowClassifier to the update SfcFlowClassifier.
51 * Both are identified by same InstanceIdentifier.
53 * @param updatedSfcFlowClassifier - changed SfcFlowClassifier (contain updates)
56 public void update(SfcFlowClassifier updatedSfcFlowClassifier) {
58 Acl aclFlowClassifier = FlowClassifierTranslator.buildAcl(updatedSfcFlowClassifier);
59 sfcMdsalHelper.updateAclFlowClassifier(aclFlowClassifier);
63 * Method adds the SfcFlowClassifier which is identified by InstanceIdentifier
66 * @param sfcFlowClassifier - new SfcFlowClassifier
69 public void add(SfcFlowClassifier sfcFlowClassifier) {
70 // Respective ACL classifier will be written in data store, once the chain is created.