Search in sources :

Example 1 with EvpnRdToNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork in project netvirt by opendaylight.

the class EvpnMacVrfUtils method getElanNameByMacvrfiid.

public String getElanNameByMacvrfiid(InstanceIdentifier<MacVrfEntry> instanceIdentifier) {
    try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
        String rd = instanceIdentifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
        String elanName = null;
        InstanceIdentifier<EvpnRdToNetwork> iidEvpnRdToNet = InstanceIdentifier.builder(EvpnRdToNetworks.class).child(EvpnRdToNetwork.class, new EvpnRdToNetworkKey(rd)).build();
        try {
            Optional<EvpnRdToNetwork> evpnRdToNetwork = tx.read(LogicalDatastoreType.CONFIGURATION, iidEvpnRdToNet).checkedGet();
            if (evpnRdToNetwork.isPresent()) {
                elanName = evpnRdToNetwork.get().getNetworkId();
            }
        } catch (ReadFailedException e) {
            LOG.error("getElanName: unable to read elanName, exception ", e);
        }
        return elanName;
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) EvpnRdToNetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey) EvpnRdToNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork)

Example 2 with EvpnRdToNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork in project netvirt by opendaylight.

the class NeutronEvpnUtils method updateVpnWithElanInfo.

public void updateVpnWithElanInfo(VpnInstance vpnInstance, String elanInstanceName, Operation operation) {
    String rd = vpnManager.getPrimaryRdFromVpnInstance(vpnInstance);
    InstanceIdentifier<EvpnRdToNetwork> rdToNetworkIdentifier = getRdToNetworkIdentifier(rd);
    jobCoordinator.enqueueJob("EVPN_ASSOCIATE-" + rd, () -> {
        ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (operation == Operation.DELETE) {
            LOG.debug("Deleting Evpn-Network with key {}", rd);
            transaction.delete(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier);
        } else {
            EvpnRdToNetworkBuilder evpnRdToNetworkBuilder = new EvpnRdToNetworkBuilder().setKey(new EvpnRdToNetworkKey(rd));
            evpnRdToNetworkBuilder.setRd(rd);
            evpnRdToNetworkBuilder.setNetworkId(elanInstanceName);
            LOG.info("updating Evpn {} with elaninstance {} and rd {}", vpnInstance.getVpnInstanceName(), elanInstanceName, rd);
            transaction.put(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier, evpnRdToNetworkBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
        }
        futures.add(transaction.submit());
        return futures;
    });
}
Also used : ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) EvpnRdToNetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey) EvpnRdToNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) EvpnRdToNetworkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkBuilder)

Aggregations

EvpnRdToNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork)2 EvpnRdToNetworkKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)1 EvpnRdToNetworkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkBuilder)1