Search in sources :

Example 51 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class ElanDpnToTransportZoneListener method add.

@Override
public void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
    // Proceed only if "auto-config-transport-zones = TRUE"
    if (!useTransportZone) {
        return;
    }
    LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
    Uint64 dpId = dataObjectModification.getDpId();
    String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orElse(null))) {
        return;
    }
    transportZoneNotificationUtil.updateTransportZone(elanInstanceName, dpId);
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 52 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class ElanInstanceManager method update.

@Override
public void update(InstanceIdentifier<ElanInstance> identifier, ElanInstance original, ElanInstance update) {
    EVENT_LOGGER.debug("ELAN-Instance, UPDATE {}", original.getElanInstanceName());
    Uint32 existingElanTag = original.getElanTag();
    String elanName = update.getElanInstanceName();
    if (existingElanTag == null || !existingElanTag.equals(update.getElanTag())) {
        if (update.getElanTag() == null || update.getElanTag().longValue() == 0L) {
            // update the elan-Instance with new properties
            LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> ElanUtils.updateOperationalDataStore(idManager, update, new ArrayList<>(), confTx, operTx)), LOG, "Error updating ELAN tag in ELAN instance for config " + "transaction")), LOG, "Error updating ELAN tag in ELAN instance for operational transaction");
        } else {
            jobCoordinator.enqueueJob(elanName, () -> elanInterfaceManager.handleunprocessedElanInterfaces(update), ElanConstants.JOB_MAX_RETRIES);
        }
    }
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) ElanConstants(org.opendaylight.netvirt.elan.utils.ElanConstants) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) ElanInterfaceCache(org.opendaylight.netvirt.elan.cache.ElanInterfaceCache) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 53 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class HwvtepHAUtil method buildManagersForHANode.

/**
 * Transform child managers (Source) to HA managers using HA node path.
 *
 * @param childNode Child Node
 * @param haGlobalCfg HA global config node
 * @return Transformed managers
 */
public static List<Managers> buildManagersForHANode(Node childNode, Optional<Node> haGlobalCfg) {
    Set<NodeId> nodeIds = new HashSet<>();
    nodeIds.add(childNode.getNodeId());
    List<NodeId> childNodeIds = getChildNodeIdsFromManagerOtherConfig(haGlobalCfg);
    nodeIds.addAll(childNodeIds);
    InstanceIdentifier<Node> parentIid = HwvtepHACache.getInstance().getParent(convertToInstanceIdentifier(childNode.getNodeId().getValue()));
    HwvtepHACache.getInstance().getChildrenForHANode(parentIid).stream().forEach(iid -> nodeIds.add(iid.firstKeyOf(Node.class).getNodeId()));
    ManagersBuilder builder1 = new ManagersBuilder();
    builder1.withKey(new ManagersKey(new Uri(MANAGER_KEY)));
    List<ManagerOtherConfigs> otherConfigses = new ArrayList<>();
    String children = nodeIds.stream().map(NodeId::getValue).collect(Collectors.joining(","));
    otherConfigses.add(getOtherConfigBuilder(HA_CHILDREN, children).build());
    builder1.setManagerOtherConfigs(otherConfigses);
    List<Managers> managers = new ArrayList<>();
    managers.add(builder1.build());
    return managers;
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) ManagersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs) Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) ManagersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Example 54 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class HwvtepHAUtil method getChildNodeIdsFromManagerOtherConfig.

/**
 * Returns ha child node path from ha node of config data tree.
 *
 * @param haGlobalConfigNodeOptional HA global node
 * @return ha Child ids
 */
public static List<NodeId> getChildNodeIdsFromManagerOtherConfig(Optional<Node> haGlobalConfigNodeOptional) {
    List<NodeId> childNodeIds = new ArrayList<>();
    if (!haGlobalConfigNodeOptional.isPresent()) {
        return childNodeIds;
    }
    HwvtepGlobalAugmentation augmentation = haGlobalConfigNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
    if (augmentation != null && augmentation.getManagers() != null && augmentation.getManagers().size() > 0) {
        Managers managers = new ArrayList<>(augmentation.nonnullManagers().values()).get(0);
        if (null == managers.getManagerOtherConfigs()) {
            return childNodeIds;
        }
        for (ManagerOtherConfigs otherConfigs : managers.nonnullManagerOtherConfigs().values()) {
            if (HA_CHILDREN.equals(otherConfigs.getOtherConfigKey())) {
                String nodeIdsVal = otherConfigs.getOtherConfigValue();
                if (nodeIdsVal != null) {
                    String[] parts = nodeIdsVal.split(",");
                    for (String part : parts) {
                        childNodeIds.add(new NodeId(part));
                    }
                }
            }
        }
    }
    return childNodeIds;
}
Also used : Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs)

Example 55 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.

the class HwvtepHAUtil method deletePSNodesOfNode.

/**
 * Delete PS data of HA node of Config Data tree.
 *
 * @param key Node object
 * @param haNode Ha Node from which to be deleted
 * @param tx Transaction
 */
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
    // read from switches attribute and clean up them
    HwvtepGlobalAugmentation globalAugmentation = haNode.augmentation(HwvtepGlobalAugmentation.class);
    if (globalAugmentation == null) {
        return;
    }
    HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
    List<Switches> switches = new ArrayList<>(globalAugmentation.nonnullSwitches().values());
    if (switches != null) {
        for (Switches switche : switches) {
            InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
            deleteNodeIfPresent(tx, psId);
            deleted.put(psId, Boolean.TRUE);
        }
    }
    // also read from managed by attribute of switches and cleanup them as a back up if the above cleanup fails
    Optional<Topology> topologyOptional = tx.read(key.firstIdentifierOf(Topology.class)).get();
    String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
    if (topologyOptional.isPresent()) {
        Topology topology = topologyOptional.get();
        if (topology.getNode() != null) {
            for (Node psNode : topology.nonnullNode().values()) {
                PhysicalSwitchAugmentation ps = psNode.augmentation(PhysicalSwitchAugmentation.class);
                if (ps != null) {
                    InstanceIdentifier<Node> iid = (InstanceIdentifier<Node>) ps.getManagedBy().getValue();
                    String nodeIdVal = iid.firstKeyOf(Node.class).getNodeId().getValue();
                    if (deletedNodeId.equals(nodeIdVal)) {
                        InstanceIdentifier<Node> psNodeId = convertToInstanceIdentifier(psNode.getNodeId().getValue());
                        if (deleted.containsKey(psNodeId)) {
                            deleteNodeIfPresent(tx, psNodeId);
                        }
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Switches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ArrayList(java.util.ArrayList) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Aggregations

ArrayList (java.util.ArrayList)61 ExecutionException (java.util.concurrent.ExecutionException)47 Test (org.junit.Test)46 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)34 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)26 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 BigInteger (java.math.BigInteger)25 Logger (org.slf4j.Logger)25 LoggerFactory (org.slf4j.LoggerFactory)25 List (java.util.List)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)24 ByteBuf (io.netty.buffer.ByteBuf)21 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)21 Collections (java.util.Collections)20 Map (java.util.Map)18 Singleton (javax.inject.Singleton)18 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)18 Inject (javax.inject.Inject)17 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)17