use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase in project genius by opendaylight.
the class InterfacemgrProvider method getPortsOnBridgeByType.
/**
* Get all termination points by type on a given DPN.
*
* @param dpnId
* Datapath Node Identifier
*
* @return If the data at the supplied path exists, returns a Map where key is interfaceType
* and value is list of termination points of given type
*/
@Override
public Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> getPortsOnBridgeByType(BigInteger dpnId) {
Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> portMap;
portMap = new ConcurrentHashMap<>();
List<TerminationPoint> ovsPorts = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
if (ovsPorts != null) {
for (TerminationPoint ovsPort : ovsPorts) {
OvsdbTerminationPointAugmentation portAug = ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (portAug != null && portAug.getInterfaceType() != null) {
portMap.computeIfAbsent(portAug.getInterfaceType(), k -> new ArrayList<>()).add(portAug);
}
}
}
return portMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase in project genius by opendaylight.
the class OvsdbSouthboundTestUtil method updateTerminationPoint.
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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase in project genius by opendaylight.
the class OvsdbSouthboundTestUtil method createTerminationPoint.
public static void createTerminationPoint(DataBroker dataBroker, String interfaceName, Class<? extends InterfaceTypeBase> type, String externalId) 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);
}
if (externalId != null) {
List<InterfaceExternalIds> interfaceExternalIds = new ArrayList<>();
InterfaceExternalIds interfaceExternalIds1 = new InterfaceExternalIdsBuilder().setExternalIdKey("iface-id").setExternalIdValue(externalId).build();
interfaceExternalIds.add(interfaceExternalIds1);
tpAugmentationBuilder.setInterfaceExternalIds(interfaceExternalIds);
}
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(OPERATIONAL, tpId, tpBuilder.build(), true);
tx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase in project netvirt by opendaylight.
the class GeniusProvider method getEgressVxlanPortForNode.
public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(dpnId);
if (tpList == null) {
// Most likely the bridge doesnt exist for this dpnId
LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]", dpnId);
return Optional.empty();
}
for (OvsdbTerminationPointAugmentation tp : tpList) {
if (tp == null) {
// Technically we should never have a list with NULL entries, but
// in a preliminary version of interfaceMgr.getTunnelPortsOnBridge()
// we were getting a list where all termination point entries were
// null. Leaving this check for now for protection.
LOG.error("getEgressVxlanPortForNode received a NULL termination point from tpList on dpnId [{}]", dpnId);
continue;
}
Class<? extends InterfaceTypeBase> ifType = tp.getInterfaceType();
if (ifType.equals(InterfaceTypeVxlan.class)) {
List<Options> tpOptions = tp.getOptions();
for (Options tpOption : tpOptions) {
// From the VXLAN Tunnels, we want the one with the GPE option set
if (tpOption.getKey().getOption().equals(OPTION_KEY_EXTS)) {
if (tpOption.getValue().equals(OPTION_VALUE_EXTS_GPE)) {
return Optional.ofNullable(tp.getOfport());
}
}
}
}
}
LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase in project genius by opendaylight.
the class SouthboundUtils method addTerminationPoint.
private void addTerminationPoint(InstanceIdentifier<?> bridgeIid, String portName, int vlanId, Class<? extends InterfaceTypeBase> type, Map<String, String> options, IfTunnel ifTunnel) {
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
tpAugmentationBuilder.setName(portName);
if (type != null) {
tpAugmentationBuilder.setInterfaceType(type);
}
if (options != null) {
List<Options> optionsList = new ArrayList<>();
for (Map.Entry<String, String> entry : options.entrySet()) {
OptionsBuilder optionsBuilder = new OptionsBuilder();
optionsBuilder.setKey(new OptionsKey(entry.getKey()));
optionsBuilder.setOption(entry.getKey());
optionsBuilder.setValue(entry.getValue());
optionsList.add(optionsBuilder.build());
}
tpAugmentationBuilder.setOptions(optionsList);
}
if (vlanId != 0) {
tpAugmentationBuilder.setVlanMode(OvsdbPortInterfaceAttributes.VlanMode.Access);
tpAugmentationBuilder.setVlanTag(new VlanId(vlanId));
}
if (bfdMonitoringEnabled(ifTunnel)) {
if (isOfTunnel(ifTunnel)) {
LOG.warn("BFD Monitoring not supported for OFTunnels");
} else {
List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
tpAugmentationBuilder.setInterfaceBfd(bfdParams);
}
}
TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
batchingUtils.write(tpIid, tpBuilder.build(), BatchingUtils.EntityType.TOPOLOGY_CONFIG);
}
Aggregations