use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput in project netvirt by opendaylight.
the class InterfaceStateEventListener method getFixedIpsForPort.
private List<String> getFixedIpsForPort(String interfname) {
LOG.debug("getFixedIpsForPort : getFixedIpsForPort method is called for interface {}", interfname);
try {
Future<RpcResult<GetFixedIPsForNeutronPortOutput>> result = neutronVpnService.getFixedIPsForNeutronPort(new GetFixedIPsForNeutronPortInputBuilder().setPortId(new Uuid(interfname)).build());
RpcResult<GetFixedIPsForNeutronPortOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("getFixedIpsForPort : RPC Call to GetFixedIPsForNeutronPortOutput returned with Errors {}", rpcResult.getErrors());
} else {
return rpcResult.getResult().getFixedIPs();
}
} catch (InterruptedException | ExecutionException | NullPointerException ex) {
LOG.error("getFixedIpsForPort : Exception while receiving fixedIps for port {}", interfname, ex);
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput in project netvirt by opendaylight.
the class NeutronvpnManager method getFixedIPsForNeutronPort.
/**
* It handles the invocations to the neutronvpn:getFixedIPsForNeutronPort RPC method.
*/
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<GetFixedIPsForNeutronPortOutput>> getFixedIPsForNeutronPort(GetFixedIPsForNeutronPortInput input) {
GetFixedIPsForNeutronPortOutputBuilder opBuilder = new GetFixedIPsForNeutronPortOutputBuilder();
SettableFuture<RpcResult<GetFixedIPsForNeutronPortOutput>> result = SettableFuture.create();
Uuid portId = input.getPortId();
StringBuilder returnMsg = new StringBuilder();
try {
List<String> fixedIPList = new ArrayList<>();
Port port = neutronvpnUtils.getNeutronPort(portId);
if (port != null) {
List<FixedIps> fixedIPs = port.getFixedIps();
for (FixedIps ip : fixedIPs) {
fixedIPList.add(String.valueOf(ip.getIpAddress().getValue()));
}
} else {
returnMsg.append("neutron port: ").append(portId.getValue()).append(" not found");
}
if (returnMsg.length() != 0) {
result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>failed().withWarning(ErrorType.PROTOCOL, "invalid-value", formatAndLog(LOG::error, "Retrieval of FixedIPList for neutron port failed due to {}", returnMsg)).build());
} else {
opBuilder.setFixedIPs(fixedIPList);
result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>success().withResult(opBuilder.build()).build());
result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>success().build());
}
} catch (Exception ex) {
result.set(RpcResultBuilder.<GetFixedIPsForNeutronPortOutput>failed().withError(ErrorType.APPLICATION, formatAndLog(LOG::error, "Retrieval of FixedIPList for neutron port {} failed due to {}", portId.getValue(), ex.getMessage(), ex)).build());
}
return result;
}
Aggregations