List<PhysAddress> existingPhysAddress = original.getStaticMacEntries(); List<PhysAddress> updatedPhysAddress = update.getStaticMacEntries(); if (updatedPhysAddress != null && !updatedPhysAddress.isEmpty()) { List<PhysAddress> existingClonedPhyAddress = new ArrayList<>();
@Override public void addStaticMacAddress(String elanInstanceName, String interfaceName, String macAddress) { ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName); PhysAddress updateStaticMacAddress = new PhysAddress(macAddress); if (existingElanInterface != null) { List<PhysAddress> existingMacAddress = existingElanInterface.getStaticMacEntries(); if (existingMacAddress.contains(updateStaticMacAddress)) { return; } existingMacAddress.add(updateStaticMacAddress); ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName) .setName(interfaceName).setStaticMacEntries(existingMacAddress) .setDescription(existingElanInterface.getDescription()).setKey(new ElanInterfaceKey(interfaceName)) .build(); MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface); } }
@Override public void updateElanInterface(String elanInstanceName, String interfaceName, List<String> updatedStaticMacAddresses, String newDescription) { ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName); if (existingElanInterface == null) { return; } List<PhysAddress> existingMacAddress = existingElanInterface.getStaticMacEntries(); List<PhysAddress> updatedMacAddresses = getPhysAddress(updatedStaticMacAddresses); List<PhysAddress> updatedPhysAddress = getUpdatedPhyAddress(existingMacAddress, updatedMacAddresses); if (updatedPhysAddress.size() > 0) { 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(); MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface); } }
WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction(); installEntriesForElanInterface(elanInstance, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx); List<PhysAddress> staticMacAddresses = elanInterface.getStaticMacEntries(); if (staticMacAddresses != null) { boolean isInterfaceOperational = isOperational(interfaceInfo);
@Override public void deleteStaticMacAddress(String elanInstanceName, String interfaceName, String macAddress) throws MacNotFoundException { ElanInterface existingElanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, interfaceName); PhysAddress physAddress = new PhysAddress(macAddress); if (existingElanInterface == null) { return; } List<PhysAddress> existingMacAddress = existingElanInterface.getStaticMacEntries(); if (existingMacAddress.contains(physAddress)) { existingMacAddress.remove(physAddress); ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName) .setName(interfaceName).setStaticMacEntries(existingMacAddress) .setDescription(existingElanInterface.getDescription()).setKey(new ElanInterfaceKey(interfaceName)) .build(); MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface); } else { throw new MacNotFoundException("deleteStaticMacAddress did not find MAC: " + macAddress); } }