/*
- * Copyright (c) 2013 Ericsson AB. All rights reserved.
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.mdsalutil.internal;
public MDSALManager(final DataBroker db, PacketProcessingService pktProcService) {
m_dataBroker = db;
m_packetProcessingService = pktProcService;
-
+ s_logger.info( "MDSAL Manager Initialized ") ;
}
@Override
public void installFlow(FlowEntity flowEntity) {
try {
- s_logger.info("InstallFlow for flowEntity {} ", flowEntity);
+ s_logger.trace("InstallFlow for flowEntity {} ", flowEntity);
if (flowEntity.getCookie() == null) {
flowEntity.setCookie(new BigInteger("0110000", 16));
@Override
public void onSuccess(final Void result) {
// Commited successfully
- s_logger.info( "Install Flow -- Committedsuccessfully ") ;
+ s_logger.debug( "Install Flow -- Committedsuccessfully ") ;
}
@Override
}
});
} catch (Exception e) {
- s_logger.error("Could not install flow: {}, exception: {}", flowEntity, e);
+ s_logger.error("Could not install flow: {}", flowEntity, e);
}
}
+ public CheckedFuture<Void,TransactionCommitFailedException> installFlow(BigInteger dpId, Flow flow) {
+ FlowKey flowKey = new FlowKey( new FlowId(flow.getId()) );
+ Node nodeDpn = buildDpnNode(dpId);
+ InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class,flowKey).build();
+
+ WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+ modification.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true);
+ return modification.submit();
+ }
+
public void installGroup(GroupEntity groupEntity) {
try {
Group group = groupEntity.getGroupBuilder().build();
@Override
public void onSuccess(final Void result) {
// Commited successfully
- s_logger.info( "Install Group -- Committedsuccessfully ") ;
+ s_logger.debug( "Install Group -- Committedsuccessfully ") ;
}
@Override
}
});
} catch (Exception e) {
- s_logger.error("Could not install Group: {}, exception: {}", groupEntity, e);
+ s_logger.error("Could not install Group: {}", groupEntity, e);
throw e;
}
}
public void removeFlow(FlowEntity flowEntity) {
try {
+ s_logger.debug("Remove flow {}",flowEntity);
Node nodeDpn = buildDpnNode(flowEntity.getDpnId());
FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
- modification.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId );
+ modification.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId);
CheckedFuture<Void,TransactionCommitFailedException> submitFuture = modification.submit();
@Override
public void onSuccess(final Void result) {
// Commited successfully
- s_logger.info( "Delete Flow -- Committedsuccessfully ") ;
+ s_logger.debug( "Delete Flow -- Committedsuccessfully ") ;
}
@Override
});
} catch (Exception e) {
- s_logger.error("Could not remove Flow: {}, exception: {}", flowEntity, e);
+ s_logger.error("Could not remove Flow: {}", flowEntity, e);
}
}
+ public CheckedFuture<Void,TransactionCommitFailedException> removeFlowNew(FlowEntity flowEntity) {
+ s_logger.debug("Remove flow {}",flowEntity);
+ Node nodeDpn = buildDpnNode(flowEntity.getDpnId());
+ FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
+ InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+ .child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
+ WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+ modification.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId );
+ return modification.submit();
+ }
+
public void removeGroup(GroupEntity groupEntity) {
try {
Node nodeDpn = buildDpnNode(groupEntity.getDpnId());
@Override
public void onSuccess(final Void result) {
// Commited successfully
- s_logger.info( "Install Group -- Committedsuccessfully ") ;
+ s_logger.debug( "Install Group -- Committedsuccessfully ") ;
}
@Override
}
});
} catch (Exception e) {
- s_logger.error("Could not remove Group: {}, exception: {}", groupEntity, e);
+ s_logger.error("Could not remove Group: {}", groupEntity, e);
}
}
installGroup(groupEntity);
}
- public void sendPacketOut(long lDpnId, int groupId, byte[] payload) {
+ public void sendPacketOut(BigInteger dpnId, int groupId, byte[] payload) {
List<ActionInfo> actionInfos = new ArrayList<ActionInfo>();
actionInfos.add(new ActionInfo(ActionType.group, new String[] { String.valueOf(groupId) }));
- sendPacketOutWithActions(lDpnId, groupId, payload, actionInfos);
+ sendPacketOutWithActions(dpnId, groupId, payload, actionInfos);
}
- public void sendPacketOutWithActions(long lDpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos) {
+ public void sendPacketOutWithActions(BigInteger dpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos) {
- m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actionInfos, payload, lDpnId,
- getNodeConnRef("openflow:" + lDpnId, "0xfffffffd")));
+ m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actionInfos, payload, dpnId,
+ getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
}
- public void sendARPPacketOutWithActions(long lDpnId, byte[] payload, List<ActionInfo> actions) {
- m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actions, payload, lDpnId,
- getNodeConnRef("openflow:" + lDpnId, "0xfffffffd")));
+ public void sendARPPacketOutWithActions(BigInteger dpnId, byte[] payload, List<ActionInfo> actions) {
+ m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actions, payload, dpnId,
+ getNodeConnRef("openflow:" + dpnId, "0xfffffffd")));
}
public InstanceIdentifier<Node> nodeToInstanceId(Node node) {
return _nodeConnectorRef;
}
- private Node buildDpnNode(long lDpnId) {
- NodeId nodeId = new NodeId("openflow:" + lDpnId);
+ private Node buildDpnNode(BigInteger dpnId) {
+ NodeId nodeId = new NodeId("openflow:" + dpnId);
Node nodeDpn = new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
return nodeDpn;