Search in sources :

Example 1 with Elements

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements in project netvirt by opendaylight.

the class LogicalSwitchesCmdTest method getData.

HwvtepGlobalAugmentation getData(LogicalSwitches[] elements) {
    HwvtepGlobalAugmentationBuilder newDataBuilder = new HwvtepGlobalAugmentationBuilder();
    List<LogicalSwitches> ls = new ArrayList<>();
    for (LogicalSwitches ele : elements) {
        ls.add(ele);
    }
    newDataBuilder.setLogicalSwitches(ls);
    return newDataBuilder.build();
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) ArrayList(java.util.ArrayList)

Example 2 with Elements

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements in project netvirt by opendaylight.

the class NeutronTrunkChangeListener method deleteSubPortInterface.

private void deleteSubPortInterface(SubPorts subPort) {
    String portName = subPort.getPortId().getValue();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (iface == null) {
            LOG.warn("Interface not present for SubPort {}", subPort);
            return futures;
        }
        /*
             * We'll reset interface back to way it was? Can IFM handle parentRef delete?
             */
        InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
        // Reset augmentations
        interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
        IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
        interfaceBuilder.addAugmentation(IfL2vlan.class, ifL2vlan);
        iface = interfaceBuilder.build();
        /*
             * There is no means to do an update to remove elements from a node.
             * Our solution is to get existing iface, remove parentRef and VlanId,
             * and do a put to replace existing entry. This works out better as put
             * has better performance than merge.
             * Only drawback is any in-flight changes might be lost, but that is a corner case
             * and this being subport delete path, don't expect any significant changes to
             * corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
             */
        WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
        txn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
        LOG.trace("Resetting trunk member interface {}", iface);
        futures.add(txn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 3 with Elements

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements in project controller by opendaylight.

the class BaListBuilder method buildInnerList.

private static List<InnerList> buildInnerList(final int index, final int elements) {
    List<InnerList> innerList = new ArrayList<>(elements);
    final String itemStr = "Item-" + String.valueOf(index) + "-";
    for (int i = 0; i < elements; i++) {
        innerList.add(new InnerListBuilder().setKey(new InnerListKey(i)).setName(i).setValue(itemStr + String.valueOf(i)).build());
    }
    return innerList;
}
Also used : InnerList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList) InnerListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListBuilder) ArrayList(java.util.ArrayList) InnerListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListKey)

Example 4 with Elements

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements in project bgpcep by opendaylight.

the class AsPathPrepend method applyExportAction.

@Override
public Attributes applyExportAction(final RouteEntryBaseAttributes routeEntryInfo, final BGPRouteEntryExportParameters exportParameters, final Attributes attributes, final SetAsPathPrepend actions) {
    final List<Segments> oldSegments = attributes.getAsPath().getSegments();
    /*
         * We need to check the first segment.
         * If it has as-set then new as-sequence with local AS is prepended.
         * If it has as-sequence, we may add local AS when it has less than 255 elements.
         * Otherwise we need to create new as-sequence for local AS.
         */
    final ArrayList<AsNumber> newAsSequence = new ArrayList<>();
    newAsSequence.add(new AsNumber(routeEntryInfo.getLocalAs()));
    List<Segments> newSegments = new ArrayList<>();
    if (oldSegments == null || oldSegments.isEmpty()) {
        newSegments = Collections.singletonList(new SegmentsBuilder().setAsSequence(newAsSequence).build());
    } else {
        final Segments firstSegment = oldSegments.remove(0);
        final List<AsNumber> firstAsSequence = firstSegment.getAsSequence();
        if (firstAsSequence != null && firstAsSequence.size() < Values.UNSIGNED_BYTE_MAX_VALUE) {
            newAsSequence.addAll(firstAsSequence);
            newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
        } else {
            newSegments.add(new SegmentsBuilder().setAsSequence(newAsSequence).build());
            newSegments.add(firstSegment);
        }
        newSegments.addAll(oldSegments);
    }
    return new AttributesBuilder(attributes).setAsPath(new AsPathBuilder().setSegments(newSegments).build()).build();
}
Also used : AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder) SegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.SegmentsBuilder) ArrayList(java.util.ArrayList) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)

Example 5 with Elements

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements in project genius by opendaylight.

the class OvsdbTepRemoveConfigHelper method removeUnknownTzTepFromTepsNotHosted.

/**
 * Removes the TEP from the not-hosted transport zone in the TepsNotHosted list
 * from ITM Operational Datastore.
 *
 * @param tzName transport zone name in string
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param dpnId bridge datapath ID in BigInteger
 * @param dataBroker data broker handle to perform operations on operational datastore
 * @param wrTx WriteTransaction object
 */
public static void removeUnknownTzTepFromTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpnId, DataBroker dataBroker, WriteTransaction wrTx) {
    List<UnknownVteps> vtepList = null;
    TepsInNotHostedTransportZone tepsInNotHostedTransportZone = ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
    if (tepsInNotHostedTransportZone == null) {
        LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS. Nothing to do for TEP removal.", tzName);
        return;
    } else {
        vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
        if (vtepList == null || vtepList.isEmpty()) {
            // case: vtep list does not exist or it has no elements
            LOG.trace("Remove TEP from unhosted TZ ({}) when no vtep-list in the TZ. Nothing to do.", tzName);
        } else {
            // case: vtep list has elements
            boolean vtepFound = false;
            UnknownVteps foundVtep = null;
            for (UnknownVteps vtep : vtepList) {
                if (vtep.getDpnId().equals(dpnId)) {
                    vtepFound = true;
                    foundVtep = vtep;
                    break;
                }
            }
            if (vtepFound) {
                // vtep is found, update it with tep-ip
                LOG.trace("Remove TEP with IP ({}) from unhosted TZ ({}) inside not-hosted-transport-zones list.", tepIpAddress, tzName);
                if (vtepList.size() == 1) {
                    removeTzFromTepsNotHosted(tzName, wrTx);
                } else {
                    removeVtepFromTepsNotHosted(tzName, dpnId, wrTx);
                }
                vtepList.remove(foundVtep);
            }
        }
    }
}
Also used : TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)

Aggregations

Elements (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)14 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)8 ElementsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder)8 ByteBuf (io.netty.buffer.ByteBuf)6 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)4 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)4 HelloMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage)4 HelloInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput)3 HelloInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder)3 BigInteger (java.math.BigInteger)2 DefaultDeserializerFactoryTest (org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)2 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)2 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)1