Search in sources :

Example 41 with DataBroker

use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project netvirt by opendaylight.

the class VpnUtil method getVpnsImportingMyRoute.

public static List<VpnInstanceOpDataEntry> getVpnsImportingMyRoute(final DataBroker broker, final String vpnName) {
    List<VpnInstanceOpDataEntry> vpnsToImportRoute = new ArrayList<>();
    final String vpnRd = getVpnRd(broker, vpnName);
    if (vpnRd == null) {
        LOG.error("getVpnsImportingMyRoute: vpn {} not present in config DS.", vpnName);
        return vpnsToImportRoute;
    }
    final VpnInstanceOpDataEntry vpnInstanceOpDataEntry = VpnUtil.getVpnInstanceOpData(broker, vpnRd);
    if (vpnInstanceOpDataEntry == null) {
        LOG.error("getVpnsImportingMyRoute: Could not retrieve vpn instance op data for {}" + " to check for vpns importing the routes", vpnName);
        return vpnsToImportRoute;
    }
    Predicate<VpnInstanceOpDataEntry> excludeVpn = input -> {
        if (input.getVpnInstanceName() == null) {
            LOG.error("getVpnsImportingMyRoute.excludeVpn: Received vpn instance with rd {} without a name.", input.getVrfId());
            return false;
        }
        return !input.getVpnInstanceName().equals(vpnName);
    };
    Predicate<VpnInstanceOpDataEntry> matchRTs = input -> {
        Iterable<String> commonRTs = intersection(getRts(vpnInstanceOpDataEntry, VpnTarget.VrfRTType.ExportExtcommunity), getRts(input, VpnTarget.VrfRTType.ImportExtcommunity));
        return Iterators.size(commonRTs.iterator()) > 0;
    };
    vpnsToImportRoute = getAllVpnInstanceOpData(broker).stream().filter(excludeVpn).filter(matchRTs).collect(Collectors.toList());
    return vpnsToImportRoute;
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) RoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.RoutesBuilder) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) Future(java.util.concurrent.Future) Vpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn) RouterInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RouterInterfaces) Map(java.util.Map) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) BigInteger(java.math.BigInteger) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) AllocatedRdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.extraroute.rds.dest.prefixes.AllocatedRdsKey) NetworkMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMapKey) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) NetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.NetworkKey) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) GetInterfaceFromIfIndexOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput) VpnInstanceOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) VpnInterfaceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey) GetInterfaceFromIfIndexInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInput) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) VpnIdToVpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnIdToVpnInstance) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) Inet4Address(java.net.Inet4Address) UnknownHostException(java.net.UnknownHostException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ElanInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) VpnIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIds) AssociatedSubnetType(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames.AssociatedSubnetType) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) Date(java.util.Date) IpVersionBase(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) Locale(java.util.Locale) ElanDpnInterfacesListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey) AdjacenciesOpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOpBuilder) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) NetworkType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkAttributes.NetworkType) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) RouterInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceKey) NeutronVpnPortipPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronVpnPortipPortData) Collection(java.util.Collection) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Collectors(java.util.stream.Collectors) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) VrfEntryBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.VrfEntryBase) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) NaptSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches) Entry(java.util.Map.Entry) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) VpnInstanceToVpnId(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceToVpnId) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) SubnetmapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapKey) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) IfIndexesInterfaceMap(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.IfIndexesInterfaceMap) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) HashSet(java.util.HashSet) RoutersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersKey) ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) VpnNexthopsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthopsKey) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) VpnTargets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnTargets) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder) VpnInterfaceOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInterfaceOpData) Nonnull(javax.annotation.Nonnull) IfIndexInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterfaceKey) Logger(org.slf4j.Logger) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Inet6Address(java.net.Inet6Address) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) RouterInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceBuilder) GetInterfaceFromIfIndexInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder) AllocatedRdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.extraroute.rds.dest.prefixes.AllocatedRdsBuilder) VpnToExtraroutes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnToExtraroutes) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterface) LearntVpnVipToPortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPortKey) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) InetAddress(java.net.InetAddress) ServiceIndex(org.opendaylight.genius.utils.ServiceIndex) IpVersionV4(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4) Optional(com.google.common.base.Optional) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) VpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.VpnKey) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) Set(java.util.Set) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) VpnInstanceNamesBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNamesBuilder) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) LearntVpnVipToPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPortBuilder) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) TimeUnits(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TimeUnits) SimpleDateFormat(java.text.SimpleDateFormat) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) AdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder) INeutronVpnManager(org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager) ArrayList(java.util.ArrayList) NetworkMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMap) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey) Nullable(javax.annotation.Nullable) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool) PrefixToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.PrefixToInterface) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) PrefixesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesKey) TryLockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput) VpnNexthops(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops) Futures(com.google.common.util.concurrent.Futures) TryLockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) VpnIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIdsKey) VpnInterfaceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) ElanTagNameKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey) IdPoolKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) SchemaValidationFailedException(org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException) Predicate(java.util.function.Predicate) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) VpnAfConfig(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnAfConfig) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) SubnetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey) List(java.util.List) FlowEntityBuilder(org.opendaylight.genius.mdsalutil.FlowEntityBuilder) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps) VpnTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget) VpnIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIdsBuilder) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) LearntVpnVipToPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.LearntVpnVipToPortData) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) HashMap(java.util.HashMap) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey) Iterators(com.google.common.collect.Iterators) L3nexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.L3nexthop) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) VpnInstances(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances) RouterInterfacesMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterInterfacesMap) AdjacencyType(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency.AdjacencyType) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) LockManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) ElanTagNameMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanTagNameMap) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) ElanHelper(org.opendaylight.netvirt.elanmanager.api.ElanHelper) Subnetmaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps) VpnPortipToPortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortKey) NetworkL3Extension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.ext.rev150712.NetworkL3Extension) VpnInterfaceKey(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey) ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) SystemPropertyReader(org.opendaylight.genius.utils.SystemPropertyReader) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) IdPools(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice) SubnetOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.SubnetOpData) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceBuilder) NetworkMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NetworkMaps) Collections(java.util.Collections) RouterToNaptSwitchKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) ArrayList(java.util.ArrayList)

