Skip to content

Commit 1c67e34

Browse files
committed
CLOUDSTACK-3287: [GSLB] API "updateGlobalLoadBalancerRule" is not
recognised by CloudStack added api to managementServerImpl and ensure glsb config is applied to gslb service providers
1 parent 301c91c commit 1c67e34

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import javax.inject.Inject;
3030

31-
@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject = LoadBalancerResponse.class)
31+
@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject=GlobalLoadBalancerResponse.class)
3232
public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
3333
public static final Logger s_logger = Logger.getLogger(GlobalLoadBalancerResponse.class.getName());
3434

@@ -99,7 +99,15 @@ public long getEntityOwnerId() {
9999

100100
@Override
101101
public void execute() {
102-
_gslbService.updateGlobalLoadBalancerRule(this);
102+
com.cloud.user.UserContext.current().setEventDetails("Global Load balancer Id: "+getId());
103+
GlobalLoadBalancerRule gslbRule = _gslbService.updateGlobalLoadBalancerRule(this);
104+
if (gslbRule != null) {
105+
GlobalLoadBalancerResponse response = _responseGenerator.createGlobalLoadBalancerResponse(gslbRule);
106+
response.setResponseName(getCommandName());
107+
this.setResponseObject(response);
108+
} else {
109+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update global load balancer rule");
110+
}
103111
}
104112

105113
@Override
@@ -109,6 +117,6 @@ public String getEventType() {
109117

110118
@Override
111119
public String getEventDescription() {
112-
return null;
120+
return "updating global load balancer rule";
113121
}
114122
}

server/src/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
305305
import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
306306
import org.apache.cloudstack.api.command.user.region.ha.gslb.ListGlobalLoadBalancerRuleCmd;
307+
import org.apache.cloudstack.api.command.user.region.ha.gslb.UpdateGlobalLoadBalancerRuleCmd;
307308
import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd;
308309
import org.apache.cloudstack.api.command.user.resource.GetCloudIdentifierCmd;
309310
import org.apache.cloudstack.api.command.user.resource.ListHypervisorsCmd;
@@ -2767,6 +2768,7 @@ public List<Class<?>> getCommands() {
27672768
cmdList.add(CreateGlobalLoadBalancerRuleCmd.class);
27682769
cmdList.add(DeleteGlobalLoadBalancerRuleCmd.class);
27692770
cmdList.add(ListGlobalLoadBalancerRuleCmd.class);
2771+
cmdList.add(UpdateGlobalLoadBalancerRuleCmd.class);
27702772
cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
27712773
cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
27722774
cmdList.add(ListStorageProvidersCmd.class);

server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,24 +494,31 @@ public GlobalLoadBalancerRule updateGlobalLoadBalancerRule(UpdateGlobalLoadBalan
494494
_accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
495495

496496

497-
if (!GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
497+
if (algorithm != null && !GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
498498
throw new InvalidParameterValueException("Invalid Algorithm: " + algorithm);
499499
}
500500

501-
if (!GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
501+
if (stickyMethod != null && !GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
502502
throw new InvalidParameterValueException("Invalid persistence: " + stickyMethod);
503503
}
504504

505505
Transaction txn = Transaction.currentTxn();
506506
txn.start();
507-
gslbRule.setAlgorithm(algorithm);
508-
gslbRule.setPersistence(stickyMethod);
509-
gslbRule.setDescription(description);
507+
if (algorithm != null) {
508+
gslbRule.setAlgorithm(algorithm);
509+
}
510+
if (stickyMethod != null) {
511+
gslbRule.setPersistence(stickyMethod);
512+
}
513+
if (description != null) {
514+
gslbRule.setDescription(description);
515+
}
516+
gslbRule.setState(GlobalLoadBalancerRule.State.Add);
510517
_gslbRuleDao.update(gslbRule.getId(), gslbRule);
511518
txn.commit();
512519

513520
try {
514-
s_logger.debug("Updated global load balancer with id " + gslbRule.getUuid());
521+
s_logger.debug("Updating global load balancer with id " + gslbRule.getUuid());
515522

516523
// apply the gslb rule on to the back end gslb service providers on zones participating in gslb
517524
applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);

0 commit comments

Comments
 (0)