Search in sources :

Example 6 with SingleTransactionDataBroker

use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method getRemoteBCGroupBucketsOfElanExternalTeps.

public List<Bucket> getRemoteBCGroupBucketsOfElanExternalTeps(ElanInstance elanInfo, BigInteger dpnId, int bucketId) {
    ElanInstance operElanInstance = null;
    try {
        operElanInstance = new SingleTransactionDataBroker(broker).syncReadOptional(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, elanInfo.getKey()).build()).orNull();
    } catch (ReadFailedException e) {
        LOG.error("Failed to read elan instance operational path {}", elanInfo, e);
        return emptyList();
    }
    if (operElanInstance == null) {
        return emptyList();
    }
    List<ExternalTeps> teps = operElanInstance.getExternalTeps();
    if (teps == null || teps.isEmpty()) {
        return emptyList();
    }
    List<Bucket> listBucketInfo = new ArrayList<>();
    for (ExternalTeps tep : teps) {
        String externalTep = tep.getNodeid() != null ? tep.getNodeid() : tep.getTepIp().toString();
        String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId), externalTep);
        if (interfaceName == null) {
            LOG.error("Could not get interface name to ext tunnel {} {}", dpnId, tep.getTepIp());
            continue;
        }
        List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName, elanUtils.getVxlanSegmentationId(elanInfo));
        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
    }
    return listBucketInfo;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ExternalTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)

Example 7 with SingleTransactionDataBroker

use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.

the class UpgradeStateListener method update.

@Override
public void update(@Nonnull Config original, Config updated) {
    if (natMode != NatserviceConfig.NatMode.Conntrack) {
        return;
    }
    LOG.info("UpgradeStateListener update from {} to {}", original, updated);
    if (!(original.isUpgradeInProgress() && !updated.isUpgradeInProgress())) {
        return;
    }
    SingleTransactionDataBroker reader = new SingleTransactionDataBroker(dataBroker);
    ExtRouters routers;
    try {
        routers = reader.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(ExtRouters.class));
    } catch (ReadFailedException e) {
        LOG.error("Error reading external routers", e);
        return;
    }
    for (Routers router : routers.getRouters()) {
        List<ExternalIps> externalIps = router.getExternalIps();
        if (router.isEnableSnat() && externalIps != null && !externalIps.isEmpty()) {
            centralizedSwitchScheduler.scheduleCentralizedSwitch(router);
        }
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

Example 8 with SingleTransactionDataBroker

use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.

the class AclLiveStatisticsRpcServiceTest method setUp.

@Before
public void setUp() throws Exception {
    aclStatsService = new AclLiveStatisticsRpcServiceImpl(config, dataBroker, odlDirectStatsService);
    singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
    LOG.info("Acl mode: {}", config.getSecurityGroupMode());
    newElan(ELAN, ELAN_TAG);
    newElanInterface(ELAN, PORT_1, true);
    Pair<DataTreeIdentifier<Interface>, Interface> port1 = new IdentifiedInterfaceWithAclBuilder().interfaceName(PORT_1).portSecurity(true).build();
    dataBrokerUtil.put(port1);
    testInterfaceManager.addInterface(port1.getValue());
    putNewStateInterface(dataBroker, "port1", PORT_MAC_1);
    asyncEventsWaiter.awaitEventsConsumption();
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) IdentifiedInterfaceWithAclBuilder(org.opendaylight.netvirt.aclservice.tests.IdentifiedInterfaceWithAclBuilder) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) StateInterfaceBuilderHelper.putNewStateInterface(org.opendaylight.netvirt.aclservice.tests.StateInterfaceBuilderHelper.putNewStateInterface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) Before(org.junit.Before)

Example 9 with SingleTransactionDataBroker

use of org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker in project netvirt by opendaylight.

the class AclServiceTestBase method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
    setUpData();
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Before(org.junit.Before)

Aggregations

SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)9 Before (org.junit.Before)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports)2 PortKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey)2 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)2 ArrayList (java.util.ArrayList)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 DataBrokerTestModule (org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule)1 DataImportBootReady (org.opendaylight.daexim.DataImportBootReady)1 DataBrokerFailuresImpl (org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl)1 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)1 InterfaceMetaUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils)1 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)1 BatchingUtils (org.opendaylight.genius.interfacemanager.renderer.ovs.utilities.BatchingUtils)1 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)1 MDSALManager (org.opendaylight.genius.mdsalutil.internal.MDSALManager)1