Example 42 with DataBroker

use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project netvirt by opendaylight.

the class IVpnLinkServiceImpl method leakRoute.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void leakRoute(InterVpnLinkDataComposite interVpnLink, String srcVpnUuid, String dstVpnUuid, String prefix, Long label, RouteOrigin forcedOrigin) {
    String ivpnLinkName = interVpnLink.getInterVpnLinkName();
    // The source VPN must participate in the InterVpnLink
    Preconditions.checkArgument(interVpnLink.isVpnLinked(srcVpnUuid), "The source VPN {} does not participate in the interVpnLink {}", srcVpnUuid, ivpnLinkName);
    // The destination VPN must participate in the InterVpnLink
    Preconditions.checkArgument(interVpnLink.isVpnLinked(dstVpnUuid), "The destination VPN {} does not participate in the interVpnLink {}", dstVpnUuid, ivpnLinkName);
    String endpointIp = interVpnLink.getOtherEndpointIpAddr(dstVpnUuid);
    String leakedOrigin = forcedOrigin != null ? forcedOrigin.getValue() : RouteOrigin.INTERVPN.getValue();
    FibHelper.buildRoutePath(endpointIp, label);
    VrfEntry newVrfEntry = new VrfEntryBuilder().setKey(new VrfEntryKey(prefix)).setDestPrefix(prefix).setRoutePaths(Collections.singletonList(FibHelper.buildRoutePath(endpointIp, label))).setOrigin(leakedOrigin).build();
    String dstVpnRd = VpnUtil.getVpnRd(dataBroker, dstVpnUuid);
    InstanceIdentifier<VrfEntry> newVrfEntryIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(dstVpnRd)).child(VrfEntry.class, new VrfEntryKey(newVrfEntry.getDestPrefix())).build();
    VpnUtil.asyncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, newVrfEntryIid, newVrfEntry);
    // Finally, route is advertised it to the DC-GW. But while in the FibEntries the nexthop is the other
    // endpoint's IP, in the DC-GW the nexthop for those prefixes are the IPs of those DPNs where the target
    // VPN has been instantiated
    List<BigInteger> srcDpnList = interVpnLink.getEndpointDpnsByVpnName(srcVpnUuid);
    List<String> nexthops = srcDpnList.stream().map(dpnId -> InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, dpnId)).collect(Collectors.toList());
    LOG.debug("Advertising route in VPN={} [prefix={} label={}  nexthops={}] to DC-GW", dstVpnRd, newVrfEntry.getDestPrefix(), label.intValue(), nexthops);
    try {
        bgpManager.advertisePrefix(dstVpnRd, null, /*macAddress*/
        prefix, nexthops, VrfEntry.EncapType.Mplsgre, label.intValue(), 0, /*l3vni*/
        0, /*l2vni*/
        null);
    } catch (Exception e) {
        LOG.error("Exception while advertising prefix {} on vpnRd {} for intervpn link", prefix, dstVpnRd, e);
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) InterVpnLinkCache(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite) Optional(com.google.common.base.Optional) VpnConstants(org.opendaylight.netvirt.vpnmanager.VpnConstants) Map(java.util.Map) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) IVpnLinkService(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.IVpnLinkService) VpnMaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps) Logger(org.slf4j.Logger) Predicate(java.util.function.Predicate) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) Collectors(java.util.stream.Collectors) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) VpnMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryBuilder) PostConstruct(javax.annotation.PostConstruct) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) Preconditions(com.google.common.base.Preconditions) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) BigInteger(java.math.BigInteger) VrfEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryBuilder) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Example 43 with DataBroker

