Search in sources :

Example 1 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class L2GwValidateCli method compareNodes.

private boolean compareNodes(Node node1, Node node2, boolean parentChildComparison, LogicalDatastoreType datastoreType) {
    if (node1 == null || node2 == null) {
        return false;
    }
    InstanceIdentifier<Node> nodeIid1 = HwvtepSouthboundUtils.createInstanceIdentifier(node1.getNodeId());
    InstanceIdentifier<Node> nodeIid2 = HwvtepSouthboundUtils.createInstanceIdentifier(node2.getNodeId());
    NodeId nodeId1 = nodeIid1.firstKeyOf(Node.class).getNodeId();
    NodeId nodeId2 = nodeIid2.firstKeyOf(Node.class).getNodeId();
    PhysicalSwitchAugmentation psAug1 = node1.getAugmentation(PhysicalSwitchAugmentation.class);
    PhysicalSwitchAugmentation psAug2 = node2.getAugmentation(PhysicalSwitchAugmentation.class);
    HwvtepGlobalAugmentation aug1 = node1.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation aug2 = node2.getAugmentation(HwvtepGlobalAugmentation.class);
    boolean globalNodes = psAug1 == null && psAug2 == null ? true : false;
    MergeCommand[] commands = globalNodes ? globalCommands : physicalSwitchCommands;
    for (MergeCommand cmd : commands) {
        List<DataObject> data1 = null;
        List<DataObject> data2 = null;
        if (globalNodes) {
            data1 = cmd.getData(aug1);
            data2 = cmd.getData(aug2);
        } else {
            data1 = cmd.getData(node1);
            data2 = cmd.getData(node2);
        }
        data1 = data1 == null ? Collections.EMPTY_LIST : data1;
        data2 = data2 == null ? Collections.EMPTY_LIST : data2;
        if (parentChildComparison) {
            data2 = cmd.transform(nodeIid1, data2);
        }
        Function<DataObject, DataObject> withoutUuidTransformer = cmd::withoutUuid;
        data1 = Lists.transform(data1, withoutUuidTransformer);
        data2 = Lists.transform(data2, withoutUuidTransformer);
        Map<Identifier<?>, DataObject> map1 = new HashMap<>();
        Map<Identifier<?>, DataObject> map2 = new HashMap<>();
        for (DataObject dataObject : data1) {
            map1.put(cmd.getKey(dataObject), dataObject);
        }
        for (DataObject dataObject : data2) {
            map2.put(cmd.getKey(dataObject), dataObject);
        }
        Set<DataObject> diff = Sets.newHashSet();
        for (Entry<Identifier<?>, DataObject> entry : map1.entrySet()) {
            DataObject obj1 = entry.getValue();
            DataObject obj2 = map2.get(entry.getKey());
            if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
                diff.add(obj1);
            }
        }
        if (!diff.isEmpty()) {
            if (parentChildComparison) {
                pw.println("Missing " + cmd.getDescription() + " child entries in " + datastoreType + " parent node " + nodeId1 + " contain " + " more entries than child " + nodeId2 + " " + diff.size());
            } else {
                pw.println("Missing " + cmd.getDescription() + " op entries config " + nodeId1 + " contain " + " more entries than operational node " + diff.size());
            }
            if (diff.size() < 10) {
                for (Object obj : diff) {
                    pw.println(cmd.getKey((DataObject) obj));
                }
            }
        }
        diff = Sets.newHashSet();
        for (Entry<Identifier<?>, DataObject> entry : map2.entrySet()) {
            DataObject obj1 = entry.getValue();
            DataObject obj2 = map1.get(entry.getKey());
            if (globalNodes || parentChildComparison) {
                if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
                    diff.add(obj1);
                }
            }
        }
        if (!diff.isEmpty()) {
            if (parentChildComparison) {
                pw.println("Extra " + cmd.getDescription() + " child entries in " + datastoreType + " node " + nodeId2 + " contain " + " more entries than parent node " + nodeId1 + " " + diff.size());
            } else {
                pw.println("Extra " + cmd.getDescription() + " operational node " + nodeId2 + " contain " + " more entries than config node " + diff.size());
            }
            if (diff.size() < 10) {
                for (Object obj : diff) {
                    pw.println(cmd.getKey((DataObject) obj));
                }
            }
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) 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) MergeCommand(org.opendaylight.netvirt.elan.l2gw.ha.commands.MergeCommand) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) DataObject(org.opendaylight.yangtools.yang.binding.DataObject)

Example 2 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class HwvtepHAUtil method buildGlobalConfigForHANode.

/**
 * Build HA Global node from child nodes in config data tress.
 *
 * @param tx Transaction
 * @param childNode Child Node object
 * @param haNodePath Ha node path
 * @param haGlobalCfg HA global node object
 */
