use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method checkVlanApis.
private void checkVlanApis() throws Exception {
// 1. Test port-no corresponding to interface
long portNo = interfaceManager.getPortForInterface(INTERFACE_NAME);
Assert.assertEquals(PORT_NO_1, portNo);
// 2. fetch interface config from datastore API
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = interfaceManager.getInterfaceInfoFromConfigDataStore(INTERFACE_NAME);
// FIXME change this once augmentation sorting fix lands
assertEqualBeans(INTERFACE_NAME, interfaceInfo.getName());
assertEqualBeans(PARENT_INTERFACE, interfaceInfo.getAugmentation(ParentRefs.class).getParentInterface());
// 3. fetch dpn-id corresponding to an interface
BigInteger dpnId = interfaceManager.getDpnForInterface(INTERFACE_NAME);
Assert.assertEquals(DPN_ID_1, dpnId);
// 4. fetch parent-interface corresponding to an interface
Assert.assertEquals(PARENT_INTERFACE, interfaceManager.getParentRefNameForInterface(INTERFACE_NAME));
// 5. get interface information
assertEqualBeans(ExpectedInterfaceInfo.newVlanInterfaceInfo(), interfaceManager.getInterfaceInfo(INTERFACE_NAME));
Assert.assertEquals(org.opendaylight.genius.interfacemanager.globals.IfmConstants.VXLAN_GROUPID_MIN + 1, interfaceManager.getLogicalTunnelSelectGroupId(1));
// 6. Test bind ingress service
BoundServices serviceInfo = InterfaceManagerTestUtil.buildServicesInfo("ELAN", NwConstants.ELAN_SERVICE_INDEX);
interfaceManager.bindService(INTERFACE_NAME, ServiceModeIngress.class, serviceInfo);
waitTillOperationCompletes("test bind ingress service api", coordinatorEventsWaiter, 1, asyncEventsWaiter);
String lportDispatcherFlowRef = String.valueOf(dpnId) + NwConstants.FLOWID_SEPARATOR + NwConstants.LPORT_DISPATCHER_TABLE + NwConstants.FLOWID_SEPARATOR + INTERFACE_NAME + NwConstants.FLOWID_SEPARATOR + NwConstants.DEFAULT_SERVICE_INDEX;
FlowKey lportDispatcherFlowKey = new FlowKey(new FlowId(lportDispatcherFlowRef));
Node nodeDpn = InterfaceManagerTestUtil.buildInventoryDpnNode(dpnId);
InstanceIdentifier<Flow> lportDispatcherFlowId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.LPORT_DISPATCHER_TABLE)).child(Flow.class, lportDispatcherFlowKey).build();
flowAssertTestUtils.assertFlowsInAnyOrder(ExpectedFlowEntries.newLportDispatcherFlow(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, lportDispatcherFlowId).checkedGet().get());
// check whether service-binding state cache is populated
assertEqualBeans(ExpectedBoundServiceState.newBoundServiceState(), FlowBasedServicesUtils.getBoundServicesState(dataBroker.newReadOnlyTransaction(), INTERFACE_NAME, ServiceModeIngress.class));
// 7. test check whether service is bound on ingress
Assert.assertTrue(interfaceManager.isServiceBoundOnInterfaceForIngress(NwConstants.ELAN_SERVICE_INDEX, INTERFACE_NAME));
// 8. test unbind ingress service
interfaceManager.unbindService(INTERFACE_NAME, ServiceModeIngress.class, serviceInfo);
waitTillOperationCompletes("test unbind ingress service api", coordinatorEventsWaiter, 2, asyncEventsWaiter);
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, lportDispatcherFlowId).get());
// check service-state cache is cleaned up
// 9. Test bind egress service
short egressACLIndex = ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX);
serviceInfo = InterfaceManagerTestUtil.buildServicesInfo("EGRESS_ACL", egressACLIndex);
interfaceManager.bindService(INTERFACE_NAME, ServiceModeEgress.class, serviceInfo);
waitTillOperationCompletes("test bind egress service api", coordinatorEventsWaiter, 1, asyncEventsWaiter);
String egressDispatcherFlowRef = String.valueOf(dpnId) + NwConstants.FLOWID_SEPARATOR + NwConstants.EGRESS_LPORT_DISPATCHER_TABLE + NwConstants.FLOWID_SEPARATOR + INTERFACE_NAME + NwConstants.FLOWID_SEPARATOR + NwConstants.DEFAULT_EGRESS_SERVICE_INDEX;
FlowKey egressDispatcherFlowKey = new FlowKey(new FlowId(egressDispatcherFlowRef));
InstanceIdentifier<Flow> egressDispatcherFlowId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE)).child(Flow.class, egressDispatcherFlowKey).build();
// FIXME the extend file getting generated had some import issues, will revist later
// assertEqualBeans(null,
// dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).checkedGet().get());
Assert.assertNotNull(dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).checkedGet().get());
// 10. test check whether service is bound on egress
Assert.assertTrue(interfaceManager.isServiceBoundOnInterfaceForEgress(NwConstants.EGRESS_ACL_SERVICE_INDEX, INTERFACE_NAME));
// 11. Test unbinding of egress service
interfaceManager.unbindService(INTERFACE_NAME, ServiceModeEgress.class, serviceInfo);
waitTillOperationCompletes("test unbind egress service api", coordinatorEventsWaiter, 2, asyncEventsWaiter);
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, egressDispatcherFlowId).get());
// 12. Test fetching child interfaces of an interface
// FIXME change the below assert once sorted augmentation fix lands
assertEqualBeans(INTERFACE_NAME, interfaceManager.getChildInterfaces(PARENT_INTERFACE).get(0).getName());
// 13. Test fetching interface-info from operational DS
assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, PARENT_INTERFACE, null), interfaceManager.getInterfaceInfoFromOperationalDataStore(INTERFACE_NAME));
// 14. Test fetching of interface-info from oper DS, given interface-type
assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, INTERFACE_NAME, InterfaceInfo.InterfaceType.VLAN_INTERFACE), interfaceManager.getInterfaceInfoFromOperationalDataStore(INTERFACE_NAME, InterfaceInfo.InterfaceType.VLAN_INTERFACE));
// 15.Test fetching of interface-info from cache
assertEqualBeans(ExpectedInterfaceInfo.newInterfaceInfo(1, INTERFACE_NAME, PARENT_INTERFACE, null), interfaceManager.getInterfaceInfoFromOperationalDSCache(INTERFACE_NAME));
// 16. Test creation of VLAN interface
// FIXME Make IInterfaceManager truly async
interfaceManager.createVLANInterface(INTERFACE_NAME_1, PARENT_INTERFACE_1, null, INTERFACE_NAME_1, IfL2vlan.L2vlanMode.Trunk);
// waitTillOperationCompletes(coordinatorEventsWaiter, 1, asyncEventsWaiter);
// assertEqualBeans(ExpectedInterfaceConfig.newVlanInterfaceConfig(INTERFACE_NAME_1, null),
// dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(
// INTERFACE_NAME_1)).checkedGet().get());
// 17. Update Parent Refs for VLAN interface
// FIXME Make IInterfaceManager truly async
// interfaceManager.updateInterfaceParentRef(INTERFACE_NAME_1, PARENT_INTERFACE_1);
waitTillOperationCompletes("create vlan interface api", coordinatorEventsWaiter, 4, asyncEventsWaiter);
assertEqualBeans(ExpectedInterfaceConfig.newVlanInterfaceConfig(INTERFACE_NAME_1, PARENT_INTERFACE_1), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(INTERFACE_NAME_1)).checkedGet().get());
// 18. Test creation of external l2vlan interfaces
// FIXME Make IInterfaceManager truly async
interfaceManager.createVLANInterface(INTERFACE_NAME_2, PARENT_INTERFACE_2, null, INTERFACE_NAME_2, IfL2vlan.L2vlanMode.Trunk, true);
// waitTillOperationCompletes(coordinatorEventsWaiter, 1, asyncEventsWaiter);
// FIXME need to wait for https://git.opendaylight.org/gerrit/#/c/54811/ this to land
// to do proper assertion
// Assert.assertNotNull(dataBroker
// .newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil
// .buildId(INTERFACE_NAME_2)).checkedGet().get().getAugmentation(IfExternal.class));
// 19. update parent-refs
// interfaceManager.updateInterfaceParentRef(INTERFACE_NAME_2, PARENT_INTERFACE_2, true);
waitTillOperationCompletes("create external vlan interface api", coordinatorEventsWaiter, 4, asyncEventsWaiter);
Assert.assertEquals(PARENT_INTERFACE_2, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(INTERFACE_NAME_2)).checkedGet().get().getAugmentation(ParentRefs.class).getParentInterface());
// 20. get list of vlan interfaces
// FIXME need to wait for https://git.opendaylight.org/gerrit/#/c/54811/ this to land
// to do proper assertion
assertEqualBeans(3, interfaceManager.getVlanInterfaces().size());
// 21. check if an interface is external interface
Assert.assertTrue(interfaceManager.isExternalInterface(INTERFACE_NAME_2));
// 22. check port name for an interface, given dpn-id and interface-name
assertEqualBeans(PARENT_INTERFACE, interfaceManager.getPortNameForInterface(DPN_ID_1.toString(), PARENT_INTERFACE));
// 23. check port name for an interface, given nodeconnectorid
assertEqualBeans(PARENT_INTERFACE, interfaceManager.getPortNameForInterface(new NodeConnectorId("openflow:1:2"), PARENT_INTERFACE));
// 24. get termination-points from cache
Assert.assertNotNull(interfaceManager.getTerminationPointCache().get(INTERFACE_NAME));
// 25. fetch termination point for interface
assertEqualBeans(ExpectedTerminationPoint.newOvsdbTerminationPointAugmentation(), interfaceManager.getTerminationPointForInterface(INTERFACE_NAME));
// 26. fetch ovsdb bridge corresponding to an interface
assertEqualBeans(ExpectedOvsdbBridge.newOvsdbBridge(), interfaceManager.getOvsdbBridgeForInterface(INTERFACE_NAME));
// 27. fetch ovsdb bridge corresponding to nodeIid
assertEqualBeans(ExpectedOvsdbBridge.newOvsdbBridge(), interfaceManager.getOvsdbBridgeForNodeIid(OvsdbSouthboundTestUtil.createInstanceIdentifier("192.168.56.101", 6640, "s2")));
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project genius by opendaylight.
the class ItmTunnelEventListener method update.
@Override
public void update(@Nonnull InstanceIdentifier<StateTunnelList> instanceIdentifier, @Nonnull StateTunnelList originalTunnelList, @Nonnull StateTunnelList updatedTunnelList) {
LOG.trace("Tunnel Interface updated. Old: {} New: {}", originalTunnelList, updatedTunnelList);
TunnelOperStatus operStatus = updatedTunnelList.getOperState();
if (!Objects.equals(originalTunnelList.getOperState(), updatedTunnelList.getOperState())) {
LOG.debug("Tunnel Interface {} changed state to {}", originalTunnelList.getTunnelInterfaceName(), operStatus);
ItmTunnelUpdateAlarmWorker itmTunnelUpdateAlarmWorker = new ItmTunnelUpdateAlarmWorker(originalTunnelList, updatedTunnelList);
jobCoordinator.enqueueJob(ITMConstants.ITM_ALARM, itmTunnelUpdateAlarmWorker);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project genius by opendaylight.
the class InterfaceStateListener method update.
@Override
public void update(@Nonnull Interface originalInterface, @Nonnull Interface updatedInterface) {
/*
* update contains only delta, may not include iftype Note: This assumes
* type can't be edited on the fly
*/
if (ItmUtils.isItmIfType(originalInterface.getType())) {
LOG.trace("Interface updated. Old: {} New: {}", originalInterface, updatedInterface);
OperStatus operStatus = updatedInterface.getOperStatus();
if (!Objects.equals(originalInterface.getOperStatus(), updatedInterface.getOperStatus())) {
LOG.debug("Tunnel Interface {} changed state to {}", originalInterface.getName(), operStatus);
jobCoordinator.enqueueJob(ITMConstants.ITM_PREFIX + originalInterface.getName(), () -> updateTunnel(updatedInterface));
}
if (tunnelAggregationHelper.isTunnelAggregationEnabled()) {
tunnelAggregationHelper.updateLogicalTunnelState(originalInterface, updatedInterface, ItmTunnelAggregationHelper.MOD_TUNNEL, dataBroker);
}
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project genius by opendaylight.
the class ItmUtils method buildStateTunnelList.
public static StateTunnelList buildStateTunnelList(StateTunnelListKey tlKey, String name, boolean state, TunnelOperStatus tunOpStatus, IInterfaceManager ifaceManager, DataBroker broker) {
StateTunnelListBuilder stlBuilder = new StateTunnelListBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(name, ifaceManager);
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
if (ifTunnel == null || parentRefs == null) {
return null;
}
DstInfoBuilder dstInfoBuilder = new DstInfoBuilder();
SrcInfoBuilder srcInfoBuilder = new SrcInfoBuilder();
dstInfoBuilder.setTepIp(ifTunnel.getTunnelDestination());
srcInfoBuilder.setTepIp(ifTunnel.getTunnelSource());
// TODO: Add/Improve logic for device type
InternalTunnel internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
ExternalTunnel externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
if (internalTunnel == null && externalTunnel == null) {
// both not present in cache. let us update and try again.
ItmUtils.updateTunnelsCache(broker);
internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
}
if (internalTunnel != null) {
srcInfoBuilder.setTepDeviceId(internalTunnel.getSourceDPN().toString()).setTepDeviceType(TepTypeInternal.class);
dstInfoBuilder.setTepDeviceId(internalTunnel.getDestinationDPN().toString()).setTepDeviceType(TepTypeInternal.class);
stlBuilder.setTransportType(internalTunnel.getTransportType());
} else if (externalTunnel != null) {
ExternalTunnel tunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
srcInfoBuilder.setTepDeviceId(tunnel.getSourceDevice()).setTepDeviceType(getDeviceType(tunnel.getSourceDevice()));
dstInfoBuilder.setTepDeviceId(tunnel.getDestinationDevice()).setTepDeviceType(getDeviceType(tunnel.getDestinationDevice())).setTepIp(ifTunnel.getTunnelDestination());
stlBuilder.setTransportType(tunnel.getTransportType());
}
stlBuilder.setKey(tlKey).setTunnelInterfaceName(name).setOperState(tunOpStatus).setTunnelState(state).setDstInfo(dstInfoBuilder.build()).setSrcInfo(srcInfoBuilder.build());
return stlBuilder.build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project genius by opendaylight.
the class ItmInternalTunnelDeleteWorker method removeTrunkInterface.
private void removeTrunkInterface(TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId, WriteTransaction transaction) {
String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(), new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
LOG.trace("Removing forward Trunk Interface {}", trunkfwdIfName);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkfwdIfName, trunkIdentifier);
transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
ItmUtils.ITM_CACHE.removeInterface(trunkfwdIfName);
// also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, srcTep.getTunnelType()));
transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
ItmUtils.ITM_CACHE.removeInternalTunnel(trunkfwdIfName);
// Release the Ids for the forward trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(srcTep.getInterfaceName(), new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
removeLogicalGroupTunnel(srcDpnId, dstDpnId);
String trunkRevIfName = ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(), new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
LOG.trace("Removing Reverse Trunk Interface {}", trunkRevIfName);
trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkRevIfName, trunkIdentifier);
transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
ItmUtils.ITM_CACHE.removeInternalTunnel(trunkRevIfName);
// also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(srcDpnId, dstDpnId, dstTep.getTunnelType()));
transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
// Release the Ids for the reverse trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(dstTep.getInterfaceName(), new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()), dstTep.getTunnelType().getName());
removeLogicalGroupTunnel(dstDpnId, srcDpnId);
}
Aggregations