Search in sources :

Example 26 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.

the class NatUtil method getDpnsForRouter.

@Nonnull
public static List<BigInteger> getDpnsForRouter(DataBroker dataBroker, String routerUuid) {
    InstanceIdentifier id = InstanceIdentifier.builder(NeutronRouterDpns.class).child(RouterDpnList.class, new RouterDpnListKey(routerUuid)).build();
    Optional<RouterDpnList> routerDpnListData = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
    List<BigInteger> dpns = new ArrayList<>();
    if (routerDpnListData.isPresent()) {
        List<DpnVpninterfacesList> dpnVpninterfacesList = routerDpnListData.get().getDpnVpninterfacesList();
        for (DpnVpninterfacesList dpnVpnInterface : dpnVpninterfacesList) {
            dpns.add(dpnVpnInterface.getDpnId());
        }
    }
    return dpns;
}
Also used : RouterDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnListKey) ArrayList(java.util.ArrayList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BigInteger(java.math.BigInteger) DpnVpninterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesList) RouterDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList) Nonnull(javax.annotation.Nonnull)

Example 27 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.

the class VpnFloatingIpHandler method removeFromFloatingIpPortInfo.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeFromFloatingIpPortInfo(Uuid floatingIpId) {
    InstanceIdentifier id = buildfloatingIpIdToPortMappingIdentifier(floatingIpId);
    try {
        Optional<FloatingIpIdToPortMapping> optFloatingIpIdToPortMapping = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        if (optFloatingIpIdToPortMapping.isPresent() && optFloatingIpIdToPortMapping.get().isFloatingIpDeleted()) {
            LOG.debug("Deleting floating IP UUID {} to Floating IP neutron port mapping from Floating " + "IP Port Info Config DS", floatingIpId.getValue());
            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        }
    } catch (Exception e) {
        LOG.error("removeFromFloatingIpPortInfo : Deleting floating IP UUID {} to Floating IP neutron port " + "mapping from Floating IP Port Info Config DS failed", floatingIpId.getValue(), e);
    }
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) FloatingIpIdToPortMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.port.info.FloatingIpIdToPortMapping)

Example 28 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.

the class NaptSwitchHA method removeFibEntry.

private void removeFibEntry(String rd, String prefix) {
    InstanceIdentifier.InstanceIdentifierBuilder<VrfEntry> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix));
    InstanceIdentifier<VrfEntry> vrfEntryId = idBuilder.build();
    Optional<VrfEntry> ent = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
    if (ent.isPresent()) {
        LOG.debug("removeFibEntry : Removing Fib entry rd {} prefix {}", rd, prefix);
        fibManager.removeFibEntry(rd, prefix, null);
    }
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey)

Example 29 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.

the class NatOverVxlanUtil method getIdPoolInstance.

private static InstanceIdentifier<IdPool> getIdPoolInstance(String poolName) {
    InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idPoolBuilder = InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(poolName));
    InstanceIdentifier<IdPool> id = idPoolBuilder.build();
    return id;
}
Also used : InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IdPools(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools) IdPoolKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)

Example 30 with InstanceIdentifier

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier in project netvirt by opendaylight.

the class NeutronUtils method writePortStatus.

private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
    Uuid uuidObj = new Uuid(uuid);
    PortBuilder portBuilder = new PortBuilder();
    portBuilder.setUuid(uuidObj);
    portBuilder.setStatus(portStatus);
    InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
    SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
    try {
        if (create) {
            tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        } else {
            tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
        }
    } catch (TransactionCommitFailedException e) {
        LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
        return false;
    }
    return true;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) PortKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)

Aggregations

InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)142 Logger (org.slf4j.Logger)57 LoggerFactory (org.slf4j.LoggerFactory)57 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)52 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)52 ArrayList (java.util.ArrayList)47 List (java.util.List)47 Collections (java.util.Collections)40 Optional (com.google.common.base.Optional)39 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)37 BigInteger (java.math.BigInteger)36 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)35 Inject (javax.inject.Inject)34 Singleton (javax.inject.Singleton)34 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)30 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)29 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)28 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)26 PostConstruct (javax.annotation.PostConstruct)24 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)24