use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class ItmTepAutoConfigTest method tzAddDeleteToNotHostedViaSouthboundTest.
@Test
public void tzAddDeleteToNotHostedViaSouthboundTest() throws Exception {
// create Network topology node
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_NAME, dataBroker);
future.get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.NOT_HOSTED_DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedtzPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
Assert.assertNotNull(notHostedtzPath);
// check not hosted
assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).checkedGet().get());
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, null, ItmTestConstants.DEF_BR_NAME, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).get());
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForTzTest.
@Test
public void tepUpdateForTzTest() throws Exception {
String tepIp = ItmTestConstants.DEF_TZ_TEP_IP;
// create Network topology node with tep-ip set into ExternalIds list
// OvsdbNodeListener would be automatically listen on Node to add TEP
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
future.get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
// iid for default-TZ
InstanceIdentifier<TransportZone> defTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(defTzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath).checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// create Transport-zone TZA
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
// iid for TZA configured from NB
InstanceIdentifier<TransportZone> tzaTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzaTzonePath);
// update OVSDB node with tzname=TZA in ExternalIds list
String tzName = ItmTestConstants.TZ_NAME;
OvsdbTestUtil.updateNode(connInfo, tepIp, tzName, null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
// check old TEP which was in default-TZ is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated and now it is added into TZA transport-zone when tzname is updated
// to TZA from southbound
assertEqualBeans(ExpectedTransportZoneObjects.updatedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzaTzonePath).checkedGet().get());
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class ItmUtils method getOvsdbNode.
/**
* Gets the Network topology Node from Operational Datastore
* based on Bridge Augmentation.
*
* @param bridgeAugmentation bridge augmentation of OVSDB node
*
* @param dataBroker data broker handle to perform operations on datastore
*
* @return the Network Topology Node i.e. OVSDB node which is managing the specified bridge
*/
public static Node getOvsdbNode(OvsdbBridgeAugmentation bridgeAugmentation, DataBroker dataBroker) {
Node ovsdbNode = null;
Optional<Node> opOvsdbNode = Optional.absent();
if (bridgeAugmentation != null) {
InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) bridgeAugmentation.getManagedBy().getValue();
opOvsdbNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, ovsdbNodeIid, dataBroker);
}
if (opOvsdbNode.isPresent()) {
ovsdbNode = opOvsdbNode.get();
}
return ovsdbNode;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method newTunnelInterface.
@Ignore
@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
// operational/network-topology
// 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_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_2);
BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(TUNNEL_INTERFACE_NAME);
InstanceIdentifier<BridgeInterfaceEntry> bridgeInterfaceEntryIid = InterfaceMetaUtils.getBridgeInterfaceEntryIdentifier(bridgeEntryKey, bridgeInterfaceEntryKey);
// TODO Later use nicer abstraction for DB access here.. see
// ElanServiceTest
assertEqualBeans(InterfaceMeta.newBridgeInterface(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, bridgeInterfaceEntryIid).checkedGet().get());
// Then
// a) check if termination end point is created in
// config/network-topology
final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> bridgeIid = OvsdbSouthboundTestUtil.createInstanceIdentifier("192.168.56.101", 6640, "s2");
InstanceIdentifier<TerminationPoint> tpIid = InterfaceManagerTestUtil.getTerminationPointId(bridgeIid, TUNNEL_INTERFACE_NAME);
assertEqualTerminationPoints(ExpectedTerminationPoint.newTerminationPoint(), db.syncRead(CONFIGURATION, tpIid));
// When termination end point is populated in network-topology
OvsdbSouthboundTestUtil.createTerminationPoint(dataBroker, TUNNEL_INTERFACE_NAME, InterfaceTypeVxlan.class, null);
InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class);
waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
Thread.sleep(3000);
TestableQueues.awaitEmpty(batchingUtils.getQueue(DEFAULT_OPERATIONAL), 1, MINUTES);
// Then
// a) check if operational/ietf-interfaces-state is populated for the tunnel interface
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class, DPN_ID_2.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
// Test all RPCs related to tunnel interfaces
checkTunnelRpcs();
checkTunnelApis();
// Update test
// i) Enable Tunnel Monitoring
InterfaceManagerTestUtil.updateTunnelMonitoringAttributes(dataBroker, TUNNEL_INTERFACE_NAME);
InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
// Then verify if bfd attributes are updated in topology config DS
assertEqualTerminationPoints(ExpectedTerminationPoint.newBfdEnabledTerminationPoint(), db.syncRead(CONFIGURATION, tpIid));
// 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.getStatistics().getDiscontinuityTime()), 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.getStatistics().getDiscontinuityTime()), 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.getStatistics().getDiscontinuityTime()), 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);
InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
// Then
// a) check if tunnel is deleted from bridge-interface-info
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, bridgeInterfaceEntryIid).get());
// b) check if termination end point is deleted in
// config/network-topology
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, tpIid).get());
waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class HwVTEPInterfaceConfigAddHelper method createPhysicalLocatorEntry.
/*
* This method writes the termination end point details to the topology
* Config DS
*/
private static void createPhysicalLocatorEntry(WriteTransaction transaction, InstanceIdentifier<TerminationPoint> tpPath, TerminationPointKey terminationPointKey, IpAddress destIPAddress) {
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalLocatorAugmentationBuilder();
tpBuilder.setKey(terminationPointKey);
tpBuilder.setTpId(terminationPointKey.getTpId());
tpAugmentationBuilder.setEncapsulationType(EncapsulationTypeVxlanOverIpv4.class);
SouthboundUtils.setDstIp(tpAugmentationBuilder, destIPAddress);
tpBuilder.addAugmentation(HwvtepPhysicalLocatorAugmentation.class, tpAugmentationBuilder.build());
LOG.debug("creating physical locator entry for {}", terminationPointKey);
transaction.put(LogicalDatastoreType.CONFIGURATION, tpPath, tpBuilder.build(), true);
}
Aggregations