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.CandidateAlreadyRegisteredException;
+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.utils.clustering.EntityOwnerUtils;
+import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
import org.opendaylight.netvirt.elan.statusanddiag.ElanStatusMonitor;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
ElanInstanceManager elanInstanceManager, ElanBridgeManager bridgeMgr,
DataBroker dataBroker,
ElanInterfaceManager elanInterfaceManager,
- ElanStatusMonitor elanStatusMonitor, ElanUtils elanUtils) {
+ ElanStatusMonitor elanStatusMonitor, ElanUtils elanUtils, EntityOwnershipService entityOwnershipService) {
this.idManager = idManager;
this.interfaceManager = interfaceManager;
this.elanInstanceManager = elanInstanceManager;
this.elanStatusMonitor = elanStatusMonitor;
this.elanUtils = elanUtils;
elanInterfaceManager.setElanUtils(elanUtils);
+ try {
+ EntityOwnerUtils.registerEntityCandidateForOwnerShip(entityOwnershipService,
+ HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_TYPE,
+ null/*listener*/);
+ } catch (CandidateAlreadyRegisteredException e) {
+ LOG.error("failed to register the entity");
+ }
}
public void init() {
deleteStaticMacAddress(elanInstanceName, elanInterface, macEntry.getMacAddress().getValue());
} catch (MacNotFoundException e) {
LOG.error("Mac Not Found Exception {}", e);
- e.printStackTrace();
}
}
}
});
}
+ private void createExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
+ if (interfaceName == null) {
+ LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
+ return;
+ }
+
+ String elanInterfaceName = createIetfInterfaces(elanInstance, interfaceName);
+ addElanInterface(elanInstance.getElanInstanceName(), elanInterfaceName, null, null);
+ }
+
@Override
public void deleteExternalElanNetworks(Node node) {
handleExternalElanNetworks(node, (elanInstance, interfaceName) -> {
});
}
+ private void deleteExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
+ if (interfaceName == null) {
+ LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
+ return;
+ }
+
+ String elanInstanceName = elanInstance.getElanInstanceName();
+ for (String elanInterface : getExternalElanInterfaces(elanInstanceName)) {
+ if (elanInterface.startsWith(interfaceName)) {
+ deleteIetfInterface(elanInterface);
+ deleteElanInterface(elanInstanceName, elanInterface);
+ }
+ }
+ }
+
@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
}
}
- private void createExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
- if (interfaceName == null) {
- LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
- return;
- }
-
- String elanInterfaceName = createIetfInterfaces(elanInstance, interfaceName);
- addElanInterface(elanInstance.getElanInstanceName(), elanInterfaceName, null, null);
- }
-
- private void deleteExternalElanNetwork(ElanInstance elanInstance, String interfaceName) {
- if (interfaceName == null) {
- LOG.trace("No physial interface is attached to {}", elanInstance.getPhysicalNetworkName());
- return;
- }
-
- String elanInstanceName = elanInstance.getElanInstanceName();
- for (String elanInterface : getExternalElanInterfaces(elanInstanceName)) {
- if (elanInterface.startsWith(interfaceName)) {
- deleteIetfInterface(elanInterface);
- deleteElanInterface(elanInstanceName, elanInterface);
- }
- }
- }
-
@Override
public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);