|
27 | 27 | import org.apache.cloudstack.api.response.FirewallRuleResponse; |
28 | 28 | import org.apache.cloudstack.api.response.SslCertResponse; |
29 | 29 | import org.apache.cloudstack.api.response.SuccessResponse; |
| 30 | +import org.apache.commons.lang3.BooleanUtils; |
30 | 31 |
|
31 | 32 | import com.cloud.event.EventTypes; |
32 | 33 | import com.cloud.exception.ConcurrentOperationException; |
@@ -57,11 +58,17 @@ public class AssignCertToLoadBalancerCmd extends BaseAsyncCmd { |
57 | 58 | description = "the ID of the certificate") |
58 | 59 | Long certId; |
59 | 60 |
|
| 61 | + @Parameter(name = ApiConstants.FORCED, |
| 62 | + type = CommandType.BOOLEAN, |
| 63 | + since = "4.22", |
| 64 | + description = "Force assign the certificate. If there is a certificate assigned to the LB, it will be removed at first.") |
| 65 | + private Boolean forced; |
| 66 | + |
60 | 67 | @Override |
61 | 68 | public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, |
62 | 69 | ResourceAllocationException, NetworkRuleConflictException { |
63 | 70 | //To change body of implemented methods use File | Settings | File Templates. |
64 | | - if (_lbService.assignCertToLoadBalancer(getLbRuleId(), getCertId())) { |
| 71 | + if (_lbService.assignCertToLoadBalancer(getLbRuleId(), getCertId(), isForced())) { |
65 | 72 | SuccessResponse response = new SuccessResponse(getCommandName()); |
66 | 73 | this.setResponseObject(response); |
67 | 74 | } else { |
@@ -95,4 +102,19 @@ public Long getCertId() { |
95 | 102 | public Long getLbRuleId() { |
96 | 103 | return lbRuleId; |
97 | 104 | } |
| 105 | + |
| 106 | + public boolean isForced() { |
| 107 | + return BooleanUtils.toBoolean(forced); |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public String getSyncObjType() { |
| 112 | + return BaseAsyncCmd.networkSyncObject; |
| 113 | + } |
| 114 | + |
| 115 | + @Override |
| 116 | + public Long getSyncObjId() { |
| 117 | + LoadBalancer lb = _entityMgr.findById(LoadBalancer.class, getLbRuleId()); |
| 118 | + return (lb != null)? lb.getNetworkId(): null; |
| 119 | + } |
98 | 120 | } |
0 commit comments