use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder 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.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder in project bgpcep by opendaylight.
the class NodeChangedListener method create.
private void create(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ReadFailedException {
final InstanceIdentifier<Node> ni = identifier.firstIdentifierOf(Node.class);
final Path1 rl = value.getPath().get(0).getAugmentation(Path1.class);
final AddressFamily af = rl.getLsp().getTlvs().getLspIdentifiers().getAddressFamily();
/*
* We are trying to ensure we have source and destination nodes.
*/
final IpAddress srcIp;
final IpAddress dstIp;
if (af instanceof Ipv4Case) {
final Ipv4 ipv4 = ((Ipv4Case) af).getIpv4();
srcIp = new IpAddress(ipv4.getIpv4TunnelSenderAddress());
dstIp = new IpAddress(ipv4.getIpv4TunnelEndpointAddress());
} else if (af instanceof Ipv6Case) {
final Ipv6 ipv6 = ((Ipv6Case) af).getIpv6();
srcIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
dstIp = new IpAddress(ipv6.getIpv6TunnelSenderAddress());
} else {
throw new IllegalArgumentException("Unsupported address family: " + af.getImplementedInterface());
}
final Path path0 = value.getPath().get(0);
final Link1Builder lab = new Link1Builder();
if (path0.getBandwidth() != null) {
lab.setBandwidth(path0.getBandwidth().getBandwidth());
}
if (path0.getClassType() != null) {
lab.setClassType(path0.getClassType().getClassType());
}
lab.setSymbolicPathName(value.getName());
final InstanceIdentifier<TerminationPoint> dst = getIpTerminationPoint(trans, dstIp, null, Boolean.FALSE);
final InstanceIdentifier<TerminationPoint> src = getIpTerminationPoint(trans, srcIp, ni, rl.getLsp().isDelegate());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder slab = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1Builder();
slab.setOperationalStatus(rl.getLsp().getOperational());
slab.setAdministrativeStatus(rl.getLsp().isAdministrative() ? AdministrativeStatus.Active : AdministrativeStatus.Inactive);
final LinkId id = linkIdForLsp(identifier, value);
final LinkBuilder lb = new LinkBuilder();
lb.setLinkId(id);
lb.setSource(new SourceBuilder().setSourceNode(src.firstKeyOf(Node.class).getNodeId()).setSourceTp(src.firstKeyOf(TerminationPoint.class).getTpId()).build());
lb.setDestination(new DestinationBuilder().setDestNode(dst.firstKeyOf(Node.class).getNodeId()).setDestTp(dst.firstKeyOf(TerminationPoint.class).getTpId()).build());
lb.addAugmentation(Link1.class, lab.build());
lb.addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Link1.class, slab.build());
trans.put(LogicalDatastoreType.OPERATIONAL, linkForLsp(id), lb.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder in project bgpcep by opendaylight.
the class LinkstateTopologyBuilder method createLink.
private void createLink(final WriteTransaction trans, final UriBuilder base, final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
// defensive lookup
final LinkAttributes la;
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
if (attr != null) {
final LinkStateAttribute attrType = attr.getLinkStateAttribute();
if (attrType != null) {
la = ((LinkAttributesCase) attrType).getLinkAttributes();
} else {
LOG.debug("Missing attribute type in link {} route {}, skipping it", linkCase, value);
la = null;
}
} else {
LOG.debug("Missing attributes in link {} route {}, skipping it", linkCase, value);
la = null;
}
final IgpLinkAttributesBuilder ilab = new IgpLinkAttributesBuilder();
if (la != null) {
if (la.getMetric() != null) {
ilab.setMetric(la.getMetric().getValue());
}
ilab.setName(la.getLinkName());
}
ProtocolUtil.augmentProtocolId(value, ilab, la, linkCase.getLinkDescriptors());
final LinkBuilder lb = new LinkBuilder();
lb.setLinkId(buildLinkId(base, linkCase));
lb.addAugmentation(Link1.class, new Link1Builder().setIgpLinkAttributes(ilab.build()).build());
final NodeId srcNode = buildNodeId(base, linkCase.getLocalNodeDescriptors());
LOG.trace("Link {} implies source node {}", linkCase, srcNode);
final NodeId dstNode = buildNodeId(base, linkCase.getRemoteNodeDescriptors());
LOG.trace("Link {} implies destination node {}", linkCase, dstNode);
final TerminationPoint srcTp = buildLocalTp(base, linkCase.getLinkDescriptors());
LOG.trace("Link {} implies source TP {}", linkCase, srcTp);
final TerminationPoint dstTp = buildRemoteTp(base, linkCase.getLinkDescriptors());
LOG.trace("Link {} implies destination TP {}", linkCase, dstTp);
lb.setSource(new SourceBuilder().setSourceNode(srcNode).setSourceTp(srcTp.getTpId()).build());
lb.setDestination(new DestinationBuilder().setDestNode(dstNode).setDestTp(dstTp.getTpId()).build());
LOG.trace("Created TP {} as link source", srcTp);
NodeHolder snh = this.nodes.get(srcNode);
if (snh == null) {
snh = getNode(srcNode);
snh.addTp(srcTp, lb.getLinkId(), false);
putNode(trans, snh);
} else {
snh.addTp(srcTp, lb.getLinkId(), false);
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(snh.getNodeId()));
trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, srcTp.getKey()), srcTp);
}
LOG.debug("Created TP {} as link destination", dstTp);
NodeHolder dnh = this.nodes.get(dstNode);
if (dnh == null) {
dnh = getNode(dstNode);
dnh.addTp(dstTp, lb.getLinkId(), true);
putNode(trans, dnh);
} else {
dnh.addTp(dstTp, lb.getLinkId(), true);
final InstanceIdentifier<Node> nid = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class, new NodeKey(dnh.getNodeId()));
trans.put(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class, dstTp.getKey()), dstTp);
}
final InstanceIdentifier<Link> lid = buildLinkIdentifier(lb.getLinkId());
final Link link = lb.build();
trans.put(LogicalDatastoreType.OPERATIONAL, lid, link);
LOG.debug("Created link {} at {} for {}", link, lid, linkCase);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder in project genius by opendaylight.
the class AlivenessMonitorUtils method startLLDPMonitoring.
public void startLLDPMonitoring(IfTunnel ifTunnel, String trunkInterfaceName) {
// LLDP monitoring for the tunnel interface
if (lldpMonitoringEnabled(ifTunnel)) {
MonitorStartInput lldpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setSource(new SourceBuilder().setEndpointType(getInterfaceForMonitoring(trunkInterfaceName, ifTunnel.getTunnelSource())).build()).setMode(MonitoringMode.OneOne).setProfileId(allocateProfile(FAILURE_THRESHOLD, ifTunnel.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp)).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(lldpMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
long monitorId = rpcResult.getResult().getMonitorId();
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
createOrUpdateInterfaceMonitorIdMap(tx, trunkInterfaceName, monitorId);
createOrUpdateMonitorIdInterfaceMap(tx, trunkInterfaceName, monitorId);
LOG.trace("Started LLDP monitoring with id {}", monitorId);
}), LOG, "Error starting monitoring");
} 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.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder 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());
}
Aggregations