Search in sources :

Example 1 with InterfaceNameEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method createDpnToInterface.

private void createDpnToInterface(BigInteger dpId, String infName, Class<? extends InterfaceType> interfaceType) throws Exception {
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpId);
    InterfaceNameEntryKey interfaceNameEntryKey = new InterfaceNameEntryKey(infName);
    InstanceIdentifier<InterfaceNameEntry> intfid = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).child(InterfaceNameEntry.class, interfaceNameEntryKey).build();
    InterfaceNameEntryBuilder entryBuilder = new InterfaceNameEntryBuilder().setKey(interfaceNameEntryKey).setInterfaceName(infName);
    if (interfaceType != null) {
        entryBuilder.setInterfaceType(interfaceType);
    }
    tx.put(LogicalDatastoreType.OPERATIONAL, intfid, entryBuilder.build(), true);
    tx.submit().checkedGet();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InterfaceNameEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry) InterfaceNameEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryKey) InterfaceNameEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryBuilder) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) DpnToInterfaceList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)

Example 2 with InterfaceNameEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry in project genius by opendaylight.

the class InterfaceManagerCommonUtils method deleteDpnToInterface.

public void deleteDpnToInterface(BigInteger dpId, String infName, WriteTransaction transaction) {
    DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpId);
    InstanceIdentifier<DpnToInterface> dpnToInterfaceId = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).build();
    Optional<DpnToInterface> dpnToInterfaceOptional = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, dpnToInterfaceId, dataBroker);
    if (!dpnToInterfaceOptional.isPresent()) {
        LOG.debug("DPN {} is already removed from the Operational DS", dpId);
        return;
    }
    List<InterfaceNameEntry> interfaceNameEntries = dpnToInterfaceOptional.get().getInterfaceNameEntry();
    InterfaceNameEntryKey interfaceNameEntryKey = new InterfaceNameEntryKey(infName);
    InstanceIdentifier<InterfaceNameEntry> intfid = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).child(InterfaceNameEntry.class, interfaceNameEntryKey).build();
    transaction.delete(LogicalDatastoreType.OPERATIONAL, intfid);
    if (interfaceNameEntries.size() <= 1) {
        transaction.delete(LogicalDatastoreType.OPERATIONAL, dpnToInterfaceId);
    }
}
Also used : InterfaceNameEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry) InterfaceNameEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryKey) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) DpnToInterfaceList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)

Example 3 with InterfaceNameEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry in project genius by opendaylight.

the class InterfaceManagerCommonUtils method createOrUpdateDpnToInterface.

public void createOrUpdateDpnToInterface(BigInteger dpId, String infName, Class<? extends InterfaceType> interfaceType) {
    DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpId);
    InterfaceNameEntryKey interfaceNameEntryKey = new InterfaceNameEntryKey(infName);
    InstanceIdentifier<InterfaceNameEntry> intfid = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).child(InterfaceNameEntry.class, interfaceNameEntryKey).build();
    InterfaceNameEntryBuilder entryBuilder = new InterfaceNameEntryBuilder().setKey(interfaceNameEntryKey).setInterfaceName(infName);
    if (interfaceType != null) {
        entryBuilder.setInterfaceType(interfaceType);
    }
    batchingUtils.write(intfid, entryBuilder.build(), BatchingUtils.EntityType.DEFAULT_OPERATIONAL);
}
Also used : InterfaceNameEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry) InterfaceNameEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryKey) InterfaceNameEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryBuilder) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) DpnToInterfaceList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)

Example 4 with InterfaceNameEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry in project genius by opendaylight.

the class InterfaceManagerCommonUtils method getAllInterfaces.

public List<InterfaceNameEntry> getAllInterfaces(BigInteger dpnId) {
    DpnToInterfaceKey dpnToInterfaceKey = new DpnToInterfaceKey(dpnId);
    InstanceIdentifier<DpnToInterface> dpninterfaceListId = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, dpnToInterfaceKey).build();
    Optional<DpnToInterface> interfaceList = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, dpninterfaceListId, dataBroker);
    if (interfaceList.isPresent()) {
        return interfaceList.get().getInterfaceNameEntry();
    }
    return null;
}
Also used : DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)

Example 5 with InterfaceNameEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry in project genius by opendaylight.

the class InterfaceManagerServiceImpl method getDpnInterfaceList.

@Override
public ListenableFuture<GetDpnInterfaceListOutput> getDpnInterfaceList(GetDpnInterfaceListInput input) {
    BigInteger dpnid = input.getDpid();
    InstanceIdentifier<DpnToInterface> id = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, new DpnToInterfaceKey(dpnid)).build();
    Optional<DpnToInterface> entry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
    if (!entry.isPresent()) {
        LOG.warn("Could not find Operational DpnToInterface info for DPN {}. Returning empty list", dpnid);
        return buildEmptyInterfaceListResult();
    }
    List<InterfaceNameEntry> interfaceNameEntries = entry.get().getInterfaceNameEntry();
    if (interfaceNameEntries == null || interfaceNameEntries.isEmpty()) {
        LOG.debug("No Interface list found in Operational for DPN {}", dpnid);
        return buildEmptyInterfaceListResult();
    }
    List<Interfaces> interfaceList = new ArrayList<>();
    interfaceNameEntries.forEach((interfaceNameEntry) -> {
        InterfacesBuilder intf = new InterfacesBuilder().setInterfaceName(interfaceNameEntry.getInterfaceName()).setInterfaceType(interfaceNameEntry.getInterfaceType());
        interfaceList.add(intf.build());
    });
    // TODO as above, simplify the success case later, as we have the failure case below
    return Futures.immediateFuture(new GetDpnInterfaceListOutputBuilder().setInterfaces(interfaceList).build());
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) InterfaceNameEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry) GetDpnInterfaceListOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutputBuilder) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) InterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.InterfacesBuilder)

Aggregations

DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)5 InterfaceNameEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry)4 DpnToInterfaceList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)3 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)3 InterfaceNameEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryKey)3 InterfaceNameEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryBuilder)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 GetDpnInterfaceListOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutputBuilder)1 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces)1 InterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.InterfacesBuilder)1