Search in sources :

Example 81 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class NAPTSwitchSelector method selectNewNAPTSwitch.

Uint64 selectNewNAPTSwitch(String routerName, List<Uint64> excludeDpns) {
    LOG.info("selectNewNAPTSwitch : Select a new NAPT switch for router {}", routerName);
    Map<Uint64, Integer> naptSwitchWeights = constructNAPTSwitches();
    List<Uint64> routerSwitches = getDpnsForVpn(routerName);
    if (routerSwitches.isEmpty()) {
        LOG.warn("selectNewNAPTSwitch : Delaying NAPT switch selection due to no dpns scenario for router {}", routerName);
        return Uint64.ZERO;
    }
    try {
        if (excludeDpns != null) {
            routerSwitches.removeAll(excludeDpns);
        }
        LOG.debug("selectNewNAPTSwitch : routerSwitches before filtering : {}", routerSwitches);
        routerSwitches = tombstonedNodeManager.filterTombStoned(routerSwitches);
        LOG.debug("selectNewNAPTSwitch : routerSwitches after filtering : {}", routerSwitches);
    } catch (ReadFailedException ex) {
        LOG.error("selectNewNAPTSwitch : filterTombStoned Exception thrown", ex);
    }
    Set<SwitchWeight> switchWeights = new TreeSet<>();
    for (Uint64 dpn : routerSwitches) {
        if (naptSwitchWeights.get(dpn) != null) {
            switchWeights.add(new SwitchWeight(dpn, naptSwitchWeights.get(dpn)));
        } else {
            switchWeights.add(new SwitchWeight(dpn, 0));
        }
    }
    Uint64 primarySwitch;
    if (!switchWeights.isEmpty()) {
        LOG.debug("selectNewNAPTSwitch : Current switch weights for router {} - {}", routerName, switchWeights);
        RouterToNaptSwitchBuilder routerToNaptSwitchBuilder = new RouterToNaptSwitchBuilder().setRouterName(routerName);
        SwitchWeight firstSwitchWeight = switchWeights.iterator().next();
        primarySwitch = firstSwitchWeight.getSwitch();
        RouterToNaptSwitch id = routerToNaptSwitchBuilder.setPrimarySwitchId(primarySwitch).build();
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getNaptSwitchesIdentifier(routerName), id);
        LOG.debug("selectNewNAPTSwitch : successful addition of RouterToNaptSwitch to napt-switches container");
        return primarySwitch;
    } else {
        primarySwitch = Uint64.ZERO;
        LOG.debug("selectNewNAPTSwitch : switchWeights empty, primarySwitch: {} ", primarySwitch);
        return primarySwitch;
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) TreeSet(java.util.TreeSet) RouterToNaptSwitchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitchBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 82 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class ExternalNetworksChangeListener method remove.

@Override
public void remove(InstanceIdentifier<Networks> identifier, Networks networks) {
    if (identifier == null || networks == null || networks.getRouterIds() == null || networks.getRouterIds().isEmpty()) {
        LOG.warn("remove : returning without processing since networks/identifier is null: " + "identifier: {}, networks: {}", identifier, networks);
        return;
    }
    for (Uuid routerId : networks.getRouterIds()) {
        String routerName = routerId.toString();
        InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitchInstanceIdentifier = NatUtil.buildNaptSwitchIdentifier(routerName);
        MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, routerToNaptSwitchInstanceIdentifier);
        LOG.debug("remove : successful deletion of data in napt-switches container");
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)

Example 83 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class ExternalRoutersListener method changeLocalVpnIdToBgpVpnId.

/**
 * router association to vpn.
 *
 * @param routerName - Name of router
 * @param routerId - router id
 * @param bgpVpnName BGP VPN name
 */
public void changeLocalVpnIdToBgpVpnId(String routerName, Uint32 routerId, String extNetwork, String bgpVpnName, TypedWriteTransaction<Configuration> writeFlowInvTx, ProviderTypes extNwProvType) {
    LOG.debug("changeLocalVpnIdToBgpVpnId : Router associated to BGP VPN");
    if (chkExtRtrAndSnatEnbl(new Uuid(routerName))) {
        Uint32 bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnName);
        LOG.debug("changeLocalVpnIdToBgpVpnId : BGP VPN ID value {} ", bgpVpnId);
        if (bgpVpnId != NatConstants.INVALID_ID) {
            LOG.debug("changeLocalVpnIdToBgpVpnId : Populate the router-id-name container with the " + "mapping BGP VPN-ID {} -> BGP VPN-NAME {}", bgpVpnId, bgpVpnName);
            RouterIds rtrs = new RouterIdsBuilder().withKey(new RouterIdsKey(bgpVpnId)).setRouterId(bgpVpnId).setRouterName(bgpVpnName).build();
            MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getRoutersIdentifier(bgpVpnId), rtrs);
            // Get the allocated Primary NAPT Switch for this router
            LOG.debug("changeLocalVpnIdToBgpVpnId : Update the Router ID {} to the BGP VPN ID {} ", routerId, bgpVpnId);
            addDefaultFibRouteForSnatWithBgpVpn(routerName, routerId, bgpVpnId, writeFlowInvTx);
            // Get the group ID
            Uint64 primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
            installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, new Uuid(extNetwork), true, writeFlowInvTx, extNwProvType);
        }
    }
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey) RouterIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 84 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class ExternalRoutersListener method add.

