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 EvpnUtils method getEndpointIpAddressForDPN.
@Nullable
public String getEndpointIpAddressForDPN(Uint64 dpnId) {
Future<RpcResult<GetDpnEndpointIpsOutput>> result = itmRpcService.getDpnEndpointIps(new GetDpnEndpointIpsInputBuilder().setSourceDpid(dpnId).build());
RpcResult<GetDpnEndpointIpsOutput> rpcResult = null;
try {
rpcResult = result.get();
} catch (InterruptedException e) {
LOG.error("getnextHopIpFromRpcOutput : InterruptedException for dpnid {}", dpnId, e);
return null;
} catch (ExecutionException e) {
LOG.error("getnextHopIpFromRpcOutput : ExecutionException for dpnid {}", dpnId, e);
return null;
}
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to getDpnEndpointIps returned with Errors {}", rpcResult.getErrors());
return null;
}
List<IpAddress> nexthopIpList = rpcResult.getResult().getNexthopipList();
return nexthopIpList.get(0).getIpv4Address().getValue();
}
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 NeutronEvpnManager method createEVPN.
@SuppressWarnings("checkstyle:IllegalCatch")
public ListenableFuture<RpcResult<CreateEVPNOutput>> createEVPN(CreateEVPNInput input) {
CreateEVPNOutputBuilder opBuilder = new CreateEVPNOutputBuilder();
SettableFuture<RpcResult<CreateEVPNOutput>> result = SettableFuture.create();
List<RpcError> errorList = new ArrayList<>();
int failurecount = 0;
List<String> existingRDs = neutronvpnUtils.getExistingRDs();
for (Evpn vpn : input.nonnullEvpn()) {
if (vpn.getRouteDistinguisher() == null || vpn.getImportRT() == null || vpn.getExportRT() == null) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} due to absence of RD/iRT/eRT input", vpn.getId().getValue())));
continue;
}
if (vpn.getRouteDistinguisher().size() > 1) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} due to multiple RD input {}", vpn.getId().getValue(), vpn.getRouteDistinguisher())));
continue;
}
if (existingRDs.contains(vpn.getRouteDistinguisher().get(0))) {
errorList.add(RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", formatAndLog(LOG::warn, "Creation of EVPN failed for VPN {} as another VPN with the same RD {} is already " + "configured", vpn.getId().getValue(), vpn.getRouteDistinguisher().get(0))));
continue;
}
try {
List<String> rdList = vpn.getRouteDistinguisher() != null ? new ArrayList<>(vpn.getRouteDistinguisher()) : new ArrayList<>();
List<String> importRdList = vpn.getImportRT() != null ? new ArrayList<>(vpn.getImportRT()) : new ArrayList<>();
List<String> exportRdList = vpn.getExportRT() != null ? new ArrayList<>(vpn.getExportRT()) : new ArrayList<>();
neutronvpnManager.createVpn(vpn.getId(), vpn.getName(), vpn.getTenantId(), rdList, importRdList, exportRdList, null, /*router-id*/
null, /*network-id*/
true, /*isL2Vpn*/
0);
} catch (Exception ex) {
errorList.add(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, formatAndLog(LOG::error, "Creation of EVPN failed for VPN {}", vpn.getId().getValue(), ex), ex.getMessage()));
failurecount++;
}
}
if (failurecount != 0) {
result.set(RpcResultBuilder.<CreateEVPNOutput>failed().withRpcErrors(errorList).build());
} else {
List<String> errorResponseList = new ArrayList<>();
if (!errorList.isEmpty()) {
for (RpcError rpcError : errorList) {
errorResponseList.add("ErrorType: " + rpcError.getErrorType() + ", ErrorTag: " + rpcError.getTag() + ", ErrorMessage: " + rpcError.getMessage());
}
} else {
errorResponseList.add("EVPN creation successful with no errors");
}
opBuilder.setResponse(errorResponseList);
result.set(RpcResultBuilder.success(opBuilder.build()).build());
}
return result;
}
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 VpnExtraRouteHelper method getTunnelType.
@Nullable
public static Class<? extends TunnelTypeBase> getTunnelType(ItmRpcService itmRpcService, String ifName) {
try {
Future<RpcResult<GetTunnelTypeOutput>> result = itmRpcService.getTunnelType(new GetTunnelTypeInputBuilder().setIntfName(ifName).build());
RpcResult<GetTunnelTypeOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
} else {
return rpcResult.getResult().getTunnelType();
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when getting tunnel interface Id for tunnel type", e);
}
return null;
}
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 NexthopManager method getEgressActionsForInterface.
protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey, boolean isTunnelInterface, Uint32 vpnId, String destIpPrefix) {
List<Action> actions;
try {
if (isTunnelInterface && interfaceManager.isItmDirectTunnelsEnabled()) {
RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmManager.getEgressActionsForTunnel(new GetEgressActionsForTunnelInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress tunnel actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
} else {
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = odlInterfaceRpcService.getEgressActionsForInterface(new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build()).get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress vm actions for interface {} vpnId {} ipPrefix {} returned with " + "Errors {}", ifName, vpnId, destIpPrefix, rpcResult.getErrors());
return Collections.emptyList();
} else {
actions = new ArrayList<Action>(rpcResult.getResult().nonnullAction().values());
}
}
List<ActionInfo> listActionInfo = new ArrayList<>();
for (Action action : actions) {
actionKey = action.key().getOrder() + actionKey;
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
if (actionClass instanceof OutputActionCase) {
listActionInfo.add(new ActionOutput(actionKey, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
} else if (actionClass instanceof PushVlanActionCase) {
listActionInfo.add(new ActionPushVlan(actionKey));
} else if (actionClass instanceof SetFieldCase) {
if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue().toJava();
listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable().toJava();
listActionInfo.add(new ActionNxResubmit(actionKey, tableId));
} else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
listActionInfo.add(new ActionRegLoad(actionKey, NxmNxReg6.class, nxRegLoad.getDst().getStart().toJava(), nxRegLoad.getDst().getEnd().toJava(), nxRegLoad.getValue().longValue()));
}
}
return listActionInfo;
} catch (InterruptedException | ExecutionException | NullPointerException e) {
LOG.error("Exception when egress actions for interface {} isTunnel {} vpnId {} ipPrefix {}", ifName, isTunnelInterface, vpnId, destIpPrefix, e);
}
LOG.warn("Exception when egress actions for interface {}", ifName);
return Collections.emptyList();
}
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 VpnUtil method getUniqueId.
public Uint32 getUniqueId(String poolName, String idKey) {
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()) {
return rpcResult.getResult().getIdValue();
} else {
LOG.error("getUniqueId: RPC Call to Get Unique Id from pool {} with key {} returned with Errors {}", poolName, idKey, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("getUniqueId: Exception when getting Unique Id from pool {} for key {}", poolName, idKey, e);
}
return Uint32.ZERO;
}
Aggregations