Search in sources :

Example 31 with ElanInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.

the class ElanServiceTestBase method addElanInterface.

public void addElanInterface(String elanInstanceName, InterfaceInfo interfaceInfo, String prefix) {
    ElanInstance existingElanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    String interfaceName = interfaceInfo.getInterfaceName();
    if (existingElanInstance != null) {
        ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName));
        StaticMacEntriesBuilder staticMacEntriesBuilder = new StaticMacEntriesBuilder();
        List<StaticMacEntries> staticMacEntries = new ArrayList<>();
        List<PhysAddress> physAddressList = Collections.singletonList(new PhysAddress(interfaceInfo.getMacAddress()));
        for (PhysAddress physAddress : physAddressList) {
            staticMacEntries.add(staticMacEntriesBuilder.setMacAddress(physAddress).setIpPrefix(new IpAddress(new Ipv4Address(prefix))).build());
        }
        elanInterfaceBuilder.setStaticMacEntries(staticMacEntries);
        ElanInterface elanInterface = elanInterfaceBuilder.build();
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) StaticMacEntriesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ArrayList(java.util.ArrayList) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 32 with ElanInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.

the class AclLiveStatisticsRpcServiceTest method newElanInterface.

protected void newElanInterface(String elanName, String portName, boolean isWrite) throws TransactionCommitFailedException {
    ElanInterface elanInterface = new ElanInterfaceBuilder().setName(portName).setElanInstanceName(elanName).build();
    InstanceIdentifier<ElanInterface> id = AclServiceUtils.getElanInterfaceConfigurationDataPathId(portName);
    if (isWrite) {
        singleTransactionDataBroker.syncWrite(CONFIGURATION, id, elanInterface);
    } else {
        singleTransactionDataBroker.syncDelete(CONFIGURATION, id);
    }
}
Also used : ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder)

Example 33 with ElanInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.

the class AclElanInterfaceListener method add.

@Override
protected void add(InstanceIdentifier<ElanInterface> key, ElanInterface elanInterface) {
    String interfaceId = elanInterface.getName();
    AclInterface aclInterface = aclInterfaceCache.updateIfPresent(interfaceId, (prevAclInterface, builder) -> {
        if (prevAclInterface.getElanId() == null) {
            ElanInstance elanInfo = AclServiceUtils.getElanInstanceByName(elanInterface.getElanInstanceName(), dataBroker);
            builder.elanId(elanInfo.getElanTag());
            return true;
        }
        return false;
    });
    if (aclInterface == null) {
        LOG.debug("On Add event, ignore if AclInterface was not found in cache or was not updated");
        return;
    }
    if (aclInterface.getDpId() != null && aclClusterUtil.isEntityOwner()) {
        // Notify ADD flows, if InterfaceStateListener has processed before ELAN-ID getting populated
        LOG.debug("On add event, notify ACL service manager to BIND/ADD ACL for interface: {}", aclInterface);
        aclServiceManager.notify(aclInterface, null, Action.BIND);
        aclServiceManager.notify(aclInterface, null, Action.ADD);
    }
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 34 with ElanInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.

the class NeutronPortChangeListener method createElanInterface.

private void createElanInterface(Port port, String name, WriteTransaction wrtConfigTxn) {
    String elanInstanceName = port.getNetworkId().getValue();
    List<StaticMacEntries> staticMacEntries = NeutronvpnUtils.buildStaticMacEntry(port);
    InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface.class, new ElanInterfaceKey(name)).build();
    ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(name).setStaticMacEntries(staticMacEntries).setKey(new ElanInterfaceKey(name)).build();
    wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, elanInterface);
    LOG.debug("Creating new ELan Interface {}", elanInterface);
}
Also used : ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey)

Aggregations

ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)21 ArrayList (java.util.ArrayList)11 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)11 StaticMacEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries)10 ElanInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder)9 ElanInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey)8 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)7 BigInteger (java.math.BigInteger)6 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)6 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)4 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)4 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)3 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)3 ElanException (org.opendaylight.netvirt.elan.ElanException)3 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)3 StaticMacEntriesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder)3 Optional (com.google.common.base.Optional)2