@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void add(InstanceIdentifier<Routers> identifier, Routers routers) {
    if (natMode != NatMode.Controller) {
        return;
    }
    // Populate the router-id-name container
    String routerName = routers.getRouterName();
    LOG.info("add : external router event for {}", routerName);
    Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
    NatUtil.createRouterIdsConfigDS(dataBroker, routerId, routerName);
    Uuid bgpVpnUuid = NatUtil.getVpnForRouter(dataBroker, routerName);
    try {
        if (routers.isEnableSnat()) {
            coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + routers.key(), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
                LOG.info("add : Installing NAT default route on all dpns part of router {}", routerName);
                Uint32 bgpVpnId = NatConstants.INVALID_ID;
                if (bgpVpnUuid != null) {
                    bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnUuid.getValue());
                }
                addOrDelDefFibRouteToSNAT(routerName, routerId, bgpVpnId, bgpVpnUuid, true, confTx);
                // Allocate Primary Napt Switch for this router
                Uint64 primarySwitchId = getPrimaryNaptSwitch(routerName);
                if (primarySwitchId != null && !primarySwitchId.equals(Uint64.ZERO)) {
                    handleEnableSnat(routers, routerId, primarySwitchId, bgpVpnId, confTx);
                }
            })), NatConstants.NAT_DJC_MAX_RETRIES);
        } else {
            LOG.info("add : SNAT is disabled for external router {} ", routerName);
        }
    } catch (Exception ex) {
        LOG.error("add : Exception while Installing NAT flows on all dpns as part of router {}", routerName, ex);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Uint32(org.opendaylight.yangtools.yang.common.Uint32) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 85 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netvirt by opendaylight.

the class SubnetOpDpnManager method addInterfaceToDpn.

public SubnetToDpn addInterfaceToDpn(Uuid subnetId, Uint64 dpnId, String intfName) {
    SubnetToDpn subDpn = null;
    try {
        // Create and add SubnetOpDataEntry object for this subnet to the SubnetOpData container
        InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        // Please use a synchronize block here as we donot need a cluster-wide lock
        InstanceIdentifier<SubnetToDpn> dpnOpId = subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
        Optional<SubnetToDpn> optionalSubDpn = SingleTransactionDataBroker.syncReadOptional(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
        if (!optionalSubDpn.isPresent()) {
            // Create a new DPN Entry
            subDpn = addDpnToSubnet(subnetId, dpnId);
        } else {
            subDpn = optionalSubDpn.get();
        }
        SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(subDpn);
        Map<VpnInterfacesKey, VpnInterfaces> vpnInterfaceMap = new HashMap<>();
        vpnInterfaceMap = subDpnBuilder.getVpnInterfaces() != null ? new HashMap<>(subDpnBuilder.getVpnInterfaces()) : vpnInterfaceMap;
        VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().withKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build();
        vpnInterfaceMap.put(vpnIntfs.key(), vpnIntfs);
        subDpnBuilder.setVpnInterfaces(vpnInterfaceMap);
        subDpn = subDpnBuilder.build();
        SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY);
        LOG.info("addInterfaceToDpn: Created SubnetToDpn entry for subnet {} with DPNId {} intfName {}", subnetId.getValue(), dpnId, intfName);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("addInterfaceToDpn: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("addInterfaceToDpn: Failed to read data store for interface {} subnet {} dpn {}", intfName, subnetId, dpnId);
    }
    return subDpn;
}
Also used : SubnetToDpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces) HashMap(java.util.HashMap) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesKey) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesBuilder) SubnetToDpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)45 Test (org.junit.Test)16 HashMap (java.util.HashMap)10 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 ByteBuf (io.netty.buffer.ByteBuf)7 ArrayList (java.util.ArrayList)7 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5