use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanServiceProvider method deleteExternalElanNetwork.
protected void deleteExternalElanNetwork(ElanInstance elanInstance, BigInteger dpnId) {
String providerIntfName = bridgeMgr.getProviderInterfaceName(dpnId, elanInstance.getPhysicalNetworkName());
String intfName = providerIntfName + IfmConstants.OF_URI_SEPARATOR + elanInstance.getSegmentationId();
Interface memberIntf = interfaceManager.getInterfaceInfoFromConfigDataStore(intfName);
if (memberIntf != null) {
deleteElanInterface(intfName);
deleteIetfInterface(intfName);
LOG.debug("delete vlan prv intf {} in elan {}, dpID {}", intfName, elanInstance.getElanInstanceName(), dpnId);
} else {
LOG.debug("vlan prv intf {} not found in interfacemgr config DS", intfName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanServiceProvider method createElanInstance.
@Override
public boolean createElanInstance(String elanInstanceName, long macTimeout, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
boolean isSuccess = true;
if (existingElanInstance.isPresent()) {
if (compareWithExistingElanInstance(existingElanInstance.get(), macTimeout, description)) {
LOG.debug("Elan Instance is already present in the Operational DS {}", existingElanInstance);
return true;
} else {
ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setMacTimeout(macTimeout).setKey(new ElanInstanceKey(elanInstanceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
LOG.debug("Updating the Elan Instance {} with MAC TIME-OUT {} and Description {}", updateElanInstance, macTimeout, description);
}
} else {
ElanInstance elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setMacTimeout(macTimeout).setDescription(description).setKey(new ElanInstanceKey(elanInstanceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
LOG.debug("Creating the new Elan Instance {}", elanInstance);
}
return isSuccess;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanServiceProvider method getEgressMatchesForElanInstance.
@Override
public List<MatchInfoBase> getEgressMatchesForElanInstance(String elanInstanceName) {
ElanInstance elanInstance = getElanInstance(elanInstanceName);
if (elanInstance == null) {
LOG.debug("No ELAN instance found for {}", elanInstanceName);
return Collections.emptyList();
}
Long elanTag = elanInstance.getElanTag();
if (elanTag == null) {
LOG.debug("No ELAN tag found for {}", elanInstanceName);
return Collections.emptyList();
}
return Collections.singletonList(new NxMatchRegister(ElanConstants.ELAN_REG_ID, elanTag, MetaDataUtil.getElanMaskForReg()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class AssociateHwvtepToElanJob method createLogicalSwitch.
private ListenableFuture<Void> createLogicalSwitch() {
final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanInstance.getElanInstanceName());
String segmentationId = ElanUtils.getVxlanSegmentationId(elanInstance).toString();
String replicationMode = "";
LOG.trace("logical switch {} is created on {} with VNI {}", logicalSwitchName, l2GatewayDevice.getHwvtepNodeId(), segmentationId);
NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
String dbVersion = HwvtepUtils.getDbVersion(broker, hwvtepNodeId);
if (SouthboundUtils.compareDbVersionToMinVersion(dbVersion, "1.6.0")) {
replicationMode = "source_node";
}
LOG.trace("logical switch {} has schema version {}, replication mode set to {}", logicalSwitchName, dbVersion, replicationMode);
LogicalSwitches logicalSwitch = HwvtepSouthboundUtils.createLogicalSwitch(logicalSwitchName, elanInstance.getDescription(), segmentationId, replicationMode);
ListenableFuture<Void> lsCreateFuture = HwvtepUtils.addLogicalSwitch(broker, hwvtepNodeId, logicalSwitch);
Futures.addCallback(lsCreateFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void noarg) {
// Listener will be closed after all configuration completed
// on hwvtep by
// listener itself
LOG.trace("Successful in initiating logical switch {} creation", logicalSwitchName);
}
@Override
public void onFailure(Throwable error) {
LOG.error("Failed logical switch {} creation", logicalSwitchName, error);
}
}, MoreExecutors.directExecutor());
return lsCreateFuture;
}
Aggregations