use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateRouterInput in project netvirt by opendaylight.
the class NeutronvpnManager method associateRouter.
/**
* It handles the invocations to the neutronvpn:associateRouter RPC method.
*/
@Override
public ListenableFuture<RpcResult<AssociateRouterOutput>> associateRouter(AssociateRouterInput input) {
SettableFuture<RpcResult<AssociateRouterOutput>> result = SettableFuture.create();
LOG.debug("associateRouter {}", input);
StringBuilder returnMsg = new StringBuilder();
Uuid vpnId = input.getVpnId();
Map<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.associaterouter.input.RouterIdsKey, org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.associaterouter.input.RouterIds> keyRouterIdsMap = input.nonnullRouterIds();
Preconditions.checkArgument(!keyRouterIdsMap.isEmpty(), "associateRouter: RouterIds list is empty!");
Preconditions.checkNotNull(vpnId, "associateRouter; VpnId not found!");
Preconditions.checkNotNull(vpnId, "associateRouter; RouterIds not found!");
for (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.associaterouter.input.RouterIds routerId : keyRouterIdsMap.values()) {
VpnMap vpnMap = neutronvpnUtils.getVpnMap(vpnId);
Router rtr = neutronvpnUtils.getNeutronRouter(routerId.getRouterId());
if (vpnMap != null) {
if (rtr != null) {
Uuid extVpnId = neutronvpnUtils.getVpnForRouter(routerId.getRouterId(), true);
if (vpnMap.getRouterIds() != null && vpnMap.getRouterIds().size() > 1) {
returnMsg.append("vpn ").append(vpnId.getValue()).append(" already associated to router ").append(routerId.getRouterId());
} else if (extVpnId != null) {
returnMsg.append("router ").append(routerId.getRouterId()).append(" already associated to " + "another VPN ").append(extVpnId.getValue());
} else {
LOG.debug("associateRouter RPC: VpnId {}, routerId {}", vpnId.getValue(), routerId.getRouterId());
associateRouterToVpn(vpnId, routerId.getRouterId());
}
} else {
returnMsg.append("router not found : ").append(routerId.getRouterId());
}
} else {
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
result.set(RpcResultBuilder.<AssociateRouterOutput>failed().withWarning(ErrorType.PROTOCOL, "invalid-value", formatAndLog(LOG::error, "associate router to vpn {} failed " + "due to {}", routerId.getRouterId(), returnMsg)).build());
} else {
result.set(RpcResultBuilder.success(new AssociateRouterOutputBuilder().build()).build());
}
}
LOG.debug("associateRouter returns..");
return result;
}
Aggregations