use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class InterfacemgrProvider method createVLANInterface.
@Override
public ListenableFuture<Void> createVLANInterface(String interfaceName, String portName, Integer vlanId, String description, IfL2vlan.L2vlanMode l2vlanMode, boolean isExternal) throws InterfaceAlreadyExistsException {
LOG.info("Create VLAN interface : {}", interfaceName);
Interface interfaceOptional = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (interfaceOptional != null) {
LOG.debug("VLAN interface already exists {} ", interfaceOptional.getDescription());
throw new InterfaceAlreadyExistsException(interfaceOptional.getName());
}
IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
if (vlanId != null && vlanId > 0) {
l2vlanBuilder.setVlanId(new VlanId(vlanId));
}
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
InterfaceBuilder interfaceBuilder = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).setDescription(description);
if (isExternal) {
interfaceBuilder.addAugmentation(IfExternal.class, new IfExternalBuilder().setExternal(true).build());
}
InstanceIdentifier<Interface> interfaceIId = interfaceManagerCommonUtils.getInterfaceIdentifier(new InterfaceKey(interfaceName));
ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(CONFIGURATION, interfaceIId, interfaceBuilder.build(), CREATE_MISSING_PARENTS));
ListenableFutures.addErrorLogging(future, LOG, "Failed to (async) write {}", interfaceIId);
return future;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey 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);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class SouthboundUtils method addAllPortsToBridge.
/*
* Add all tunnels ports corresponding to the bridge to the topology config DS.
*/
public void addAllPortsToBridge(BridgeEntry bridgeEntry, InterfaceManagerCommonUtils interfaceManagerCommonUtils, InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid, OvsdbBridgeAugmentation bridgeNew) {
String bridgeName = bridgeNew.getBridgeName().getValue();
LOG.debug("adding all ports to bridge: {}", bridgeName);
List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
if (bridgeInterfaceEntries != null) {
for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
String portName = bridgeInterfaceEntry.getInterfaceName();
InterfaceKey interfaceKey = new InterfaceKey(portName);
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (iface != null) {
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
if (ifTunnel != null) {
if (!(interfacemgrProvider.isItmDirectTunnelsEnabled() && ifTunnel.isInternal())) {
addTunnelPortToBridge(ifTunnel, bridgeIid, iface, portName);
}
if (isOfTunnel(ifTunnel)) {
LOG.debug("Using OFTunnel. Only one tunnel port will be added");
return;
}
}
} else {
LOG.debug("Interface {} not found in config DS", portName);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getDpidFromInterface.
@Override
public ListenableFuture<GetDpidFromInterfaceOutput> getDpidFromInterface(GetDpidFromInterfaceInput input) {
String interfaceName = input.getIntfName();
BigInteger dpId;
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
Interface interfaceInfo = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo == null) {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface in Config DataStore"));
}
if (Tunnel.class.equals(interfaceInfo.getType())) {
ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
dpId = parentRefs.getDatapathNodeIdentifier();
} else {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
if (ifState != null) {
String lowerLayerIf = ifState.getLowerLayerIf().get(0);
NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
} else {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface-state"));
}
}
return Futures.immediateFuture(new GetDpidFromInterfaceOutputBuilder().setDpid(dpId).build());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getTunnelType.
@Override
public ListenableFuture<GetTunnelTypeOutput> getTunnelType(GetTunnelTypeInput input) {
String interfaceName = input.getIntfName();
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
Interface interfaceInfo = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo == null) {
throw new IllegalArgumentException(String.format("Retrieval of Tunnel Type for the key {%s} failed due to missing Interface in Config DataStore", interfaceName));
}
if (Tunnel.class.equals(interfaceInfo.getType())) {
IfTunnel tnl = interfaceInfo.getAugmentation(IfTunnel.class);
Class<? extends TunnelTypeBase> tunType = tnl.getTunnelInterfaceType();
return Futures.immediateFuture(new GetTunnelTypeOutputBuilder().setTunnelType(tunType).build());
} else {
throw new IllegalArgumentException("Retrieval of interface type failed for key: " + interfaceName);
}
}
Aggregations