use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project netvirt by opendaylight.

the class VpnServiceElanDpnInterfacesListener method update.

@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
    LOG.info("received Dpninterfaces update event for dpn {}", update.getDpId());
    BigInteger dpnId = update.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = VpnUtil.getElanInstanceByName(dataBroker, elanInstanceName);
    String vpnName = VpnUtil.getVpnNameFromElanIntanceName(dataBroker, elanInstanceName);
    if (vpnName == null) {
        return;
    }
    String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
    if (elanInstance != null && !elanInstance.isExternal() && VpnUtil.isVlan(elanInstance)) {
        jobCoordinator.enqueueJob(elanInstance.getElanInstanceName(), () -> {
            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
                List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(), original.getInterfaces());
                for (String addedInterface : addedInterfaces) {
                    if (interfaceManager.isExternalInterface(addedInterface)) {
                        InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(primaryRd, dpnId);
                        Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                        if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
                            return;
                        }
                        if (!VpnUtil.shouldPopulateFibForVlan(dataBroker, vpnName, elanInstanceName, dpnId, interfaceManager)) {
                            return;
                        }
                        long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
                        fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
                        break;
                    }
                }
                List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(), update.getInterfaces());
                if (!deletedInterfaces.isEmpty()) {
                    String routerPortUuid = VpnUtil.getRouterPordIdFromElanInstance(dataBroker, elanInstanceName);
                    if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
                        VpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId, dataBroker);
                    }
                }
            }));
        });
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) LoggerFactory(org.slf4j.LoggerFactory) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) Collections(java.util.Collections) Optional(com.google.common.base.Optional) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ArrayList(java.util.ArrayList) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) List(java.util.List) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Example 44 with DataBroker

use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project netvirt by opendaylight.

