use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method updateElanInterface.
@Override
public void updateElanInterface(String elanInstanceName, String interfaceName, List<String> updatedStaticMacAddresses, String newDescription) {
Optional<ElanInterface> existingElanInterface = elanInterfaceCache.get(interfaceName);
if (!existingElanInterface.isPresent()) {
return;
}
List<StaticMacEntries> updatedStaticMacEntries = ElanUtils.getStaticMacEntries(updatedStaticMacAddresses);
LOG.debug("updating the ElanInterface with new Mac Entries {}", updatedStaticMacAddresses);
ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(interfaceName).setDescription(newDescription).setStaticMacEntries(updatedStaticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method flushMACTable.
@Override
public void flushMACTable(String elanInstanceName) {
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
if (elanInfo == null) {
return;
}
List<String> elanInterfaces = elanInfo.getElanInterfaces();
if (elanInterfaces == null || elanInterfaces.isEmpty()) {
return;
}
for (String elanInterface : elanInterfaces) {
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
List<MacEntry> macEntries = elanInterfaceMac.getMacEntry();
for (MacEntry macEntry : macEntries) {
deleteStaticMacAddress(elanInterface, macEntry.getMacAddress().getValue());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method addElanInterface.
@Override
public void addElanInterface(String elanInstanceName, String interfaceName, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
if (existingElanInstance.isPresent()) {
ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName));
if (staticMacAddresses != null) {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterfaceBuilder.setStaticMacEntries(staticMacEntries);
}
ElanInterface elanInterface = elanInterfaceBuilder.build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Created the new ELan Interface {}", elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method addEtreeInterface.
@Override
public void addEtreeInterface(String etreeInstanceName, String interfaceName, EtreeInterfaceType interfaceType, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(etreeInstanceName);
if (existingElanInstance.isPresent() && existingElanInstance.get().getAugmentation(EtreeInstance.class) != null) {
EtreeInterface etreeInterface = new EtreeInterfaceBuilder().setEtreeInterfaceType(interfaceType).build();
ElanInterface elanInterface;
if (staticMacAddresses == null) {
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
} else {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setStaticMacEntries(staticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Creating the new Etree Interface {}", elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class VpnElanInterfaceChangeListener method add.
@Override
protected void add(InstanceIdentifier<ElanInterface> key, ElanInterface elanInterface) {
String interfaceName = elanInterface.getName();
if (!elanService.isExternalInterface(interfaceName)) {
LOG.debug("add: Interface {} is not external. Ignoring", interfaceName);
return;
}
Uuid networkId;
try {
networkId = new Uuid(elanInterface.getElanInstanceName());
} catch (IllegalArgumentException e) {
LOG.debug("add: ELAN instance {} for interface {} is not Uuid", elanInterface.getElanInstanceName(), elanInterface.getName());
return;
}
Uuid vpnId = VpnUtil.getExternalNetworkVpnId(broker, networkId);
if (vpnId == null) {
LOG.debug("add: Network {} is not external or vpn-id missing. Ignoring interface {} on elan {}", networkId.getValue(), elanInterface.getName(), elanInterface.getElanInstanceName());
return;
}
VpnInstanceNames vpnInstance = VpnHelper.getVpnInterfaceVpnInstanceNames(vpnId.getValue(), AssociatedSubnetType.V4AndV6Subnets);
List<VpnInstanceNames> listVpn = new ArrayList<>();
listVpn.add(vpnInstance);
VpnInterface vpnInterface = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(interfaceName)).setVpnInstanceNames(listVpn).setScheduledForRemove(Boolean.FALSE).build();
InstanceIdentifier<VpnInterface> vpnInterfaceIdentifier = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vpnInterfaceIdentifier, vpnInterface);
LOG.info("add: Added VPN interface {} with VPN-id {} elanInstance {}", interfaceName, vpnId.getValue(), elanInterface.getElanInstanceName());
}
Aggregations