Search in sources :

Example 76 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config in project genius by opendaylight.

the class TepCommandHelper method buildTeps.

@SuppressWarnings("checkstyle:IllegalCatch")
public void buildTeps() {
    TransportZones transportZonesBuilt = null;
    TransportZone transportZone = null;
    try {
        LOG.debug("no of teps added {}", CHECK);
        if (transportZonesHashMap != null && !transportZonesHashMap.isEmpty()) {
            transportZoneArrayList = new ArrayList<>();
            for (Entry<String, Map<SubnetObject, List<Vteps>>> mapEntry : transportZonesHashMap.entrySet()) {
                String tz = mapEntry.getKey();
                LOG.debug("transportZonesHashMap {}", tz);
                subnetList = new ArrayList<>();
                Map<SubnetObject, List<Vteps>> subVtepMapTemp = mapEntry.getValue();
                for (Entry<SubnetObject, List<Vteps>> entry : subVtepMapTemp.entrySet()) {
                    SubnetObject subOb = entry.getKey();
                    LOG.debug("subnets {}", subOb.get_prefix());
                    List<Vteps> vtepList = entry.getValue();
                    Subnets subnet = new SubnetsBuilder().setGatewayIp(subOb.get_gatewayIp()).setKey(subOb.get_key()).setPrefix(subOb.get_prefix()).setVlanId(subOb.get_vlanId()).setVteps(vtepList).build();
                    subnetList.add(subnet);
                    LOG.debug("vteps {}", vtepList);
                }
                InstanceIdentifier<TransportZone> transportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tz)).build();
                Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, transportZonePath, dataBroker);
                LOG.debug("read container from DS");
                if (transportZoneOptional.isPresent()) {
                    TransportZone tzoneFromDs = transportZoneOptional.get();
                    LOG.debug("read tzone container {}", tzoneFromDs);
                    if (tzoneFromDs.getTunnelType() == null || tzoneFromDs.getTunnelType().equals(TunnelTypeVxlan.class)) {
                        transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
                    } else if (tzoneFromDs.getTunnelType().equals(TunnelTypeGre.class)) {
                        transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeGre.class).setSubnets(subnetList).setZoneName(tz).build();
                    }
                } else {
                    transportZone = new TransportZoneBuilder().setKey(new TransportZoneKey(tz)).setTunnelType(TunnelTypeVxlan.class).setSubnets(subnetList).setZoneName(tz).build();
                }
                LOG.debug("tzone object {}", transportZone);
                transportZoneArrayList.add(transportZone);
            }
            transportZonesBuilt = new TransportZonesBuilder().setTransportZone(transportZoneArrayList).build();
            InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
            LOG.debug("InstanceIdentifier {}", path);
            ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, transportZonesBuilt, dataBroker, ItmUtils.DEFAULT_CALLBACK);
            LOG.debug("wrote to Config DS {}", transportZonesBuilt);
            transportZonesHashMap.clear();
            transportZoneArrayList.clear();
            subnetList.clear();
            LOG.debug("Everything cleared");
        } else {
            LOG.debug("NO vteps were configured");
        }
    } catch (RuntimeException e) {
        LOG.error("Error building TEPs", e);
    }
}
Also used : TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) Map(java.util.Map) HashMap(java.util.HashMap) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 77 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config in project genius by opendaylight.

the class DpnTepStateCache method removeTepFromDpnTepInterfaceConfigDS.