the class InterfaceStateChangeListener method add.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
    try {
        if (L2vlan.class.equals(intrf.getType())) {
            LOG.info("VPN Interface add event - intfName {} from InterfaceStateChangeListener", intrf.getName());
            jobCoordinator.enqueueJob("VPNINTERFACE-" + intrf.getName(), () -> {
                List<ListenableFuture<Void>> futures = new ArrayList<>(3);
                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
                    ListenableFuture<Void> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
                        ListenableFuture<Void> operFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
                            final String interfaceName = intrf.getName();
                            LOG.info("Detected interface add event for interface {}", interfaceName);
                            final VpnInterface vpnIf = VpnUtil.getConfiguredVpnInterface(dataBroker, interfaceName);
                            if (vpnIf != null) {
                                for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.getVpnInstanceNames()) {
                                    String vpnName = vpnInterfaceVpnInstance.getVpnName();
                                    String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
                                    if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {} " + "running oper-driven, VpnInstance not ready, holding" + " on", vpnIf.getName(), vpnName);
                                    } else if (VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
                                        LOG.error("add: Ignoring addition of vpnInterface {}, as" + " vpnInstance {} with primaryRd {} is already marked for" + " deletion", interfaceName, vpnName, primaryRd);
                                    } else {
                                        BigInteger intfDpnId = BigInteger.ZERO;
                                        try {
                                            intfDpnId = InterfaceUtils.getDpIdFromInterface(intrf);
                                        } catch (Exception e) {
                                            LOG.error("Unable to retrieve dpnId for interface {}. " + "Process vpn interface add failed", intrf.getName(), e);
                                            return;
                                        }
                                        final BigInteger dpnId = intfDpnId;
                                        final int ifIndex = intrf.getIfIndex();
                                        LOG.info("VPN Interface add event - intfName {} onto vpnName {}" + " running oper-driven", vpnIf.getName(), vpnName);
                                        vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd, ifIndex, false, writeConfigTxn, writeOperTxn, writeInvTxn, intrf, vpnName);
                                    }
                                }
                            }
                        });
                        futures.add(operFuture);
                        // Synchronous submit of operTxn
                        operFuture.get();
                    });
                    futures.add(configFuture);
                    // TODO: Allow immediateFailedFuture from writeCfgTxn to cancel writeInvTxn as well.
                    Futures.addCallback(configFuture, new PostVpnInterfaceThreadWorker(intrf.getName(), true, "Operational"));
                }));
                return futures;
            });
        }
    } catch (Exception e) {
        LOG.error("Exception caught in Interface {} Operational State Up event", intrf.getName(), e);
    }
}
Also used : InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FutureCallback(com.google.common.util.concurrent.FutureCallback) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger)

Example 45 with DataBroker

use of org.opendaylight.controller.md.sal.binding.api.DataBroker in project netvirt by opendaylight.

the class VpnServiceChainUtils method getAllVpnIfaceNames.

public static List<String> getAllVpnIfaceNames(DataBroker dataBroker, String vpnName) {
    String vpnRd = getVpnRd(dataBroker, vpnName);
    InstanceIdentifier<VpnInstanceOpDataEntry> vpnOpDataIid = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnRd)).build();
    try {
        VpnInstanceOpDataEntry vpnOpData = SingleTransactionDataBroker.syncRead(dataBroker, LogicalDatastoreType.OPERATIONAL, vpnOpDataIid);
        if (vpnOpData == null) {
            return Collections.emptyList();
        }
        List<VpnToDpnList> dpnToVpns = vpnOpData.getVpnToDpnList();
        if (dpnToVpns == null) {
            return Collections.emptyList();
        }
        return dpnToVpns.stream().filter(dpn -> dpn.getVpnInterfaces() != null).flatMap(dpn -> dpn.getVpnInterfaces().stream()).map(VpnInterfaces::getInterfaceName).collect(Collectors.toList());
    } catch (ReadFailedException e) {
        LOG.warn("getAllVpnInterfaces for vpn {}: Failure on read operation", vpnName, e);
        return Collections.emptyList();
    }
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) CloudServiceChainConstants(org.opendaylight.netvirt.cloudservicechain.CloudServiceChainConstants) ServiceIndex(org.opendaylight.genius.utils.ServiceIndex) NxmNxReg2(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Optional(com.google.common.base.Optional) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) BoundServicesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesKey) Collectors(java.util.stream.Collectors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) List(java.util.List) ServicesInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfoKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) VpnInstanceOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData) VpnInstanceToVpnId(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceToVpnId) ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) VpnToPseudoPortList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.VpnToPseudoPortList) VpnToPseudoPortDataKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.vpn.to.pseudo.port.list.VpnToPseudoPortDataKey) ServicesInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfo) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ServiceBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings) ArrayList(java.util.ArrayList) VpnToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.vpn.to.pseudo.port.list.VpnToPseudoPortData) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) Logger(org.slf4j.Logger) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Aggregations

DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)67 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)38 Optional (com.google.common.base.Optional)37 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)37 Logger (org.slf4j.Logger)37 LoggerFactory (org.slf4j.LoggerFactory)36 ArrayList (java.util.ArrayList)34 List (java.util.List)33 BigInteger (java.math.BigInteger)31 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)30 Collections (java.util.Collections)29 Inject (javax.inject.Inject)29 Singleton (javax.inject.Singleton)29 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)25 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)24 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)23 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)22 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)22 FutureCallback (com.google.common.util.concurrent.FutureCallback)21 PostConstruct (javax.annotation.PostConstruct)21