/*
-* Copyright (C) 2014 Red Hat, Inc.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0 which accompanies this distribution,
-* and is available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Authors : Sam Hague
-*/
+ * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
package org.opendaylight.ovsdb.ovssfc;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
+//import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
-import java.util.Set;
+//import java.util.Set;
public class SfpDataListener extends AbstractDataListener {
private static final Logger logger = LoggerFactory.getLogger(SfpDataListener.class);
public SfpDataListener (DataBroker dataBroker) {
setDataBroker(dataBroker);
- setIID(InstanceIdentifierUtils.createServiceFunctionPathsPath());
- registerAsDataChangeListener();
+ //setIID(InstanceIdentifierUtils.createServiceFunctionPathsPath());
+ setIID(InstanceIdentifierUtils.createServiceFunctionPathPath());
+ registerAsDataChangeListener(DataBroker.DataChangeScope.BASE);
}
@Override
//OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.CREATE, serviceFunctionPaths);
}
}
+
+ Map<InstanceIdentifier<?>, DataObject> originalDataObject = change.getOriginalData();
+ Set<InstanceIdentifier<?>> iID = change.getRemovedPaths();
+ for (InstanceIdentifier instanceIdentifier : iID) {
+ DataObject dObject = originalDataObject.get(instanceIdentifier);
+ if (dObject instanceof ServiceFunctionPath) {
+ ServiceFunctionPath serviceFunctionPath = (ServiceFunctionPath) dataObject;
+ logger.trace("\nOVSSFC DELETE: sfp:\n {}", serviceFunctionPath.toString());
+
+ OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.DELETE, serviceFunctionPath);
+ }
+ }
+
+ dataObject = change.getUpdatedData();
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
+ if (entry.getValue() instanceof ServiceFunctionPaths) {
+ ServiceFunctionPaths updatedServiceFunctionPaths = (ServiceFunctionPaths) entry.getValue();
+ logger.trace("\nOVSSFC UPDATE: sfps:\n {}", updatedServiceFunctionPaths.toString());
+
+ OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpsEvent(SfcEvent.Action.UPDATE, updatedServiceFunctionPaths);
+ }
+ }
*/
+/*
dataObject = change.getCreatedData();
for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
if (entry.getValue() instanceof ServiceFunctionPaths) {
OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpsEvent(SfcEvent.Action.CREATE, serviceFunctionPaths);
}
}
-
- dataObject = change.getUpdatedData();
+*/
+ dataObject = change.getCreatedData();
for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
- if (entry.getValue() instanceof ServiceFunctionPaths) {
- ServiceFunctionPaths updatedServiceFunctionPaths = (ServiceFunctionPaths) entry.getValue();
- logger.trace("\nOVSSFC UPDATE: sfps:\n {}", updatedServiceFunctionPaths.toString());
+ if (entry.getValue() instanceof ServiceFunctionPath) {
+ ServiceFunctionPath serviceFunctionPath = (ServiceFunctionPath) entry.getValue();
+ logger.trace("\nOVSSFC CREATE: sfp:\n {}", serviceFunctionPath.toString());
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpsEvent(SfcEvent.Action.UPDATE, updatedServiceFunctionPaths);
+ OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.CREATE, serviceFunctionPath);
}
}
- Map<InstanceIdentifier<?>, DataObject> originalDataObject = change.getOriginalData();
- Set<InstanceIdentifier<?>> iID = change.getRemovedPaths();
- for (InstanceIdentifier instanceIdentifier : iID) {
- DataObject dObject = originalDataObject.get(instanceIdentifier);
- if (dObject instanceof ServiceFunctionPath) {
- ServiceFunctionPath serviceFunctionPath = (ServiceFunctionPath) dataObject;
- logger.trace("\nOVSSFC DELETE: sfp:\n {}", serviceFunctionPath.toString());
+ dataObject = change.getUpdatedData();
+ for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dataObject.entrySet()) {
+ if (entry.getValue() instanceof ServiceFunctionPath) {
+ ServiceFunctionPath updatedServiceFunctionPath = (ServiceFunctionPath) entry.getValue();
+ logger.trace("\nOVSSFC UPDATE: sfp:\n {}", updatedServiceFunctionPath.toString());
- OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.DELETE, serviceFunctionPath);
+ OvsSfcProvider.getOvsSfcProvider().eventHandler.enqueueSfpEvent(SfcEvent.Action.UPDATE, updatedServiceFunctionPath);
}
}