use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.
the class ElanL2GatewayUtils method updateVlanBindingsInL2GatewayDevice.
/**
* Update vlan bindings in l2 gateway device.
*
* @param nodeId
* the node id
* @param logicalSwitchName
* the logical switch name
* @param hwVtepDevice
* the hardware device
* @param defaultVlanId
* the default vlan id
* @return the listenable future
*/
public ListenableFuture<Void> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
if (hwVtepDevice == null || hwVtepDevice.getInterfaces() == null || hwVtepDevice.getInterfaces().isEmpty()) {
String errMsg = "HwVtepDevice is null or interfaces are empty.";
LOG.error(errMsg);
return Futures.immediateFailedFuture(new RuntimeException(errMsg));
}
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
// Removed the check for checking terminationPoint present in OP or not
// for coniguring vlan bindings
// As we are not any more dependent on it , plugin takes care of this
// with port reconcilation.
List<VlanBindings> vlanBindings = new ArrayList<>();
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
}
HwvtepUtils.mergeVlanBindings(tx, nodeId, hwVtepDevice.getDeviceName(), deviceInterface.getInterfaceName(), vlanBindings);
}
LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}, LogicalSwitch: {}", nodeId.getValue(), logicalSwitchName);
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.
the class ElanItmUtils method buildItmEgressActions.
/**
* Builds the list of actions to be taken when sending the packet over external port such as tunnel, physical
* port etc.
*
* @param interfaceName
* the interface name
* @param tunnelKey
* can be VNI for VxLAN tunnel interfaces, Gre Key for GRE
* tunnels, etc.
* @return the list
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
List<Action> result = Collections.emptyList();
try {
GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
if (egressActionsOutputFuture.get().isSuccessful()) {
GetEgressActionsForInterfaceOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
result = egressActionsOutput.getAction();
}
} catch (Exception e) {
LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
}
if (result == null || result.isEmpty()) {
LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.
the class ElanUtils method updateOperationalDataStore.
/**
* Updates the Elan information in the Operational DS. It also updates the
* ElanInstance in the Config DS by setting the adquired elanTag.
*
* @param idManager
* the id manager
* @param elanInstanceAdded
* the elan instance added
* @param elanInterfaces
* the elan interfaces
* @param tx
* transaction
*
* @return the updated ELAN instance.
*/
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, WriteTransaction tx) {
String elanInstanceName = elanInstanceAdded.getElanInstanceName();
Long elanTag = elanInstanceAdded.getElanTag();
if (elanTag == null || elanTag == 0L) {
elanTag = retrieveNewElanTag(idManager, elanInstanceName);
}
Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).setKey(new ElanKey(elanInstanceName)).build();
// Add the ElanState in the elan-state operational data-store
tx.put(LogicalDatastoreType.OPERATIONAL, getElanInstanceOperationalDataPath(elanInstanceName), elanInfo, WriteTransaction.CREATE_MISSING_PARENTS);
// Add the ElanMacTable in the elan-mac-table operational data-store
MacTable elanMacTable = new MacTableBuilder().setKey(new MacTableKey(elanInstanceName)).build();
tx.put(LogicalDatastoreType.OPERATIONAL, getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).setKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
long etreeLeafTag = -1;
if (isEtreeInstance(elanInstanceAdded)) {
etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
elanTagNameBuilder.addAugmentation(EtreeLeafTagName.class, etreeLeafTagName);
addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, tx);
}
ElanTagName elanTagName = elanTagNameBuilder.build();
// Add the ElanTag to ElanName in the elan-tag-name Operational
// data-store
tx.put(LogicalDatastoreType.OPERATIONAL, getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
// Updates the ElanInstance Config DS by setting the just acquired
// elanTag
ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Long.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).setKey(elanInstanceAdded.getKey()).setElanTag(elanTag);
if (isEtreeInstance(elanInstanceAdded)) {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
elanInstanceBuilder.addAugmentation(EtreeInstance.class, etreeInstance);
}
ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
tx.merge(LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag, WriteTransaction.CREATE_MISSING_PARENTS);
return elanInstanceWithTag;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.
the class ElanUtils method getExternalElanInterface.
public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
DpnInterfaces dpnInterfaces = getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null) {
LOG.trace("Elan {} does not have interfaces in DPN {}", elanInstanceName, dpnId);
return null;
}
for (String dpnInterface : dpnInterfaces.getInterfaces()) {
if (interfaceManager.isExternalInterface(dpnInterface)) {
return dpnInterface;
}
}
LOG.trace("Elan {} does not have any external interace attached to DPN {}", elanInstanceName, dpnId);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces in project netvirt by opendaylight.
the class ElanServiceProvider method createIetfInterfaces.
/**
* Create ietf-interfaces based on the ELAN segment type.<br>
* For segment type flat - create transparent interface pointing to the
* patch-port attached to the physnet port.<br>
* For segment type vlan - create trunk interface pointing to the patch-port
* attached to the physnet port + trunk-member interface pointing to the
* trunk interface.
*
* @param elanInstance
* ELAN instance
* @param parentRef
* parent interface name
* @return the name of the interface to be added to the ELAN instance i.e.
* trunk-member name for vlan network and transparent for flat
* network or null otherwise
*/
private String createIetfInterfaces(ElanInstance elanInstance, String parentRef) {
String interfaceName = null;
try {
String trunkName = getTrunkInterfaceName(parentRef);
// trunk interface may have been created by other vlan network
Interface trunkInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(trunkName);
if (trunkInterface == null) {
interfaceManager.createVLANInterface(trunkName, parentRef, null, null, IfL2vlan.L2vlanMode.Trunk, true);
}
if (ElanUtils.isFlat(elanInstance)) {
interfaceName = trunkName;
} else if (ElanUtils.isVlan(elanInstance)) {
Long segmentationId = elanInstance.getSegmentationId();
interfaceName = parentRef + IfmConstants.OF_URI_SEPARATOR + segmentationId;
interfaceManager.createVLANInterface(interfaceName, trunkName, segmentationId.intValue(), null, IfL2vlan.L2vlanMode.TrunkMember, true);
}
} catch (InterfaceAlreadyExistsException e) {
LOG.trace("Interface {} was already created", interfaceName);
}
return interfaceName;
}
Aggregations