Search in sources :

Example 1 with Start

use of org.opendaylight.yang.gen.v1.urn.example.data.center.rev180807.device.Start in project netvirt by opendaylight.

the class AlivenessMonitorUtils method startArpMonitoring.

public static void startArpMonitoring(MacEntry macEntry, Long arpMonitorProfileId, AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker, INeutronVpnManager neutronVpnService, IInterfaceManager interfaceManager) {
    if (interfaceManager.isExternalInterface(macEntry.getInterfaceName())) {
        LOG.debug("ARP monitoring is currently not supported through external interfaces," + "skipping ARP monitoring from interface {} for IP {} (last known MAC {})", macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), macEntry.getMacAddress());
        return;
    }
    Optional<IpAddress> gatewayIpOptional = VpnUtil.getGatewayIpAddressFromInterface(macEntry.getInterfaceName(), neutronVpnService);
    if (!gatewayIpOptional.isPresent()) {
        LOG.error("Error while retrieving GatewayIp for interface{}", macEntry.getInterfaceName());
        return;
    }
    final IpAddress gatewayIp = gatewayIpOptional.get();
    Optional<String> gatewayMacOptional = VpnUtil.getGWMacAddressFromInterface(macEntry, gatewayIp, dataBroker);
    if (!gatewayMacOptional.isPresent()) {
        LOG.error("Error while retrieving GatewayMac for interface{}", macEntry.getInterfaceName());
        return;
    }
    final PhysAddress gatewayMac = new PhysAddress(gatewayMacOptional.get());
    if (arpMonitorProfileId == null || arpMonitorProfileId.equals(0L)) {
        Optional<Long> profileIdOptional = allocateProfile(alivenessMonitorService, ArpConstants.FAILURE_THRESHOLD, ArpConstants.ARP_CACHE_TIMEOUT_MILLIS, ArpConstants.MONITORING_WINDOW, EtherTypes.Arp);
        if (!profileIdOptional.isPresent()) {
            LOG.error("Error while allocating Profile Id for alivenessMonitorService");
            return;
        }
        arpMonitorProfileId = profileIdOptional.get();
    }
    IpAddress targetIp = new IpAddress(new Ipv4Address(macEntry.getIpAddress().getHostAddress()));
    MonitorStartInput arpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setSource(new SourceBuilder().setEndpointType(getSourceEndPointType(macEntry.getInterfaceName(), gatewayIp, gatewayMac)).build()).setDestination(new DestinationBuilder().setEndpointType(getEndPointIpAddress(targetIp)).build()).setMode(MonitoringMode.OneOne).setProfileId(arpMonitorProfileId).build()).build();
    try {
        Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(arpMonitorInput);
        RpcResult<MonitorStartOutput> rpcResult = result.get();
        long monitorId;
        if (rpcResult.isSuccessful()) {
            monitorId = rpcResult.getResult().getMonitorId();
            createOrUpdateInterfaceMonitorIdMap(monitorId, macEntry);
            LOG.trace("Started ARP monitoring with id {}", monitorId);
        } else {
            LOG.warn("RPC Call to start monitoring returned with Errors {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when starting monitoring", e);
    }
}
Also used : MonitorStartOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.SourceBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MonitorStartInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.DestinationBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.ConfigBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ExecutionException(java.util.concurrent.ExecutionException) MonitorStartInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInputBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 2 with Start

use of org.opendaylight.yang.gen.v1.urn.example.data.center.rev180807.device.Start in project netvirt by opendaylight.

the class AclServiceTestBase method newInterfaceWithAap.

@Test
public void newInterfaceWithAap() throws Exception {
    LOG.info("newInterfaceWithAap test - start");
    // AAP with same MAC and different IP
    AllowedAddressPairs aapWithSameMac = buildAap("10.0.0.100/32", PORT_MAC_2);
    // AAP with different MAC and different IP
    AllowedAddressPairs aapWithDifferentMac = buildAap("10.0.0.101/32", "0D:AA:D8:42:30:A4");
    newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
    newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Arrays.asList(AAP_PORT_2, aapWithSameMac, aapWithDifferentMac));
    dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_1).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
    dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_2).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
    prepareInterfaceWithIcmpAcl();
    // When
    putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
    putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
    asyncEventsWaiter.awaitEventsConsumption();
    // Then
    newInterfaceWithAapCheck();
    LOG.info("newInterfaceWithAap test - end");
}
Also used : IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) Test(org.junit.Test)

Example 3 with Start

use of org.opendaylight.yang.gen.v1.urn.example.data.center.rev180807.device.Start in project netvirt by opendaylight.

the class AclServiceTestBase method newInterfaceWithIcmpAcl.

@Test
public void newInterfaceWithIcmpAcl() throws Exception {
    LOG.info("newInterfaceWithIcmpAcl - start");
    newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
    newAllowedAddressPair(PORT_2, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_2));
    dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_1).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
    dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName(PORT_2).addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
    // Given
    prepareInterfaceWithIcmpAcl();
    // When
    putNewStateInterface(dataBroker, PORT_1, PORT_MAC_1);
    putNewStateInterface(dataBroker, PORT_2, PORT_MAC_2);
    asyncEventsWaiter.awaitEventsConsumption();
    // Then
    newInterfaceWithIcmpAclCheck();
    LOG.info("newInterfaceWithIcmpAcl - end");
}
Also used : IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) Test(org.junit.Test)

Example 4 with Start

use of org.opendaylight.yang.gen.v1.urn.example.data.center.rev180807.device.Start in project netvirt by opendaylight.

the class AclServiceTestBase method newInterface.

@Test
public void newInterface() throws Exception {
    LOG.info("newInterface - start");
    newAllowedAddressPair(PORT_1, Collections.singletonList(SG_UUID_1), Collections.singletonList(AAP_PORT_1));
    testInterfaceManager.addInterfaceInfo(newInterfaceInfo("port1"));
    dataBrokerUtil.put(new IdentifiedSubnetIpPrefixBuilder().interfaceName("port1").addAllIpPrefixOrAddress(Collections.singletonList(new IpPrefixOrAddress(SUBNET_IP_PREFIX_1.toCharArray()))));
    // When
    putNewStateInterface(dataBroker, "port1", PORT_MAC_1);
    asyncEventsWaiter.awaitEventsConsumption();
    // Then
    newInterfaceCheck();
    LOG.info("newInterface - end");
}
Also used : IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) Test(org.junit.Test)

Example 5 with Start

use of org.opendaylight.yang.gen.v1.urn.example.data.center.rev180807.device.Start in project openflowplugin by opendaylight.

the class Activator method onSessionInitialized.

@Override
public void onSessionInitialized(ConsumerContext session) {
    SalFlowService flowService = session.getRpcService(SalFlowService.class);
    new SimpleDropFirewall(flowService).start();
}
Also used : SalFlowService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService)

Aggregations

Test (org.junit.Test)35 ArrayList (java.util.ArrayList)26 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)13 List (java.util.List)13 Ignore (org.junit.Ignore)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 ByteBuf (io.netty.buffer.ByteBuf)12 Inject (javax.inject.Inject)12 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)12 Collections (java.util.Collections)11 Optional (java.util.Optional)11 NonNull (org.eclipse.jdt.annotation.NonNull)10 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)10 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)9 Map (java.util.Map)8 Nullable (org.eclipse.jdt.annotation.Nullable)8 Before (org.junit.Before)8 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)8 RetryingManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.RetryingManagedNewTransactionRunner)8 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)7