use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry in project netvirt by opendaylight.
the class QosNeutronUtils method setPortBandwidthLimits.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void setPortBandwidthLimits(Port port, BandwidthLimitRules bwLimit, WriteTransaction writeConfigTxn) {
if (!qosEosHandler.isQosClusterOwner()) {
LOG.trace("Not Qos Cluster Owner. Ignoring setting bandwidth limits");
return;
}
LOG.trace("Setting bandwidth limits {} on Port {}", port, bwLimit);
BigInteger dpId = getDpnForInterface(port.getUuid().getValue());
if (dpId.equals(BigInteger.ZERO)) {
LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
return;
}
OvsdbBridgeRef bridgeRefEntry = getBridgeRefEntryFromOperDS(dpId);
Optional<Node> bridgeNode = MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntry.getValue().firstIdentifierOf(Node.class), dataBroker);
TerminationPoint tp = SouthboundUtils.getTerminationPointByExternalId(bridgeNode.get(), port.getUuid().getValue());
OvsdbTerminationPointAugmentation ovsdbTp = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(ovsdbTp.getName());
tpAugmentationBuilder.setIngressPolicingRate(bwLimit.getMaxKbps().longValue());
tpAugmentationBuilder.setIngressPolicingBurst(bwLimit.getMaxBurstKbps().longValue());
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setKey(tp.getKey());
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
try {
if (writeConfigTxn != null) {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), tpBuilder.build());
} else {
MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), tpBuilder.build());
}
} catch (Exception e) {
LOG.error("Failure while setting BwLimitRule {} to port {}", bwLimit, port, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry 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.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry in project genius by opendaylight.
the class OvsInterfaceConfigAddHelper method addTunnelConfiguration.
private void addTunnelConfiguration(ParentRefs parentRefs, Interface interfaceNew, IfTunnel ifTunnel, WriteTransaction defaultConfigShardTransaction, WriteTransaction defaultOperShardTransaction, List<ListenableFuture<Void>> futures) {
if (parentRefs == null) {
LOG.warn("ParentRefs for interface: {} Not Found. " + "Creation of Tunnel OF-Port not supported when dpid not provided.", interfaceNew.getName());
return;
}
BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
if (dpId == null) {
LOG.warn("dpid for interface: {} Not Found. No DPID provided. " + "Creation of OF-Port not supported.", interfaceNew.getName());
return;
}
LOG.info("adding tunnel configuration for interface {}", interfaceNew.getName());
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
futures.add(addLogicalTunnelGroup(interfaceNew, defaultOperShardTransaction));
return;
}
boolean createTunnelPort = true;
final String tunnelName;
if (SouthboundUtils.isOfTunnel(ifTunnel)) {
BridgeEntry bridgeEntry = interfaceMetaUtils.getBridgeEntryFromConfigDS(dpId);
createTunnelPort = bridgeEntry == null || bridgeEntry.getBridgeInterfaceEntry() == null || bridgeEntry.getBridgeInterfaceEntry().isEmpty();
tunnelName = SouthboundUtils.generateOfTunnelName(dpId, ifTunnel);
interfaceManagerCommonUtils.createInterfaceChildEntry(tunnelName, interfaceNew.getName(), defaultConfigShardTransaction);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = interfaceManagerCommonUtils.getInterfaceState(tunnelName);
if (interfaceState != null) {
coordinator.enqueueJob(tunnelName, () -> ovsInterfaceStateAddHelper.addState(interfaceNew.getName(), interfaceState));
}
} else {
tunnelName = interfaceNew.getName();
}
String parentInterface = parentRefs.getParentInterface();
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class) && !Strings.isNullOrEmpty(parentInterface)) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: createInterfaceChildEntry for {} in logical group {}", tunnelName, parentInterface);
interfaceManagerCommonUtils.createInterfaceChildEntry(parentInterface, tunnelName, defaultConfigShardTransaction);
}
LOG.debug("creating bridge interfaceEntry in ConfigDS {}", dpId);
interfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(dpId, interfaceNew.getName());
// create bridge on switch, if switch is connected
BridgeRefEntry bridgeRefEntry = interfaceMetaUtils.getBridgeRefEntryFromOperDS(dpId);
if (bridgeRefEntry != null && bridgeRefEntry.getBridgeReference() != null) {
LOG.debug("creating bridge interface on dpn {}", dpId);
InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid = (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue();
if (createTunnelPort) {
southboundUtils.addPortToBridge(bridgeIid, interfaceNew, tunnelName);
}
// if TEP is already configured on switch, start LLDP monitoring and
// program tunnel ingress flow
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceNew.getName());
if (ifState != null) {
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(ncId);
interfaceManagerCommonUtils.addTunnelIngressFlow(ifTunnel, dpId, portNo, interfaceNew.getName(), ifState.getIfIndex());
ListenableFuture<Void> future = FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceNew, Long.toString(portNo), interfaceNew.getName(), ifState.getIfIndex());
futures.add(future);
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
public void onSuccess(@Nullable Void result) {
// start LLDP monitoring for the tunnel interface
alivenessMonitorUtils.startLLDPMonitoring(ifTunnel, interfaceNew.getName());
}
@Override
public void onFailure(@Nonnull Throwable throwable) {
LOG.error("Unable to add tunnel monitoring", throwable);
}
}, MoreExecutors.directExecutor());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry in project genius by opendaylight.
the class OvsInterfaceConfigUpdateHelper method handleTunnelMonitorUpdates.
/*
* if the tunnel monitoring attributes have changed, handle it based on the
* tunnel type. As of now internal vxlan tunnels use LLDP monitoring and
* external tunnels use BFD monitoring.
*/
private void handleTunnelMonitorUpdates(WriteTransaction transaction, Interface interfaceNew, Interface interfaceOld) {
LOG.debug("tunnel monitoring attributes modified for interface {}", interfaceNew.getName());
// update termination point on switch, if switch is connected
BridgeRefEntry bridgeRefEntry = interfaceMetaUtils.getBridgeReferenceForInterface(interfaceNew);
IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
if (SouthboundUtils.isMonitorProtocolBfd(ifTunnel) && interfaceMetaUtils.bridgeExists(bridgeRefEntry)) {
SouthboundUtils.updateBfdParamtersForTerminationPoint(bridgeRefEntry.getBridgeReference().getValue(), interfaceNew.getAugmentation(IfTunnel.class), interfaceNew.getName(), transaction);
} else {
// update lldp tunnel monitoring attributes for an internal vxlan
// tunnel interface
alivenessMonitorUtils.handleTunnelMonitorUpdates(interfaceOld, interfaceNew);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry in project genius by opendaylight.
the class InterfaceMetaUtils method createBridgeRefEntry.
public static void createBridgeRefEntry(BigInteger dpnId, InstanceIdentifier<?> bridgeIid, WriteTransaction tx) {
LOG.debug("Creating bridge ref entry for dpn: {} bridge: {}", dpnId, bridgeIid);
BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
InstanceIdentifier<BridgeRefEntry> bridgeEntryId = InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
BridgeRefEntryBuilder tunnelDpnBridgeEntryBuilder = new BridgeRefEntryBuilder().setKey(bridgeRefEntryKey).setDpid(dpnId).setBridgeReference(new OvsdbBridgeRef(bridgeIid));
tx.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
}
Aggregations