use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType in project netvirt by opendaylight.
the class ElanServiceProvider method addEtreeInterface.
@Override
public void addEtreeInterface(String etreeInstanceName, String interfaceName, EtreeInterfaceType interfaceType, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(etreeInstanceName);
if (existingElanInstance.isPresent() && existingElanInstance.get().getAugmentation(EtreeInstance.class) != null) {
EtreeInterface etreeInterface = new EtreeInterfaceBuilder().setEtreeInterfaceType(interfaceType).build();
ElanInterface elanInterface;
if (staticMacAddresses == null) {
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
} else {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setStaticMacEntries(staticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Creating the new Etree Interface {}", elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method createDpnToInterface.
private void createDpnToInterface(BigInteger dpId, String infName, Class<? extends InterfaceType> interfaceType) throws Exception {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpId);
InterfaceNameEntryKey interfaceNameEntryKey = new InterfaceNameEntryKey(infName);
InstanceIdentifier<InterfaceNameEntry> intfid = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).child(InterfaceNameEntry.class, interfaceNameEntryKey).build();
InterfaceNameEntryBuilder entryBuilder = new InterfaceNameEntryBuilder().setKey(interfaceNameEntryKey).setInterfaceName(infName);
if (interfaceType != null) {
entryBuilder.setInterfaceType(interfaceType);
}
tx.put(LogicalDatastoreType.OPERATIONAL, intfid, entryBuilder.build(), true);
tx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType 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.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType in project genius by opendaylight.
the class InterfacemgrProvider method getInterfaceInfoFromOperationalDataStore.
@Override
public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName, InterfaceInfo.InterfaceType interfaceType) {
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
if (ifState == null) {
LOG.debug("Interface {} is not present", interfaceName);
return null;
}
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
interfaceInfo.setDpId(IfmUtil.getDpnFromNodeConnectorId(ncId));
interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
}
interfaceInfo.setAdminState(ifState.getAdminStatus() == AdminStatus.Up ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
interfaceInfo.setInterfaceName(interfaceName);
Integer lportTag = ifState.getIfIndex();
interfaceInfo.setInterfaceTag(lportTag);
interfaceInfo.setInterfaceType(interfaceType);
interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
PhysAddress phyAddress = ifState.getPhysAddress();
if (phyAddress != null) {
interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
}
return interfaceInfo;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType in project genius by opendaylight.
the class InterfaceManagerCommonUtils method addStateEntry.
public void addStateEntry(String interfaceName, WriteTransaction interfaceOperShardTransaction, List<ListenableFuture<Void>> futures, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
// allocate lport tag and create interface-if-index map.
// This is done even if interface-state is not present, so that there is
// no throttling
// on id allocation even when multiple southbound port_up events come in
// one shot
Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
if (ifState == null) {
LOG.debug("could not retrieve interface state corresponding to {}, processing will be resumed when " + "interface-state is available", interfaceName);
return;
}
LOG.debug("adding interface state for {}", interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus = ifState.getOperStatus();
PhysAddress physAddress = ifState.getPhysAddress();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus = ifState.getAdminStatus();
NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
}
List<String> childLowerLayerIfList = new ArrayList<>();
childLowerLayerIfList.add(0, nodeConnectorId.getValue());
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
ifaceBuilder.setIfIndex(ifIndex).setType(Other.class);
Class<? extends InterfaceType> interfaceType = null;
if (interfaceInfo != null) {
interfaceType = interfaceInfo.getType();
ifaceBuilder.setType(interfaceType);
}
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
interfaceOperShardTransaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
// install ingress flow
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
if (interfaceInfo != null && interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, interfaceInfo, futures, txRunner, ifIndex);
futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceInfo, Long.toString(portNo), interfaceName, ifIndex));
}
// Update the DpnToInterfaceList OpDS
createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
Aggregations