public static void buildGlobalConfigForHANode(ReadWriteTransaction tx, Node childNode, InstanceIdentifier<Node> haNodePath, Optional<Node> haGlobalCfg) {
    NodeBuilder nodeBuilder = new NodeBuilder();
    HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
    hwvtepGlobalBuilder.setSwitches(buildSwitchesForHANode(childNode, haNodePath, haGlobalCfg));
    hwvtepGlobalBuilder.setManagers(buildManagersForHANode(childNode, haGlobalCfg));
    nodeBuilder.setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
    nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, hwvtepGlobalBuilder.build());
    Node configHANode = nodeBuilder.build();
    tx.merge(CONFIGURATION, haNodePath, configHANode, Boolean.TRUE);
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 3 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class VpnFootprintService method publishAddNotification.

private void publishAddNotification(final BigInteger dpnId, final String vpnName, final String rd) {
    LOG.debug("publishAddNotification: Sending notification for add dpn {} in vpn {} rd {} event ", dpnId, vpnName, rd);
    AddEventData data = new AddEventDataBuilder().setVpnName(vpnName).setRd(rd).setDpnId(dpnId).build();
    AddDpnEvent event = new AddDpnEventBuilder().setAddEventData(data).build();
    final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
    Futures.addCallback(eventFuture, new FutureCallback<Object>() {

        @Override
        public void onFailure(Throwable error) {
            LOG.error("publishAddNotification: Error in notifying listeners for add dpn {} in vpn {} rd {} event ", dpnId, vpnName, rd, error);
        }

        @Override
        public void onSuccess(Object arg) {
            LOG.info("publishAddNotification: Successful in notifying listeners for add dpn {} in vpn {} rd {}" + " event ", dpnId, vpnName, rd);
        }
    }, MoreExecutors.directExecutor());
}
Also used : AddEventDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.add.dpn.event.AddEventDataBuilder) AddDpnEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddDpnEvent) AddEventData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.add.dpn.event.AddEventData) AddDpnEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AddDpnEventBuilder)

Example 4 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class VpnFootprintService method publishRemoveNotification.

private void publishRemoveNotification(final BigInteger dpnId, final String vpnName, final String rd) {
    LOG.debug("publishRemoveNotification: Sending notification for remove dpn {} in vpn {} rd {} event ", dpnId, vpnName, rd);
    RemoveEventData data = new RemoveEventDataBuilder().setVpnName(vpnName).setRd(rd).setDpnId(dpnId).build();
    RemoveDpnEvent event = new RemoveDpnEventBuilder().setRemoveEventData(data).build();
    final ListenableFuture<?> eventFuture = notificationPublishService.offerNotification(event);
    Futures.addCallback(eventFuture, new FutureCallback<Object>() {

        @Override
        public void onFailure(Throwable error) {
            LOG.error("publishRemoveNotification: Error in notifying listeners for remove dpn {} in vpn {} rd {}" + " event ", dpnId, vpnName, rd, error);
        }

        @Override
        public void onSuccess(Object arg) {
            LOG.info("publishRemoveNotification: Successful in notifying listeners for remove dpn {} in vpn {}" + " rd {} event ", dpnId, vpnName, rd);
        }
    }, MoreExecutors.directExecutor());
}
Also used : RemoveDpnEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEventBuilder) RemoveEventDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventDataBuilder) RemoveEventData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData) RemoveDpnEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RemoveDpnEvent)

Example 5 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project netvirt by opendaylight.

the class SubnetOpDpnManager method addInterfaceToDpn.

public SubnetToDpn addInterfaceToDpn(Uuid subnetId, BigInteger 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 = VpnUtil.read(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);
        List<VpnInterfaces> vpnIntfList = subDpnBuilder.getVpnInterfaces();
        VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().setKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build();
        vpnIntfList.add(vpnIntfs);
        subDpnBuilder.setVpnInterfaces(vpnIntfList);
        subDpn = subDpnBuilder.build();
        SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
        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);
        return null;
    }
    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) 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.controller.md.sal.common.api.data.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)

Aggregations

ArrayList (java.util.ArrayList)94 ByteBuf (io.netty.buffer.ByteBuf)82 Test (org.junit.Test)62 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)34 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)33 ExecutionException (java.util.concurrent.ExecutionException)30 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 List (java.util.List)21 HashMap (java.util.HashMap)19 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17 Nullable (org.eclipse.jdt.annotation.Nullable)16 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)16 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)15 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)15 FutureCallback (com.google.common.util.concurrent.FutureCallback)14 BigInteger (java.math.BigInteger)14