Search in sources :

Example 11 with VpnInstanceBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceBuilder in project netvirt by opendaylight.

the class NeutronvpnManager method updateVpnInstanceWithRDs.

public void updateVpnInstanceWithRDs(String vpnInstanceId, final List<String> rds) {
    InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class, new VpnInstanceKey(vpnInstanceId)).build();
    try {
        Optional<VpnInstance> vpnInstanceConfig = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
        if (!vpnInstanceConfig.isPresent()) {
            LOG.debug("updateVpnInstanceWithRDs: " + "No VpnInstance present under config vpnInstance:{}", vpnInstanceId);
            return;
        }
        VpnInstance vpnInstance = vpnInstanceConfig.get();
        VpnInstanceBuilder updateVpnInstanceBuilder = new VpnInstanceBuilder(vpnInstance);
        updateVpnInstanceBuilder.setRouteDistinguisher(rds);
        LOG.debug("updateVpnInstanceWithRDs: " + "Updating Config vpn-instance: {} with the list of RDs: {}", vpnInstanceId, rds);
        SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier, updateVpnInstanceBuilder.build());
    } catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
        LOG.warn("updateVpnInstanceWithRDs: Error configuring vpn-instance: {} with " + "the list of RDs: {}", vpnInstanceId, rds, ex);
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceBuilder) ExecutionException(java.util.concurrent.ExecutionException) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceKey)

Aggregations

ArrayList (java.util.ArrayList)7 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)6 VpnInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceBuilder)6 ExecutionException (java.util.concurrent.ExecutionException)4 VpnInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstanceKey)4 Function (com.google.common.base.Function)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Sets (com.google.common.collect.Sets)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 Futures (com.google.common.util.concurrent.Futures)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 SettableFuture (com.google.common.util.concurrent.SettableFuture)2 Inet4Address (java.net.Inet4Address)2 Inet6Address (java.net.Inet6Address)2 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2