use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors 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.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class AlivenessMonitorUtils method createMonitorProfile.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public Optional<Uint32> createMonitorProfile(MonitorProfileCreateInput monitorProfileCreateInput) {
try {
Future<RpcResult<MonitorProfileCreateOutput>> result = alivenessManager.monitorProfileCreate(monitorProfileCreateInput);
RpcResult<MonitorProfileCreateOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return Optional.of(rpcResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Profile Id Id returned with Errors {}.. Trying to fetch existing profile ID", rpcResult.getErrors());
try {
Profile createProfile = monitorProfileCreateInput.getProfile();
Future<RpcResult<MonitorProfileGetOutput>> existingProfile = alivenessManager.monitorProfileGet(buildMonitorGetProfile(createProfile.getMonitorInterval().toJava(), createProfile.getMonitorWindow().toJava(), createProfile.getFailureThreshold().toJava(), createProfile.getProtocolType()));
RpcResult<MonitorProfileGetOutput> rpcGetResult = existingProfile.get();
if (rpcGetResult.isSuccessful()) {
return Optional.of(rpcGetResult.getResult().getProfileId());
} else {
LOG.warn("RPC Call to Get Existing Profile Id returned with Errors {}", rpcGetResult.getErrors());
}
} catch (Exception e) {
LOG.warn("Exception when getting existing profile", e);
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when allocating profile Id", e);
}
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class NeutronvpnManager method addInterVpnRoutes.
/**
* Creates the corresponding static routes in the specified VPN. These static routes must be point to an
* InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink. Otherwise the
* route will be ignored.
*
* @param vpnName the VPN identifier
* @param interVpnLinkRoutes The list of static routes
* @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
*/
public void addInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
for (Routes route : interVpnLinkRoutes) {
String nexthop = route.getNexthop().stringValue();
String destination = route.getDestination().stringValue();
InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
AddStaticRouteInput rpcInput = new AddStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
Future<RpcResult<AddStaticRouteOutput>> labelOuputFtr = vpnRpcService.addStaticRoute(rpcInput);
RpcResult<AddStaticRouteOutput> rpcResult;
try {
rpcResult = labelOuputFtr.get();
if (rpcResult.isSuccessful()) {
LOG.debug("Label generated for destination {} is: {}", destination, rpcResult.getResult().getLabel());
} else {
LOG.error("RPC call to add a static Route to {} with nexthop {} returned with errors {}", destination, nexthop, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error happened while invoking addStaticRoute RPC for nexthop {} with destination {} " + "for VPN {}", nexthop, destination, vpnName.getValue(), e);
}
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", route.getDestination().stringValue(), nexthop);
continue;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class NeutronSecurityGroupUtils method allocateId.
public Integer allocateId(String poolName, String idKey, Integer defaultId) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
Integer allocatedId = rpcResult.getResult().getIdValue().intValue();
LOG.debug("Allocated ACL ID: {} with key: {} into pool: {}", allocatedId, idKey, poolName);
return allocatedId;
} else {
LOG.error("RPC Call to Get Unique Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when getting Unique Id for key {} from pool {} ", idKey, poolName, e);
}
return defaultId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors in project netvirt by opendaylight.
the class NeutronSecurityGroupUtils method releaseId.
public void releaseId(String poolName, String idKey) {
ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<ReleaseIdOutput>> result = idManager.releaseId(idInput);
RpcResult<ReleaseIdOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to release Id with Key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
} else {
LOG.debug("Released ACL ID with key: {} from pool: {}", idKey, poolName);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when releasing Id for key {} from pool {} ", idKey, poolName, e);
}
}
Aggregations