import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
+import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.DPN_ID_1;
+import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.DPN_ID_2;
import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.INTERFACE_NAME;
import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.PARENT_INTERFACE;
import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.TRUNK_INTERFACE_NAME;
import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.TUNNEL_INTERFACE_NAME;
+import static org.opendaylight.genius.interfacemanager.test.InterfaceManagerTestUtil.waitTillOperationCompletes;
+
import static org.opendaylight.genius.mdsalutil.NwConstants.DEFAULT_EGRESS_SERVICE_INDEX;
import static org.opendaylight.genius.mdsalutil.NwConstants.VLAN_INTERFACE_INGRESS_TABLE;
import static org.opendaylight.mdsal.binding.testutils.AssertDataObjects.assertEqualBeans;
import org.junit.rules.MethodRule;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.testutils.AsyncEventsWaiter;
import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorEventsWaiter;
import org.opendaylight.genius.datastoreutils.testutils.TestableDataTreeChangeListenerModule;
public @Rule MethodRule guice = new GuiceRule(new InterfaceManagerTestModule(),
new TestableDataTreeChangeListenerModule());
- private static final BigInteger DPN_ID = BigInteger.valueOf(1);
-
@Inject DataBroker dataBroker;
@Inject OdlInterfaceRpcService odlInterfaceRpcService;
@Inject JobCoordinatorEventsWaiter coordinatorEventsWaiter;
@Inject AsyncEventsWaiter asyncEventsWaiter;
@Before
- public void start() throws InterruptedException {
+ public void start() throws InterruptedException, TransactionCommitFailedException {
// Create the bridge and make sure it is ready
setupAndAssertBridgeCreation();
}
private void setupAndAssertBridgeDeletion() throws InterruptedException {
OvsdbSouthboundTestUtil.deleteBridge(dataBroker);
Thread.sleep(2000);
- assertEqualBeans(InterfaceMetaUtils.getBridgeRefEntryFromOperDS(DPN_ID, dataBroker), null);
+ assertEqualBeans(InterfaceMetaUtils.getBridgeRefEntryFromOperDS(DPN_ID_1, dataBroker), null);
}
- private void setupAndAssertBridgeCreation() throws InterruptedException {
+ private void setupAndAssertBridgeCreation() throws InterruptedException, TransactionCommitFailedException {
OvsdbSouthboundTestUtil.createBridge(dataBroker);
Thread.sleep(2000);
// a) Check bridgeRefEntry in cache and OperDS are same and use the
// right DPN_ID
- BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(DPN_ID);
+ BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(DPN_ID_1);
InstanceIdentifier<BridgeRefEntry> bridgeRefEntryIid = InterfaceMetaUtils
.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
BridgeRefEntry bridgeRefEntry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntryIid, dataBroker)
.orNull();
- assertEqualBeans(InterfaceMetaUtils.getBridgeRefEntryFromCache(DPN_ID), bridgeRefEntry);
- assertEqualBeans(bridgeRefEntry.getDpid(), DPN_ID);
+ assertEqualBeans(InterfaceMetaUtils.getBridgeRefEntryFromCache(DPN_ID_1), bridgeRefEntry);
+ assertEqualBeans(bridgeRefEntry.getDpid(), DPN_ID_1);
}
@Test
IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
- INTERFACE_NAME, Interface.OperStatus.Up, L2vlan.class), ifaceState);
+ INTERFACE_NAME, Interface.OperStatus.Up, L2vlan.class, DPN_ID_1.toString()), ifaceState);
// b) check if lport-tag to interface mapping is created
// Test all RPCs related to vlan-interfaces
checkVlanRpcs();
- //Update test
+ //Update config test
// i) vlan interface admin-state updated
InterfaceManagerTestUtil.updateInterfaceAdminState(dataBroker, INTERFACE_NAME, false);
ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), INTERFACE_NAME, Interface
- .OperStatus.Down, L2vlan.class), ifaceState);
-
+ .OperStatus.Down, L2vlan.class, DPN_ID_1.toString()), ifaceState);
// Restore the opState back to UP for proceeding with further tests
InterfaceManagerTestUtil.updateInterfaceAdminState(dataBroker, INTERFACE_NAME, true);
-
InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+
+ //state modification tests
+ // 1. Make the operational state of port as DOWN
+ InterfaceManagerTestUtil.updateFlowCapableNodeConnectorState(dataBroker, PARENT_INTERFACE, L2vlan.class, false);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+ Thread.sleep(3000);
+ ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).checkedGet().get();
+ // Verify if operational/ietf-interface-state is marked down
+ assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
+ INTERFACE_NAME, Interface.OperStatus.Down, L2vlan.class, DPN_ID_1.toString()), ifaceState);
+
+ // 4. Delete the southbound OF port
+ InterfaceManagerTestUtil.removeFlowCapableNodeConnectorState(dataBroker, L2vlan.class);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+ // Verify if interfaces are deleted from oper/ietf-interfaces-state
+ Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(PARENT_INTERFACE)).get());
+ Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).get());
+
+ // 3. Re-create the OF port to proceeed with vlan-member tests
+ InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, PARENT_INTERFACE, null);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
testVlanMemberInterface();
//Delete test
@Test
public void newTunnelInterface() throws Exception {
+
+ // 3. Update DPN-ID of the bridge
+ OvsdbSouthboundTestUtil.updateBridge(dataBroker, "00:00:00:00:00:00:00:02");
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+ BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(DPN_ID_2);
+ InstanceIdentifier<BridgeRefEntry> bridgeRefEntryIid = InterfaceMetaUtils
+ .getBridgeRefEntryIdentifier(bridgeRefEntryKey);
+ // Verify if DPN-ID is updated in corresponding DS and cache
+ BridgeRefEntry bridgeRefEntry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntryIid, dataBroker)
+ .orNull();
+ assertEqualBeans(InterfaceMetaUtils.getBridgeRefEntryFromCache(DPN_ID_2), bridgeRefEntry);
+
+
// 1. Given
// 2. When
// i) dpn-id specified above configuration comes in
// ii) Vlan interface written to config/ietf-interfaces DS and
// corresponding parent-interface is not present
// in operational/ietf-interface-state
- ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(DPN_ID).build();
+ ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(DPN_ID_2).build();
InterfaceManagerTestUtil.putInterfaceConfig(dataBroker, TUNNEL_INTERFACE_NAME, parentRefs, Tunnel.class);
Thread.sleep(5000);
// 3. Then
// a) check expected bridge-interface mapping in
// odl-interface-meta/config/bridge-interface-info was created
- BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(DPN_ID);
+ BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(DPN_ID_2);
BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(TUNNEL_INTERFACE_NAME);
InstanceIdentifier<BridgeInterfaceEntry> bridgeInterfaceEntryIid = InterfaceMetaUtils
.getBridgeInterfaceEntryIdentifier(bridgeEntryKey, bridgeInterfaceEntryKey);
// When termination end point is populated in network-topology
OvsdbSouthboundTestUtil.createTerminationPoint(dataBroker, TUNNEL_INTERFACE_NAME, InterfaceTypeVxlan.class);
InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class);
- Thread.sleep(5000);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+ Thread.sleep(3000);
// Then
// a) check if operational/ietf-interfaces-state is populated for the tunnel interface
dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
- TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class), ifaceState);
+ TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class, DPN_ID_2.toString()), ifaceState);
// Test all RPCs related to tunnel interfaces
checkTunnelRpcs();
assertEqualBeans(ExpectedTerminationPoint.newBfdEnabledTerminationPoint(),
dataBroker.newReadOnlyTransaction().read(CONFIGURATION, tpIid).checkedGet().get());
+ //state modification tests
+ // 1. Make the operational state of port as DOWN
+ InterfaceManagerTestUtil.updateFlowCapableNodeConnectorState(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel
+ .class, false);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+ ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
+ // Verify if operational/ietf-interface-state is still up
+ assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
+ TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class, DPN_ID_2.toString()), ifaceState);
+
+ // 2. Make BFD staus of tunnel port as down
+ OvsdbSouthboundTestUtil.updateTerminationPoint(dataBroker, TUNNEL_INTERFACE_NAME, InterfaceTypeVxlan.class);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+ ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
+ // Verify if operational/ietf-interface-state is marked down
+ assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
+ TUNNEL_INTERFACE_NAME, Interface.OperStatus.Down, Tunnel.class, DPN_ID_2.toString()), ifaceState);
+
+
+ // 2. Delete the Node
+ InterfaceManagerTestUtil.removeNode(dataBroker);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+ ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
+ // Verify if operational/ietf-interface-state is marked unknown
+ assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(),
+ TUNNEL_INTERFACE_NAME, Interface.OperStatus.Unknown, Tunnel.class, DPN_ID_2.toString()), ifaceState);
+
+ // Re-create port to proceed with further tests
+ InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+
+ // 2. Delete the OF port
+ InterfaceManagerTestUtil.removeFlowCapableNodeConnectorState(dataBroker, Tunnel.class);
+ waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
+
+ // Verify if operational-states are deleted
+ Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).get());
+ Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
+ IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).get());
+
// Delete test
// iii) tunnel interface is deleted from config/ietf-interfaces
InterfaceManagerTestUtil.deleteInterfaceConfig(dataBroker, TUNNEL_INTERFACE_NAME);
//2. Test interface list fetching from dpnId
GetDpnInterfaceListInput dpnInterfaceListInput = new GetDpnInterfaceListInputBuilder()
- .setDpid(DPN_ID).build();
+ .setDpid(DPN_ID_1).build();
Future<RpcResult<GetDpnInterfaceListOutput>> dpnInterfaceListOutput = odlInterfaceRpcService
.getDpnInterfaceList(dpnInterfaceListInput);
List<String> expectedDpnInterfaceList = new ArrayList(DpnInterfaceListOutput.newDpnInterfaceListOutput()
private void checkTunnelRpcs() throws Exception {
//1. Test endpoint ip fetching for dpn-id
- GetEndpointIpForDpnInput endpointIpForDpnInput = new GetEndpointIpForDpnInputBuilder().setDpid(DPN_ID).build();
+ GetEndpointIpForDpnInput endpointIpForDpnInput = new GetEndpointIpForDpnInputBuilder().setDpid(DPN_ID_2)
+ .build();
Future<RpcResult<GetEndpointIpForDpnOutput>> endpointIpForDpnOutput = odlInterfaceRpcService
.getEndpointIpForDpn(endpointIpForDpnInput);
assertEqualBeans(EndPointIpFromDpn.newEndPointIpFromDpn(), endpointIpForDpnOutput.get().getResult());
InterfaceManagerTestUtil.putVlanInterfaceConfig(dataBroker, TRUNK_INTERFACE_NAME, INTERFACE_NAME,
IfL2vlan.L2vlanMode.TrunkMember);
InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
-
+ Thread.sleep(3000);
// 3. Then
// a) check expected interface-child entry mapping in odl-interface-meta/config/interface-child-info was created
InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryInstanceIdentifier = InterfaceMetaUtils
dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
IfmUtil.buildStateInterfaceId(TRUNK_INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TRUNK_INTERFACE_NAME,
- Interface.OperStatus.Up, L2vlan.class), ifaceState);
+ Interface.OperStatus.Up, L2vlan.class, DPN_ID_1.toString()), ifaceState);
// b) check if lport-tag to interface mapping is created
InstanceIdentifier<IfIndexInterface> ifIndexInterfaceInstanceIdentifier = InstanceIdentifier.builder(
ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
IfmUtil.buildStateInterfaceId(TRUNK_INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TRUNK_INTERFACE_NAME,
- Interface.OperStatus.Down, L2vlan.class), ifaceState);
+ Interface.OperStatus.Down, L2vlan.class, DPN_ID_1.toString()), ifaceState);
InterfaceManagerTestUtil.deleteInterfaceConfig(dataBroker, TRUNK_INTERFACE_NAME);
InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
public static final String INTERFACE_NAME = "23701c04-7e58-4c65-9425-78a80d49a218";
public static final String TUNNEL_INTERFACE_NAME = "tun414a856a7a4";
public static final String TRUNK_INTERFACE_NAME = "23701c04-7e58-4c65-9425-78a80d49a219";
- public static final String DPN_ID_1 = "1";
- public static final String PORT_NO_1 = "2";
+
+ public static final BigInteger DPN_ID_1 = BigInteger.valueOf(1);
+ public static final BigInteger DPN_ID_2 = BigInteger.valueOf(2);
+ public static final long PORT_NO_1 = 2;
+
public static final TopologyId OVSDB_TOPOLOGY_ID = new TopologyId(new Uri("ovsdb:1"));
public static final NodeKey NODE_KEY = new NodeKey(new NodeId("openflow:1"));
static org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
- buildFlowCapableNodeConnector(NodeConnectorId ncId, String portName) {
+ buildFlowCapableNodeConnector(NodeConnectorId ncId, String portName, boolean isLive) {
NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder()
.setId(ncId)
.setKey(new NodeConnectorKey(ncId));
ncBuilder.addAugmentation(FlowCapableNodeConnector.class,
- buildFlowCapableNodeConnector(false, true,"AA:AA:AA:AA:AA:AA", portName));
+ buildFlowCapableNodeConnector(false, isLive,"AA:AA:AA:AA:AA:AA", portName));
return ncBuilder.build();
}
}
static void createFlowCapableNodeConnector(DataBroker dataBroker, String interfaceName,
- Class<? extends InterfaceType> ifType)
+ Class<? extends InterfaceType> ifType)
throws TransactionCommitFailedException {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ BigInteger dpnId = Tunnel.class.equals(ifType) ? DPN_ID_2 : DPN_ID_1;
+ long portNo = Tunnel.class.equals(ifType) ? PORT_NO_1 : PORT_NO_1;
+ NodeConnector nodeConnector = InterfaceManagerTestUtil
+ .buildFlowCapableNodeConnector(buildNodeConnectorId(dpnId, portNo), interfaceName, true);
+ tx.put(OPERATIONAL,buildNodeConnectorInstanceIdentifier(dpnId, portNo), nodeConnector, true);
+ tx.submit().checkedGet();
+ }
+ static void updateFlowCapableNodeConnectorState(DataBroker dataBroker, String interfaceName,
+ Class<? extends InterfaceType> ifType, boolean isLive)
+ throws TransactionCommitFailedException {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ BigInteger dpnId = Tunnel.class.equals(ifType) ? DPN_ID_2 : DPN_ID_1;
+ long portNo = Tunnel.class.equals(ifType) ? PORT_NO_1 : PORT_NO_1;
NodeConnector nodeConnector = InterfaceManagerTestUtil
- .buildFlowCapableNodeConnector(buildNodeConnectorId(BigInteger.valueOf(1), 2), interfaceName);
- tx.put(OPERATIONAL,buildNodeConnectorInstanceIdentifier(BigInteger.valueOf(1), 2), nodeConnector, true);
+ .buildFlowCapableNodeConnector(buildNodeConnectorId(dpnId, portNo), interfaceName, isLive);
+ tx.merge(OPERATIONAL,buildNodeConnectorInstanceIdentifier(dpnId, portNo), nodeConnector, true);
+ tx.submit().checkedGet();
+ }
+
+ static void removeFlowCapableNodeConnectorState(DataBroker dataBroker, Class<? extends InterfaceType> ifType)
+ throws TransactionCommitFailedException {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ BigInteger dpnId = Tunnel.class.equals(ifType) ? DPN_ID_2 : DPN_ID_1;
+ long portNo = Tunnel.class.equals(ifType) ? PORT_NO_1 : PORT_NO_1;
+ tx.delete(OPERATIONAL,buildNodeConnectorInstanceIdentifier(dpnId, portNo));
+ tx.submit().checkedGet();
+ }
+
+
+ static void removeNode(DataBroker dataBroker)
+ throws TransactionCommitFailedException {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ InstanceIdentifier<Node> nodeInstanceIdentifier = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, new NodeKey(IfmUtil.buildDpnNodeId(DPN_ID_2))).build();
+ tx.delete(OPERATIONAL,nodeInstanceIdentifier);
tx.submit().checkedGet();
}
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
return new NodeId(uri);
}
- public static void createBridge(DataBroker dataBroker) {
+ public static void createBridge(DataBroker dataBroker) throws TransactionCommitFailedException {
final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
final InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
final InstanceIdentifier<OvsdbBridgeAugmentation> ovsdbBridgeIid = bridgeIid.builder()
LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder.toString());
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, ovsdbBridgeIid, bridgeCreateAugmentationBuilder.build(), true);
- tx.submit();
+ tx.submit().checkedGet();
+ }
+
+ public static void updateBridge(DataBroker dataBroker, String datapathId) throws TransactionCommitFailedException {
+ final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
+ final InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
+ final InstanceIdentifier<OvsdbBridgeAugmentation> ovsdbBridgeIid = bridgeIid.builder()
+ .augmentation(OvsdbBridgeAugmentation.class).build();
+ final NodeId bridgeNodeId = createManagedNodeId(bridgeIid);
+ final NodeBuilder bridgeCreateNodeBuilder = new NodeBuilder();
+ bridgeCreateNodeBuilder.setNodeId(bridgeNodeId);
+ OvsdbBridgeAugmentationBuilder bridgeCreateAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
+ bridgeCreateAugmentationBuilder.setBridgeName(ovsdbBridgeName)
+ .setDatapathId(new DatapathId(datapathId));
+ bridgeCreateNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeCreateAugmentationBuilder.build());
+ LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder.toString());
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.merge(LogicalDatastoreType.OPERATIONAL, ovsdbBridgeIid, bridgeCreateAugmentationBuilder.build(), true);
+ tx.submit().checkedGet();
}
public boolean deleteBridge(final ConnectionInfo connectionInfo, final String bridgeName) {
}
public static void createTerminationPoint(DataBroker dataBroker, String interfaceName,
- Class<? extends InterfaceTypeBase> type) {
+ Class<? extends InterfaceTypeBase> type) throws
+ TransactionCommitFailedException {
final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
final InstanceIdentifier<Node> bridgeIid =
createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(OPERATIONAL, tpId, tpBuilder.build(), true);
- tx.submit();
+ tx.submit().checkedGet();
+ }
+
+ public static void updateTerminationPoint(DataBroker dataBroker, String interfaceName,
+ Class<? extends InterfaceTypeBase> type) throws
+ TransactionCommitFailedException {
+ final OvsdbBridgeName ovsdbBridgeName = new OvsdbBridgeName("s2");
+ final InstanceIdentifier<Node> bridgeIid =
+ createInstanceIdentifier("192.168.56.101", 6640, ovsdbBridgeName);
+ InstanceIdentifier<TerminationPoint> tpId = createTerminationPointInstanceIdentifier(
+ InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), interfaceName);
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ tpBuilder.setKey(InstanceIdentifier.keyOf(tpId));
+ OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
+
+ tpAugmentationBuilder.setName(interfaceName);
+ if (type != null) {
+ tpAugmentationBuilder.setInterfaceType(type);
+ }
+ List<InterfaceBfdStatus> interfaceBfdStatuses = Arrays.asList(new InterfaceBfdStatusBuilder()
+ .setBfdStatusKey("state").setBfdStatusValue("down").build());
+
+ tpAugmentationBuilder.setInterfaceBfdStatus(interfaceBfdStatuses);
+ tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.merge(OPERATIONAL, tpId, tpBuilder.build(), true);
+ tx.submit().checkedGet();
}
public static NodeKey createNodeKey(String ip, Integer port) {