use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class OvsVlanMemberConfigAddHelper method addConfiguration.
public List<ListenableFuture<Void>> addConfiguration(ParentRefs parentRefs, Interface interfaceNew) {
LOG.info("adding vlan member configuration for interface {}", interfaceNew.getName());
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> interfaceManagerCommonUtils.createInterfaceChildEntry(parentRefs.getParentInterface(), interfaceNew.getName(), tx)));
InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
Interface ifaceParent = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (ifaceParent == null) {
LOG.info("Parent Interface: {} not found when adding child interface: {}", parentRefs.getParentInterface(), interfaceNew.getName());
return futures;
}
IfL2vlan parentIfL2Vlan = ifaceParent.getAugmentation(IfL2vlan.class);
if (parentIfL2Vlan == null || parentIfL2Vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
LOG.error("Parent Interface: {} not of trunk Type when adding trunk-member: {}", ifaceParent, interfaceNew);
return futures;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
interfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), futures, ifState);
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class VlanMemberConfigListener method update.
@Override
public void update(@Nonnull Interface originalInterface, @Nonnull Interface updatedInterface) {
IfL2vlan ifL2vlanNew = updatedInterface.getAugmentation(IfL2vlan.class);
if (ifL2vlanNew == null) {
return;
}
IfL2vlan ifL2vlanOld = originalInterface.getAugmentation(IfL2vlan.class);
if (IfL2vlan.L2vlanMode.TrunkMember == ifL2vlanNew.getL2vlanMode() && IfL2vlan.L2vlanMode.Trunk == ifL2vlanOld.getL2vlanMode()) {
// Trunk subport add use case
addVlanMember(updatedInterface);
return;
} else if (IfL2vlan.L2vlanMode.Trunk == ifL2vlanNew.getL2vlanMode() && IfL2vlan.L2vlanMode.TrunkMember == ifL2vlanOld.getL2vlanMode()) {
// Trunk subport remove use case
removeVlanMember(originalInterface);
} else if (IfL2vlan.L2vlanMode.TrunkMember != ifL2vlanNew.getL2vlanMode()) {
return;
}
ParentRefs parentRefsNew = updatedInterface.getAugmentation(ParentRefs.class);
if (parentRefsNew == null) {
LOG.error("Configuration Error. Attempt to update Vlan Trunk-Member {} without a " + "parent interface", updatedInterface);
return;
}
String lowerLayerIf = parentRefsNew.getParentInterface();
if (lowerLayerIf.equals(updatedInterface.getName())) {
LOG.error("Configuration Error. Attempt to update Vlan Trunk-Member {} with same parent " + "interface name.", updatedInterface);
return;
}
coordinator.enqueueJob(lowerLayerIf, () -> ovsVlanMemberConfigUpdateHelper.updateConfiguration(parentRefsNew, originalInterface, ifL2vlanNew, updatedInterface), IfmConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class VlanMemberConfigListener method addVlanMember.
private void addVlanMember(Interface added) {
ParentRefs parentRefs = added.getAugmentation(ParentRefs.class);
if (parentRefs == null) {
return;
}
String lowerLayerIf = parentRefs.getParentInterface();
if (lowerLayerIf.equals(added.getName())) {
LOG.error("Attempt to add Vlan Trunk-Member {} with same parent interface name.", added);
return;
}
coordinator.enqueueJob(lowerLayerIf, () -> ovsVlanMemberConfigAddHelper.addConfiguration(parentRefs, added), IfmConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.
the class InterfaceManagerCommonUtils method createInterfaceChildEntryIfNotPresent.
// For trunk interfaces, binding to a parent interface which is already
// bound to another trunk interface should not
// be allowed
public boolean createInterfaceChildEntryIfNotPresent(WriteTransaction tx, String parentInterface, String childInterface, IfL2vlan.L2vlanMode l2vlanMode) {
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier);
if (interfaceParentEntry != null) {
List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
if (interfaceChildEntries != null) {
for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
String curChildInterface = interfaceChildEntry.getChildInterface();
if (childInterface.equals(curChildInterface)) {
LOG.trace("Child entry for interface {} already exists", childInterface);
return false;
}
Interface iface = getInterfaceFromConfigDS(curChildInterface);
if (l2vlanMode == IfL2vlan.L2vlanMode.Trunk && isTrunkInterface(iface)) {
LOG.error("Trying to bind child interface {} of type Trunk to parent interface {}," + "but it is already bound to a trunk interface {}", childInterface, parentInterface, curChildInterface);
return false;
}
}
}
}
LOG.info("Creating child interface {} of type {} bound on parent-interface {}", childInterface, l2vlanMode, parentInterface);
createInterfaceChildEntry(parentInterface, childInterface, tx);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk 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().toJava();
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