use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder in project netvirt by opendaylight.
the class AclServiceUtils method getDpnForInterface.
/**
* Get the data path number for the interface.
* @param interfaceManagerRpcService interfaceManagerRpcService instance.
* @param ifName the interface name.
* @return the dpn.
*/
public static BigInteger getDpnForInterface(OdlInterfaceRpcService interfaceManagerRpcService, String ifName) {
BigInteger nodeId = BigInteger.ZERO;
try {
GetDpidFromInterfaceInput dpIdInput = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
Future<RpcResult<GetDpidFromInterfaceOutput>> dpIdOutput = interfaceManagerRpcService.getDpidFromInterface(dpIdInput);
RpcResult<GetDpidFromInterfaceOutput> dpIdResult = dpIdOutput.get();
if (dpIdResult.isSuccessful()) {
nodeId = dpIdResult.getResult().getDpid();
} else {
LOG.error("Could not retrieve DPN Id for interface {}", ifName);
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("Exception when getting dpn for interface {}", ifName, e);
}
return nodeId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getDpidFromInterface.
/**
* Gets the dpid from interface.
*
* @param interfaceName
* the interface name
* @return the dpid from interface
*/
public BigInteger getDpidFromInterface(String interfaceName) {
BigInteger dpId = null;
Future<RpcResult<GetDpidFromInterfaceOutput>> output = interfaceManagerRpcService.getDpidFromInterface(new GetDpidFromInterfaceInputBuilder().setIntfName(interfaceName).build());
try {
RpcResult<GetDpidFromInterfaceOutput> rpcResult = output.get();
if (rpcResult != null && rpcResult.isSuccessful()) {
dpId = rpcResult.getResult().getDpid();
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to get the DPN ID for interface {}", interfaceName, e);
}
return dpId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder in project netvirt by opendaylight.
the class QosNeutronUtils method getDpnForInterface.
public BigInteger getDpnForInterface(String ifName) {
BigInteger nodeId = BigInteger.ZERO;
try {
GetDpidFromInterfaceInput dpIdInput = new GetDpidFromInterfaceInputBuilder().setIntfName(ifName).build();
Future<RpcResult<GetDpidFromInterfaceOutput>> dpIdOutput = odlInterfaceRpcService.getDpidFromInterface(dpIdInput);
RpcResult<GetDpidFromInterfaceOutput> dpIdResult = dpIdOutput.get();
if (dpIdResult.isSuccessful()) {
nodeId = dpIdResult.getResult().getDpid();
} else {
LOG.error("Could not retrieve DPN Id for interface {}", ifName);
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("Exception when getting dpn for interface {}", ifName, e);
}
return nodeId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder in project netvirt by opendaylight.
the class GeniusProvider method getDpnIdFromInterfaceName.
public Optional<DpnIdType> getDpnIdFromInterfaceName(String interfaceName) {
LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
GetDpidFromInterfaceInputBuilder builder = new GetDpidFromInterfaceInputBuilder();
builder.setIntfName(interfaceName);
GetDpidFromInterfaceInput input = builder.build();
if (interfaceManagerRpcService == null) {
LOG.error("getDpnIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
return Optional.empty();
}
try {
LOG.debug("getDpnIdFromInterfaceName: invoking rpc");
RpcResult<GetDpidFromInterfaceOutput> output = interfaceManagerRpcService.getDpidFromInterface(input).get();
if (!output.isSuccessful()) {
LOG.error("getDpnIdFromInterfaceName({}) failed: {}", input, output);
return Optional.empty();
}
BigInteger dpnId = output.getResult().getDpid();
if (dpnId == null) {
return Optional.empty();
}
LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
return Optional.of(new DpnIdType(dpnId));
} catch (InterruptedException | ExecutionException e) {
LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
}
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method checkVlanRpcs.
private void checkVlanRpcs() throws Exception {
// 1. Test dpn-id fetching from interface
GetDpidFromInterfaceInput dpidFromInterfaceInput = new GetDpidFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetDpidFromInterfaceOutput>> dpidFromInterfaceOutput = odlInterfaceRpcService.getDpidFromInterface(dpidFromInterfaceInput);
Assert.assertEquals(DpnFromInterfaceOutput.newDpnFromInterfaceOutput(), dpidFromInterfaceOutput.get().getResult());
// 3. Test egress actions fetching for interface
GetEgressActionsForInterfaceInput egressActionsForInterfaceInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsForInterfaceOutput = odlInterfaceRpcService.getEgressActionsForInterface(egressActionsForInterfaceInput);
assertEqualBeans(EgressActionsForInterfaceOutput.newEgressActionsForInterfaceOutput(), egressActionsForInterfaceOutput.get().getResult());
// 4. Test egress instructions fetching for interface
GetEgressInstructionsForInterfaceInput egressInstructionsForInterfaceInput = new GetEgressInstructionsForInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetEgressInstructionsForInterfaceOutput>> egressInstructionsForInterfaceOutput = odlInterfaceRpcService.getEgressInstructionsForInterface(egressInstructionsForInterfaceInput);
assertEqualBeans(EgressInstructionsForInterfaceOutput.newEgressInstructionsForInterfaceOutput(), egressInstructionsForInterfaceOutput.get().getResult());
// 5. Test interface fetching from if-index
/* FIXME can be tested only once ResourceBatchingManager becomes testable
GetInterfaceFromIfIndexInput interfaceFromIfIndexInput = new GetInterfaceFromIfIndexInputBuilder()
.setIfIndex(1).build();
Future<RpcResult<GetInterfaceFromIfIndexOutput>> interfaceFromIfIndexOutput = odlInterfaceRpcService
.getInterfaceFromIfIndex(interfaceFromIfIndexInput);
assertEqualBeans(InterfaceFromIfIndexOutput.newInterfaceFromIfIndexOutput(),
interfaceFromIfIndexOutput.get().getResult());*/
// 6. Test interface type fetching from interface-name
GetInterfaceTypeInput interfaceTypeInput = new GetInterfaceTypeInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetInterfaceTypeOutput>> interfaceTypeOutput = odlInterfaceRpcService.getInterfaceType(interfaceTypeInput);
assertEqualBeans(InterfaceTypeOutput.newInterfaceTypeOutput(), interfaceTypeOutput.get().getResult());
// 7. Test get nodeconnector-id from interface-name
GetNodeconnectorIdFromInterfaceInput nodeconnectorIdFromInterfaceInput = new GetNodeconnectorIdFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> nodeconnectorIdFromInterfaceOutput = odlInterfaceRpcService.getNodeconnectorIdFromInterface(nodeconnectorIdFromInterfaceInput);
assertEqualBeans(NodeconnectorIdFromInterfaceOutput.newNodeconnectorIdFromInterfaceOutput(), nodeconnectorIdFromInterfaceOutput.get().getResult());
// 8. Test get port details from interface-name
GetPortFromInterfaceInput portFromInterfaceInput = new GetPortFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
Future<RpcResult<GetPortFromInterfaceOutput>> portFromInterfaceOutput = odlInterfaceRpcService.getPortFromInterface(portFromInterfaceInput);
assertEqualBeans(PortFromInterfaceOutput.newPortFromInterfaceOutput(), portFromInterfaceOutput.get().getResult());
}
Aggregations