Search in sources :

Example 1 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project netvirt by opendaylight.

the class HwvtepTerminationPointListener method handlePortAdded.

private List<ListenableFuture<Void>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
    Node psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
    if (psNode != null) {
        String psName = psNode.getAugmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
        L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
        if (l2GwDevice != null) {
            if (isL2GatewayConfigured(l2GwDevice)) {
                List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
                String newPortId = portAdded.getTpId().getValue();
                NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
                return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
            }
        } else {
            LOG.error("{} details are not present in L2Gateway Cache", psName);
        }
    } else {
        LOG.error("{} entry not in config datastore", psNodeId);
    }
    return Collections.emptyList();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 2 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLocatorRef.

/**
 * Trnaform locator reference to nodepath passed .
 *
 * @param src {@link HwvtepPhysicalLocatorRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return physicalLocatorRef {@link HwvtepPhysicalLocatorRef} the transforrmed result
 */
public static HwvtepPhysicalLocatorRef convertLocatorRef(HwvtepPhysicalLocatorRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<TerminationPoint> srcTepPath = (InstanceIdentifier<TerminationPoint>) src.getValue();
    TpId tpId = srcTepPath.firstKeyOf(TerminationPoint.class).getTpId();
    InstanceIdentifier<TerminationPoint> tpPath = nodePath.child(TerminationPoint.class, new TerminationPointKey(tpId));
    HwvtepPhysicalLocatorRef physicalLocatorRef = new HwvtepPhysicalLocatorRef(tpPath);
    return physicalLocatorRef;
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 3 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project netvirt by opendaylight.

the class PhysicalLocatorCmd method areEqual.

@Override
public boolean areEqual(TerminationPoint updated, TerminationPoint orig) {
    HwvtepPhysicalLocatorAugmentation updatedPhysicalLocator = updated.getAugmentation(HwvtepPhysicalLocatorAugmentation.class);
    HwvtepPhysicalLocatorAugmentation origPhysicalLocator = orig.getAugmentation(HwvtepPhysicalLocatorAugmentation.class);
    return updatedPhysicalLocator.getDstIp().equals(origPhysicalLocator.getDstIp()) && updatedPhysicalLocator.getEncapsulationType() == origPhysicalLocator.getEncapsulationType();
}
Also used : HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation)

Example 4 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project netvirt by opendaylight.

the class TerminationPointCmd method transform.

@Override
public TerminationPoint transform(InstanceIdentifier<Node> nodePath, TerminationPoint src) {
    HwvtepPhysicalPortAugmentation augmentation = src.getAugmentation(HwvtepPhysicalPortAugmentation.class);
    if (augmentation == null) {
        return new TerminationPointBuilder(src).build();
    }
    String nodeIdVal = nodePath.firstKeyOf(Node.class).getNodeId().getValue();
    int idx = nodeIdVal.indexOf("/physicalswitch");
    if (idx > 0) {
        nodeIdVal = nodeIdVal.substring(0, idx);
        nodePath = HwvtepHAUtil.convertToInstanceIdentifier(nodeIdVal);
    }
    final InstanceIdentifier<Node> path = nodePath;
    TerminationPointBuilder tpBuilder = new TerminationPointBuilder(src);
    tpBuilder.removeAugmentation(HwvtepPhysicalPortAugmentation.class);
    HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalPortAugmentationBuilder(augmentation);
    if (augmentation.getVlanBindings() != null && augmentation.getVlanBindings().size() > 0) {
        tpAugmentationBuilder.setVlanBindings(augmentation.getVlanBindings().stream().map(vlanBindings -> {
            VlanBindingsBuilder vlanBindingsBuilder = new VlanBindingsBuilder(vlanBindings);
            vlanBindingsBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(vlanBindings.getLogicalSwitchRef(), path));
            return vlanBindingsBuilder.build();
        }).collect(Collectors.toList()));
    }
    tpBuilder.addAugmentation(HwvtepPhysicalPortAugmentation.class, tpAugmentationBuilder.build());
    return tpBuilder.build();
}
Also used : HwvtepPhysicalPortAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) VlanBindingsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder)

Example 5 with TerminationPoint

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project netvirt by opendaylight.

the class TerminationPointCmd method areEqual.

@Override
public boolean areEqual(TerminationPoint updated, TerminationPoint orig) {
    if (!updated.getKey().equals(orig.getKey())) {
        return false;
    }
    HwvtepPhysicalPortAugmentation updatedAugmentation = updated.getAugmentation(HwvtepPhysicalPortAugmentation.class);
    HwvtepPhysicalPortAugmentation origAugmentation = orig.getAugmentation(HwvtepPhysicalPortAugmentation.class);
    List<VlanBindings> up = updatedAugmentation != null ? updatedAugmentation.getVlanBindings() : null;
    List<VlanBindings> or = origAugmentation != null ? origAugmentation.getVlanBindings() : null;
    if (!areSameSize(up, or)) {
        return false;
    }
    List<VlanBindings> added = diffOf(up, or, bindingsComparator);
    if (added.size() != 0) {
        return false;
    }
    List<VlanBindings> removed = diffOf(or, up, bindingsComparator);
    if (removed.size() != 0) {
        return false;
    }
    return true;
}
Also used : VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)

Aggregations

TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)41 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)25 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)20 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)18 TerminationPointBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder)16 ArrayList (java.util.ArrayList)12 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)10 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 HwvtepPhysicalPortAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)7 OvsdbTerminationPointAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Test (org.junit.Test)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)6 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)6 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 OvsdbTerminationPointAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)5 BigInteger (java.math.BigInteger)4 List (java.util.List)3