use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutputBuilder 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