public void removeTepFromDpnTepInterfaceConfigDS(BigInteger srcDpnId) throws TransactionCommitFailedException {
    Collection<DpnsTeps> dpnsTeps = this.getAllPresent();
    for (DpnsTeps dpnTep : dpnsTeps) {
        if (!dpnTep.getSourceDpnId().equals(srcDpnId)) {
            List<RemoteDpns> remoteDpns = dpnTep.getRemoteDpns();
            for (RemoteDpns remoteDpn : remoteDpns) {
                if (remoteDpn.getDestinationDpnId().equals(srcDpnId)) {
                    // Remote the SrcDpnId from the remote List. Remove it from COnfig DS. 4
                    // This will be reflected in cache by the ClusteredDTCN. Not removing it here !
                    // Caution :- Batching Delete !!
                    InstanceIdentifier<RemoteDpns> remoteDpnII = buildRemoteDpnsInstanceIdentifier(dpnTep.getSourceDpnId(), remoteDpn.getDestinationDpnId());
                    SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, remoteDpnII);
                    break;
                }
            }
        } else {
            // The source DPn id is the one to be removed
            InstanceIdentifier<DpnsTeps> dpnsTepsII = buildDpnsTepsInstanceIdentifier(dpnTep.getSourceDpnId());
            SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, dpnsTepsII);
        }
    }
}
Also used : RemoteDpns(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.dpns.teps.RemoteDpns) DpnsTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.DpnsTeps)

Example 78 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config in project genius by opendaylight.

the class TepCommandHelper method validateForDuplicates.

/**
 * Validate for duplicates.
 *
 * @param inputVtep
 *            the input vtep
 * @param transportZone
 *            the transport zone
 */
public void validateForDuplicates(Vteps inputVtep, String transportZone) {
    Map<String, TransportZone> allTransportZonesAsMap = getAllTransportZonesAsMap();
    boolean isConfiguredTepGreType = isGreTunnelType(transportZone, allTransportZonesAsMap);
    // Checking for duplicates in local cache
    for (Entry<String, Map<SubnetObject, List<Vteps>>> entry : transportZonesHashMap.entrySet()) {
        String tz = entry.getKey();
        boolean isGreType = isGreTunnelType(tz, allTransportZonesAsMap);
        Map<SubnetObject, List<Vteps>> subVtepMapTemp = entry.getValue();
        for (List<Vteps> vtepList : subVtepMapTemp.values()) {
            validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
        }
    }
    // Checking for duplicates in config DS
    for (TransportZone tz : allTransportZonesAsMap.values()) {
        boolean isGreType = false;
        if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
            isGreType = true;
        }
        for (Subnets sub : ItmUtils.emptyIfNull(tz.getSubnets())) {
            List<Vteps> vtepList = sub.getVteps();
            validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
        }
    }
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 79 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config in project genius by opendaylight.

the class InterfaceMetaUtils method getBridgeEntryFromConfigDS.

public BridgeEntry getBridgeEntryFromConfigDS(BigInteger dpnId) {
    BridgeEntry bridgeEntry = getBridgeEntryFromCache(dpnId);
    if (bridgeEntry != null) {
        return bridgeEntry;
    }
    BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
    InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier = InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
    LOG.debug("Trying to retrieve bridge entry from config for Id: {}", bridgeEntryInstanceIdentifier);
    bridgeEntry = readBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier);
    if (bridgeEntry != null) {
        addBridgeEntryToCache(dpnId, bridgeEntry);
    }
    return bridgeEntry;
}
Also used : BridgeEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntryKey) BridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry)

Example 80 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config in project bgpcep by opendaylight.

the class OpenconfigRoutingPolicyLoader method loadConfiguration.

@Override
public void loadConfiguration(final NormalizedNode<?, ?> dto) {
    final RoutingPolicy routingPolicy = (RoutingPolicy) this.bindingSerializer.fromNormalizedNode(this.routingPolicyYiid, dto).getValue();
    final WriteTransaction wtx = this.dataBroker.newWriteOnlyTransaction();
    wtx.merge(LogicalDatastoreType.CONFIGURATION, ROUTING_POLICY_IID, routingPolicy, WriteTransaction.CREATE_MISSING_PARENTS);
    try {
        wtx.submit().get();
    } catch (final ExecutionException | InterruptedException e) {
        LOG.warn("Failed to create Routing Policy config", e);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RoutingPolicy(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ArrayList (java.util.ArrayList)47 Test (org.junit.Test)45 BigInteger (java.math.BigInteger)29 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)23 ByteBuf (io.netty.buffer.ByteBuf)21 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)21 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)20 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)19 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)16 ExecutionException (java.util.concurrent.ExecutionException)16 Optional (com.google.common.base.Optional)15 List (java.util.List)15 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)14 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)14 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)12 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)12