Search in sources :

Example 1 with TunnelInterfaceBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder in project netvirt by opendaylight.

the class PolicyServiceUtil method updateTunnelInterfaceForUnderlayNetwork.

public void updateTunnelInterfaceForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, BigInteger dstDpId, String tunnelInterfaceName, boolean isAdded) {
    coordinator.enqueueJob(underlayNetwork, () -> {
        InstanceIdentifier<TunnelInterface> identifier = getUnderlayNetworkTunnelIdentifier(underlayNetwork, srcDpId, tunnelInterfaceName);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            TunnelInterface tunnelInterface = new TunnelInterfaceBuilder().setInterfaceName(tunnelInterfaceName).setRemoteDpId(dstDpId).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, tunnelInterface, true);
            LOG.info("Add tunnel {} on DPN {} to underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove tunnel {} from DPN {} on underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TunnelInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 TunnelInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)1 TunnelInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder)1