import java.util.concurrent.Future;
import java.util.function.BiFunction;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.interfacemanager.exceptions.InterfaceAlreadyExistsException;
import org.opendaylight.genius.interfacemanager.globals.IfmConstants;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
-import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
-import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
-import org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils;
import org.opendaylight.netvirt.elan.statusanddiag.ElanStatusMonitor;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
-import org.opendaylight.netvirt.elan.utils.ElanForwardingEntriesHandler;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.elanmanager.exceptions.MacNotFoundException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface;
public class ElanServiceProvider implements IElanService {
- private static final Logger logger = LoggerFactory.getLogger(ElanServiceProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ElanServiceProvider.class);
private final IdManagerService idManager;
private final IInterfaceManager interfaceManager;
this.broker = dataBroker;
this.elanStatusMonitor = elanStatusMonitor;
this.elanUtils = elanUtils;
- elanInstanceManager.setElanUtils(elanUtils);
elanInterfaceManager.setElanUtils(elanUtils);
}
- public static ElanUtils getElanutils() {
- return ElanServiceProvider.elanUtils;
- }
-
public void init() {
- logger.info("Starting ElnaServiceProvider");
+ LOG.info("Starting ElnaServiceProvider");
elanStatusMonitor.reportStatus("STARTING");
try {
createIdPool();
elanStatusMonitor.reportStatus("OPERATIONAL");
} catch (Exception e) {
- logger.error("Error initializing services", e);
+ LOG.error("Error initializing services", e);
elanStatusMonitor.reportStatus("ERROR");
}
}
.setLow(ElanConstants.ELAN_ID_LOW_VALUE).setHigh(ElanConstants.ELAN_ID_HIGH_VALUE).build();
try {
Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
- if ((result != null) && (result.get().isSuccessful())) {
- logger.debug("ELAN Id Pool is created successfully");
+ if (result != null && result.get().isSuccessful()) {
+ LOG.debug("ELAN Id Pool is created successfully");
}
} catch (Exception e) {
- logger.error("Failed to create ELAN Id pool {}", e);
+ LOG.error("Failed to create ELAN Id pool {}", e);
}
}
boolean isSuccess = true;
if (existingElanInstance != null) {
if (compareWithExistingElanInstance(existingElanInstance, macTimeout, description)) {
- logger.debug("Elan Instance is already present in the Operational DS {}", existingElanInstance);
+ LOG.debug("Elan Instance is already present in the Operational DS {}", existingElanInstance);
return true;
} else {
ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName)
.setKey(new ElanInstanceKey(elanInstanceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
- logger.debug("Updating the Elan Instance {} with MAC TIME-OUT %l and Description %s ",
+ LOG.debug("Updating the Elan Instance {} with MAC TIME-OUT %l and Description %s ",
updateElanInstance, macTimeout, description);
}
} else {
.build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
- logger.debug("Creating the new Elan Instance {}", elanInstance);
+ LOG.debug("Creating the new Elan Instance {}", elanInstance);
}
return isSuccess;
}
boolean isSuccess = true;
if (existingElanInstance != null) {
if (compareWithExistingElanInstance(existingElanInstance, macTimeout, description)) {
- logger.warn("Etree Instance is already present in the Operational DS {}", existingElanInstance);
+ LOG.warn("Etree Instance is already present in the Operational DS {}", existingElanInstance);
return true;
} else {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().build();
.addAugmentation(EtreeInstance.class, etreeInstance).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
- logger.debug("Updating the Etree Instance {} with MAC TIME-OUT %l and Description %s ",
+ LOG.debug("Updating the Etree Instance {} with MAC TIME-OUT %l and Description %s ",
updateElanInstance, macTimeout, description);
}
} else {
.addAugmentation(EtreeInstance.class, etreeInstance).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
- logger.debug("Creating the new Etree Instance {}", elanInstance);
+ LOG.debug("Creating the new Etree Instance {}", elanInstance);
}
return isSuccess;
}
+ @Override
+ public EtreeInterface getEtreeInterfaceByElanInterfaceName(String elanInterface) {
+ return ElanUtils.getEtreeInterfaceByElanInterfaceName(broker, elanInterface);
+ }
+
public static boolean compareWithExistingElanInstance(ElanInstance existingElanInstance, long macTimeOut,
String description) {
boolean isEqual = false;
boolean isSuccess = false;
ElanInstance existingElanInstance = elanInstanceManager.getElanInstanceByName(elanInstanceName);
if (existingElanInstance == null) {
- logger.debug("Elan Instance is not present {}", existingElanInstance);
+ LOG.debug("Elan Instance is not present {}", existingElanInstance);
return isSuccess;
}
- logger.debug("Deletion of the existing Elan Instance {}", existingElanInstance);
+ LOG.debug("Deletion of the existing Elan Instance {}", existingElanInstance);
ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInstanceConfigurationDataPath(elanInstanceName));
isSuccess = true;
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
- logger.debug("Creating the new Etree Interface {}", elanInterface);
+ LOG.debug("Creating the new Etree Interface {}", elanInterface);
}
}
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
- logger.debug("Creating the new ELan Interface {}", elanInterface);
+ LOG.debug("Creating the new ELan Interface {}", elanInterface);
}
}
@Override
public void updateElanInterface(String elanInstanceName, String interfaceName,
List<String> updatedStaticMacAddresses, String newDescription) {
- ElanInterface existingElanInterface = elanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName);
if (existingElanInterface == null) {
return;
}
List<PhysAddress> updatedMacAddresses = getPhysAddress(updatedStaticMacAddresses);
List<PhysAddress> updatedPhysAddress = getUpdatedPhyAddress(existingMacAddress, updatedMacAddresses);
if (updatedPhysAddress.size() > 0) {
- logger.debug("updating the ElanInterface with new Mac Entries {}", updatedStaticMacAddresses);
+ LOG.debug("updating the ElanInterface with new Mac Entries {}", updatedStaticMacAddresses);
ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName)
.setName(interfaceName).setDescription(newDescription).setStaticMacEntries(updatedPhysAddress)
.setKey(new ElanInterfaceKey(interfaceName)).build();
@Override
public void deleteEtreeInterface(String elanInstanceName, String interfaceName) {
deleteElanInterface(elanInstanceName, interfaceName);
- logger.debug("deleting the Etree Interface {}", interfaceName);
+ LOG.debug("deleting the Etree Interface {}", interfaceName);
}
@Override
public void deleteElanInterface(String elanInstanceName, String interfaceName) {
- ElanInterface existingElanInterface = elanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName);
if (existingElanInterface != null) {
ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName));
- logger.debug("deleting the Elan Interface {}", existingElanInterface);
+ LOG.debug("deleting the Elan Interface {}", existingElanInterface);
}
}
@Override
public void addStaticMacAddress(String elanInstanceName, String interfaceName, String macAddress) {
- ElanInterface existingElanInterface = elanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName);
PhysAddress updateStaticMacAddress = new PhysAddress(macAddress);
if (existingElanInterface != null) {
List<PhysAddress> existingMacAddress = existingElanInterface.getStaticMacEntries();
@Override
public void deleteStaticMacAddress(String elanInstanceName, String interfaceName, String macAddress)
throws MacNotFoundException {
- ElanInterface existingElanInterface = elanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName);
PhysAddress physAddress = new PhysAddress(macAddress);
if (existingElanInterface == null) {
return;
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
} else {
- throw new MacNotFoundException("Mac Not Found Exception");
+ throw new MacNotFoundException("deleteStaticMacAddress did not find MAC: " + macAddress);
}
}
@Override
public Collection<MacEntry> getElanMacTable(String elanInstanceName) {
- Elan elanInfo = elanUtils.getElanByName(elanInstanceName);
+ Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
List<MacEntry> macAddress = new ArrayList<>();
if (elanInfo == null) {
return macAddress;
@Override
public void flushMACTable(String elanInstanceName) {
- Elan elanInfo = elanUtils.getElanByName(elanInstanceName);
+ Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
if (elanInfo == null) {
return;
}
try {
deleteStaticMacAddress(elanInstanceName, elanInterface, macEntry.getMacAddress().getValue());
} catch (MacNotFoundException e) {
- logger.error("Mac Not Found Exception {}", e);
+ LOG.error("Mac Not Found Exception {}", e);
e.printStackTrace();
}
}
@Override
public ElanInstance getElanInstance(String elanName) {
- return elanUtils.getElanInstanceByName(elanName);
+ return ElanUtils.getElanInstanceByName(broker, elanName);
}
@Override
@Override
public void createExternalElanNetworks(Node node) {
- handleExternalElanNetworks(node, new BiFunction<ElanInstance, String, Void>() {
-
- @Override
- public Void apply(ElanInstance elanInstance, String interfaceName) {
- createExternalElanNetwork(elanInstance, interfaceName);
- return null;
- }
+ handleExternalElanNetworks(node, (elanInstance, interfaceName) -> {
+ createExternalElanNetwork(elanInstance, interfaceName);
+ return null;
});
}
@Override
public void createExternalElanNetwork(ElanInstance elanInstance) {
- handleExternalElanNetwork(elanInstance, new BiFunction<ElanInstance, String, Void>() {
-
- @Override
- public Void apply(ElanInstance elanInstance, String interfaceName) {
- createExternalElanNetwork(elanInstance, interfaceName);
- return null;
- }
-
+ handleExternalElanNetwork(elanInstance, (elanInstance1, interfaceName) -> {
+ createExternalElanNetwork(elanInstance1, interfaceName);
+ return null;
});
}
@Override
public void deleteExternalElanNetworks(Node node) {
- handleExternalElanNetworks(node, new BiFunction<ElanInstance, String, Void>() {
-
- @Override
- public Void apply(ElanInstance elanInstance, String interfaceName) {
- deleteExternalElanNetwork(elanInstance, interfaceName);
- return null;
- }
+ handleExternalElanNetworks(node, (elanInstance, interfaceName) -> {
+ deleteExternalElanNetwork(elanInstance, interfaceName);
+ return null;
});
}
@Override
public void deleteExternalElanNetwork(ElanInstance elanInstance) {
- handleExternalElanNetwork(elanInstance, new BiFunction<ElanInstance, String, Void>() {
-
- @Override
- public Void apply(ElanInstance elanInstance, String interfaceName) {
- deleteExternalElanNetwork(elanInstance, interfaceName);
- return null;
- }
-
+ handleExternalElanNetwork(elanInstance, (elanInstance1, interfaceName) -> {
+ deleteExternalElanNetwork(elanInstance1, interfaceName);
+ return null;
});
}
List<ElanInstance> elanInstances = getElanInstances();
if (elanInstances == null || elanInstances.isEmpty()) {
- logger.trace("No ELAN instances found");
+ LOG.trace("No ELAN instances found");
return;
}
private void createExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
if (interfaceName == null) {
- logger.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
+ LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
return;
}
private void deleteExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
if (interfaceName == null) {
- logger.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
+ LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
return;
}
public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null) {
- logger.trace("Elan {} does not have interfaces in DPN {}", elanInstanceName, dpnId);
+ LOG.trace("Elan {} does not have interfaces in DPN {}", elanInstanceName, dpnId);
return null;
}
}
}
- logger.trace("Elan {} does not have any external interace attached to DPN {}", elanInstanceName, dpnId);
+ LOG.trace("Elan {} does not have any external interace attached to DPN {}", elanInstanceName, dpnId);
return null;
}
public Collection<String> getExternalElanInterfaces(String elanInstanceName) {
List<String> elanInterfaces = getElanInterfaces(elanInstanceName);
if (elanInterfaces == null || elanInterfaces.isEmpty()) {
- logger.trace("No ELAN interfaces defined for {}", elanInstanceName);
+ LOG.trace("No ELAN interfaces defined for {}", elanInstanceName);
return Collections.emptySet();
}
return elanUtils.isExternal(interfaceName);
}
+ @Override
+ public ElanInterface getElanInterfaceByElanInterfaceName(String interfaceName) {
+ return ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName);
+ }
+
/**
* Create ietf-interfaces based on the ELAN segment type.<br>
* For segment type flat - create transparent interface pointing to the
IfL2vlan.L2vlanMode.TrunkMember, true);
}
} catch (InterfaceAlreadyExistsException e) {
- logger.trace("Interface {} was already created", interfaceName);
+ LOG.trace("Interface {} was already created", interfaceName);
}
return interfaceName;
InstanceIdentifier<Interface> interfaceInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class)
.child(Interface.class, interfaceKey).build();
MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
- logger.debug("Deleting IETF interface {}", interfaceName);
+ LOG.debug("Deleting IETF interface {}", interfaceName);
}
private String getExtInterfaceName(Node node, String physicalNetworkName) {
String providerMappingValue = bridgeMgr.getProviderMappingValue(node, physicalNetworkName);
if (providerMappingValue == null) {
- logger.trace("No provider mapping found for physicalNetworkName {} node {}", physicalNetworkName,
+ LOG.trace("No provider mapping found for physicalNetworkName {} node {}", physicalNetworkName,
node.getNodeId().getValue());
return null;
}
List<ElanInstance> elanInstances = getElanInstances();
if (elanInstances == null || elanInstances.isEmpty()) {
- logger.trace("No ELAN instances found");
+ LOG.trace("No ELAN instances found");
return;
}
private void handleExternalElanNetwork(ElanInstance elanInstance, BiFunction<ElanInstance, String, Void> function) {
String elanInstanceName = elanInstance.getElanInstanceName();
if (elanInstance.getPhysicalNetworkName() == null) {
- logger.trace("No physical network attached to {}", elanInstanceName);
+ LOG.trace("No physical network attached to {}", elanInstanceName);
return;
}
List<Node> nodes = bridgeMgr.southboundUtils.getOvsdbNodes();
if (nodes == null || nodes.isEmpty()) {
- logger.trace("No OVS nodes found while creating external network for ELAN {}",
+ LOG.trace("No OVS nodes found while creating external network for ELAN {}",
elanInstance.getElanInstanceName());
return;
}