use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class NatOverVxlanUtil method releaseVNI.
public static void releaseVNI(String vniKey, IdManagerService idManager) {
ReleaseIdInput releaseIdInput = new ReleaseIdInputBuilder().setPoolName(NatConstants.ODL_VNI_POOL_NAME).setIdKey(vniKey).build();
try {
Future<RpcResult<Void>> result = idManager.releaseId(releaseIdInput);
RpcResult<Void> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("releaseVNI : Unable to release ID {} from OpenDaylight VXLAN VNI range pool. Error {}", vniKey, rpcResult.getErrors());
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("releaseVNI : Exception in release VNI for Key {}", vniKey, e);
}
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class NexthopManager method getEgressActionsForInterface.
protected List<ActionInfo> getEgressActionsForInterface(final String ifName, int actionKey) {
List<ActionInfo> listActionInfo = new ArrayList<>();
try {
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManager.getEgressActionsForInterface(new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).build());
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
} else {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = rpcResult.getResult().getAction();
for (Action action : actions) {
actionKey = action.getKey().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();
listActionInfo.add(new ActionSetFieldVlanVid(actionKey, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
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(), nxRegLoad.getDst().getEnd(), nxRegLoad.getValue().longValue()));
}
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when egress actions for interface {}", ifName, e);
}
return listActionInfo;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class NexthopManager method installGroupOnDpn.
private void installGroupOnDpn(long groupId, BigInteger dpnId, String groupName, List<BucketInfo> bucketsInfo, String nextHopKey, GroupTypes groupType) {
NodeRef nodeRef = FibUtil.buildNodeRef(dpnId);
Buckets buckets = FibUtil.buildBuckets(bucketsInfo);
GroupRef groupRef = new GroupRef(FibUtil.buildGroupInstanceIdentifier(groupId, dpnId));
AddGroupInput input = new AddGroupInputBuilder().setNode(nodeRef).setGroupId(new GroupId(groupId)).setBuckets(buckets).setGroupRef(groupRef).setGroupType(groupType).setGroupName(groupName).build();
Future<RpcResult<AddGroupOutput>> groupStats = salGroupService.addGroup(input);
RpcResult<AddGroupOutput> rpcResult = null;
try {
rpcResult = groupStats.get();
if (rpcResult != null && rpcResult.isSuccessful()) {
LOG.info("Group {} with key {} has been successfully installed directly on dpn {}.", groupId, nextHopKey, dpnId);
} else {
LOG.error("Unable to install group {} with key {} directly on dpn {} due to {}.", groupId, nextHopKey, dpnId, rpcResult != null ? rpcResult.getErrors() : null);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error while installing group {} directly on dpn {}", groupId, dpnId);
}
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class NexthopManager method createNextHopPointer.
protected long createNextHopPointer(String nexthopKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(NEXTHOP_ID_POOL_NAME).setIdKey(nexthopKey).build();
// TODO: Proper error handling once IdManager code is complete
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
return rpcResult.getResult().getIdValue();
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.trace("", e);
}
return 0;
}
use of org.opendaylight.yangtools.yang.common.RpcResult in project netvirt by opendaylight.
the class ElanL2GatewayUtils method createItmTunnels.
public static void createItmTunnels(DataBroker dataBroker, ItmRpcService itmRpcService, String hwvtepId, String psName, IpAddress tunnelIp) {
AddL2GwDeviceInputBuilder builder = new AddL2GwDeviceInputBuilder();
builder.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
builder.setNodeId(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepId), psName).getValue());
builder.setIpAddress(tunnelIp);
try {
deleteStaleTunnelsOfHwvtepInITM(dataBroker, itmRpcService, hwvtepId, psName, tunnelIp);
Future<RpcResult<Void>> result = itmRpcService.addL2GwDevice(builder.build());
RpcResult<Void> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
LOG.info("Created ITM tunnels for {}", hwvtepId);
} else {
LOG.error("Failed to create ITM Tunnels: {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("RPC to create ITM tunnels failed", e);
}
}
Aggregations