Skip to content

Commit 73d53e5

Browse files
author
Jayapal
committed
CLOUDSTACK-7349: Catching exception in API assigntoloadbalancerrule command
1 parent 19ffc93 commit 73d53e5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignToLoadBalancerRuleCmd.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.Map;
2525

26+
import com.cloud.utils.exception.CloudRuntimeException;
2627
import org.apache.log4j.Logger;
2728

2829
import org.apache.cloudstack.api.APICommand;
@@ -165,8 +166,14 @@ public void execute() {
165166
CallContext.current().setEventDetails("Load balancer Id: " + getLoadBalancerId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ","));
166167

167168
Map<Long, List<String>> vmIdIpsMap = getVmIdIpListMap();
169+
boolean result = false;
170+
171+
try {
172+
result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap);
173+
}catch (CloudRuntimeException ex) {
174+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign load balancer rule");
175+
}
168176

169-
boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap);
170177
if (result) {
171178
SuccessResponse response = new SuccessResponse(getCommandName());
172179
setResponseObject(response);

0 commit comments

Comments
 (0)