use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorStart.
@Test
public void testMonitorStart() throws InterruptedException, ExecutionException {
Long profileId = createProfile();
MonitorStartInput input = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setDestination(new DestinationBuilder().setEndpointType(getInterface("10.0.0.1")).build()).setSource(new SourceBuilder().setEndpointType(getInterface("testInterface", "10.1.1.1")).build()).setMode(MonitoringMode.OneOne).setProfileId(profileId).build()).build();
Optional<MonitorProfile> optionalProfile = Optional.of(getTestMonitorProfile());
CheckedFuture<Optional<MonitorProfile>, ReadFailedException> proFuture = Futures.immediateCheckedFuture(optionalProfile);
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)))).thenReturn(proFuture);
CheckedFuture<Optional<MonitoringInfo>, ReadFailedException> outFuture = Futures.immediateCheckedFuture(Optional.<MonitoringInfo>absent());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringInfo.class)))).thenReturn(outFuture);
RpcResult<MonitorStartOutput> output = alivenessMonitor.monitorStart(input).get();
verify(idManager, times(2)).allocateId(any(AllocateIdInput.class));
assertTrue("Monitor start output result", output.isSuccessful());
assertNotNull("Monitor start output", output.getResult().getMonitorId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder in project netvirt by opendaylight.
the class AlivenessMonitorUtils method startIpMonitoring.
void startIpMonitoring(MacEntry macEntry, Long ipMonitorProfileId) {
if (interfaceManager.isExternalInterface(macEntry.getInterfaceName())) {
LOG.debug("IP monitoring is currently not supported through external interfaces," + "skipping IP monitoring from interface {} for IP {} (last known MAC {})", macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), macEntry.getMacAddress());
return;
}
Optional<IpAddress> gatewayIpOptional = vpnUtil.getGatewayIpAddressFromInterface(macEntry);
if (!gatewayIpOptional.isPresent()) {
LOG.info("Interface{} does not have an GatewayIp", macEntry.getInterfaceName());
return;
}
final IpAddress gatewayIp = gatewayIpOptional.get();
Optional<String> gatewayMacOptional = vpnUtil.getGWMacAddressFromInterface(macEntry, gatewayIp);
if (!gatewayMacOptional.isPresent()) {
LOG.error("Error while retrieving GatewayMac for interface{}", macEntry.getInterfaceName());
return;
}
final IpAddress targetIp = IetfInetUtil.INSTANCE.ipAddressFor(macEntry.getIpAddress());
if (ipMonitorProfileId == null || ipMonitorProfileId.equals(0L)) {
Optional<Uint32> profileIdOptional = allocateIpMonitorProfile(targetIp);
if (!profileIdOptional.isPresent()) {
LOG.error("startIpMonitoring: Error while allocating Profile Id for IP={}", targetIp);
return;
}
ipMonitorProfileId = profileIdOptional.get().toJava();
}
final PhysAddress gatewayMac = new PhysAddress(gatewayMacOptional.get());
MonitorStartInput ipMonitorInput = 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(ipMonitorProfileId).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessManager.monitorStart(ipMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
long monitorId;
if (rpcResult.isSuccessful()) {
monitorId = rpcResult.getResult().getMonitorId().toJava();
createOrUpdateInterfaceMonitorIdMap(monitorId, macEntry);
LOG.trace("Started IP 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method testGetRemotePeerAs.
@Test
public void testGetRemotePeerAs() {
final ConfigBuilder configBuilder = new ConfigBuilder();
assertEquals(AS, OpenConfigMappingUtil.getRemotePeerAs(NEIGHBOR.getConfig(), null, null));
assertEquals(AS, OpenConfigMappingUtil.getRemotePeerAs(configBuilder.build(), null, rib.getLocalAs()));
assertEquals(AS, OpenConfigMappingUtil.getRemotePeerAs(NEIGHBOR.getConfig(), EMPTY_PEERGROUP, null));
assertEquals(AS, OpenConfigMappingUtil.getRemotePeerAs(configBuilder.build(), EMPTY_PEERGROUP, rib.getLocalAs()));
assertEquals(AS, OpenConfigMappingUtil.getRemotePeerAs(null, new PeerGroupBuilder().setPeerGroupName("foo").setConfig(new ConfigBuilder().setPeerAs(AS).build()).build(), null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method testGetNeighborKey.
@Test
public void testGetNeighborKey() {
assertArrayEquals(MD5_PASSWORD.getBytes(StandardCharsets.US_ASCII), OpenConfigMappingUtil.getNeighborKey(NEIGHBOR).asMap().get(INSTANCE.inetAddressFor(NEIGHBOR_ADDRESS)));
assertNull(OpenConfigMappingUtil.getNeighborKey(EMPTY_NEIGHBOR));
assertNull(OpenConfigMappingUtil.getNeighborKey(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setConfig(new ConfigBuilder().build()).build()));
}
Aggregations