Search in sources :

Example 1 with GetFixedIPsForNeutronPortOutput

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;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetFixedIPsForNeutronPortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput) ExecutionException(java.util.concurrent.ExecutionException) GetFixedIPsForNeutronPortInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortInputBuilder)

Example 2 with GetFixedIPsForNeutronPortOutput

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;
}
Also used : GetFixedIPsForNeutronPortOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutputBuilder) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ArrayList(java.util.ArrayList) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) GetFixedIPsForNeutronPortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 GetFixedIPsForNeutronPortOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutput)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 ArrayList (java.util.ArrayList)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 LearntVpnVipToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort)1 GetFixedIPsForNeutronPortInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortInputBuilder)1 GetFixedIPsForNeutronPortOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.GetFixedIPsForNeutronPortOutputBuilder)1 FixedIps (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)1 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)1