Search in sources :

Example 6 with PhysicalSwitchAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method removed.

@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
    NodeId nodeId = getNodeId(identifier);
    String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
    LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
    if (l2GwDevice != null) {
        if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
            l2GatewayCache.remove(psName);
            LOG.debug("{} details removed from L2Gateway Cache", psName);
            MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
        } else {
            LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
        }
        l2GwDevice.setConnected(false);
    // ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", psName);
    }
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 7 with PhysicalSwitchAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation 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
 * @throws ReadFailedException  Exception thrown if read fails
 */
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, ReadWriteTransaction tx) throws ReadFailedException {
    // read from switches attribute and clean up them
    HwvtepGlobalAugmentation globalAugmentation = haNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (globalAugmentation == null) {
        return;
    }
    HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
    List<Switches> switches = globalAugmentation.getSwitches();
    if (switches != null) {
        for (Switches switche : switches) {
            InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
            deleteNodeIfPresent(tx, CONFIGURATION, 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(CONFIGURATION, key.firstIdentifierOf(Topology.class)).checkedGet();
    String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
    if (topologyOptional.isPresent()) {
        Topology topology = topologyOptional.get();
        if (topology.getNode() != null) {
            for (Node psNode : topology.getNode()) {
                PhysicalSwitchAugmentation ps = psNode.getAugmentation(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, CONFIGURATION, 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) 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)

Example 8 with PhysicalSwitchAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.

the class NodeConnectedHandler method copyChildPSOpToHAPS.

/**
 * Copy child physical switch node data to HA physical switch data of Operational data tree.
 *
 * @param childPsNode HA child PS node
 * @param haPath  HA node path
 * @param haPspath Ha Physical Switch Node path
 * @param tx Transaction
 * @throws ReadFailedException  Exception thrown if read fails
 */
public void copyChildPSOpToHAPS(Node childPsNode, InstanceIdentifier<Node> haPath, InstanceIdentifier<Node> haPspath, ReadWriteTransaction tx) throws ReadFailedException {
    NodeBuilder haPSNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haPspath);
    PhysicalSwitchAugmentationBuilder dstBuilder = new PhysicalSwitchAugmentationBuilder();
    PhysicalSwitchAugmentation src = childPsNode.getAugmentation(PhysicalSwitchAugmentation.class);
    Node existingHAPSNode = HwvtepHAUtil.readNode(tx, OPERATIONAL, haPspath);
    PhysicalSwitchAugmentation existingHAPSAugumentation = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(existingHAPSNode);
    psAugmentationMerger.mergeOperationalData(dstBuilder, existingHAPSAugumentation, src, haPath);
    psNodeMerger.mergeOperationalData(haPSNodeBuilder, existingHAPSNode, childPsNode, haPath);
    mergeOpManagedByAttributes(src, dstBuilder, haPath);
    haPSNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, dstBuilder.build());
    Node haPsNode = haPSNodeBuilder.build();
    tx.merge(OPERATIONAL, haPspath, haPsNode, true);
}
Also used : PhysicalSwitchAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 9 with PhysicalSwitchAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.

the class NodeConnectedHandler method mergeOpManagedByAttributes.

/**
 * Merge data to Physical switch from HA node path .
 *
 * @param psAugmentation  Physical Switch Augmation of Node
 * @param builder Physical Switch Augmentation Builder
 * @param haNodePath HA node Path
 */
public void mergeOpManagedByAttributes(PhysicalSwitchAugmentation psAugmentation, PhysicalSwitchAugmentationBuilder builder, InstanceIdentifier<Node> haNodePath) {
    builder.setManagedBy(new HwvtepGlobalRef(haNodePath));
    builder.setHwvtepNodeName(psAugmentation.getHwvtepNodeName());
    builder.setHwvtepNodeDescription(psAugmentation.getHwvtepNodeDescription());
    builder.setTunnelIps(psAugmentation.getTunnelIps());
    builder.setPhysicalSwitchUuid(HwvtepHAUtil.getUUid(psAugmentation.getHwvtepNodeName().getValue()));
}
Also used : HwvtepGlobalRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef)

Example 10 with PhysicalSwitchAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.

the class NodeCopier method mergeOpManagedByAttributes.

public void mergeOpManagedByAttributes(PhysicalSwitchAugmentation psAugmentation, PhysicalSwitchAugmentationBuilder builder, InstanceIdentifier<Node> haNodePath) {
    builder.setManagedBy(new HwvtepGlobalRef(haNodePath));
    if (psAugmentation != null) {
        builder.setHwvtepNodeName(psAugmentation.getHwvtepNodeName());
        builder.setHwvtepNodeDescription(psAugmentation.getHwvtepNodeDescription());
        builder.setTunnelIps(psAugmentation.getTunnelIps());
        if (psAugmentation.getHwvtepNodeName() != null) {
            builder.setPhysicalSwitchUuid(HwvtepHAUtil.getUUid(psAugmentation.getHwvtepNodeName().getValue()));
        }
    }
}
Also used : HwvtepGlobalRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)9 PhysicalSwitchAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation)7 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)5 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3 HwvtepGlobalRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef)3 PhysicalSwitchAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder)3 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 HashMap (java.util.HashMap)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)2 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)2 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)2 Optional (com.google.common.base.Optional)1 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 BatchedTransaction (org.opendaylight.netvirt.elan.l2gw.ha.BatchedTransaction)1 MergeCommand (org.opendaylight.netvirt.elan.l2gw.ha.commands.MergeCommand)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)1 Switches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches)1