CLOUDSTACK-7349: Catching exception in API assigntoloadbalancerrule command

This commit is contained in:
Jayapal 2014-08-21 11:00:04 +05:30
parent 19ffc93e2e
commit 73d53e5f43
1 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
@ -165,8 +166,14 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
CallContext.current().setEventDetails("Load balancer Id: " + getLoadBalancerId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ","));
Map<Long, List<String>> vmIdIpsMap = getVmIdIpListMap();
boolean result = false;
try {
result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap);
}catch (CloudRuntimeException ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign load balancer rule");
}
boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);