mirror of https://github.com/apache/cloudstack.git
fixing some issues found in unit testing
This commit is contained in:
parent
d56ccd438d
commit
83d381f25c
|
|
@ -38,6 +38,9 @@ public class GlobalLoadBalancerConfigCommand extends Command {
|
|||
// session persistence type
|
||||
String persistenceType;
|
||||
|
||||
// unique Id given per gslb rule, that is uniquely represents glsb rule on all participant sites
|
||||
long gslbId;
|
||||
|
||||
// true if global load balancer rule is being deleted
|
||||
boolean revoked;
|
||||
|
||||
|
|
@ -48,11 +51,13 @@ public class GlobalLoadBalancerConfigCommand extends Command {
|
|||
String lbMethod,
|
||||
String persistenceType,
|
||||
String serviceType,
|
||||
long gslbId,
|
||||
boolean revoked) {
|
||||
this.domainName = domainName;
|
||||
this.serviceType = serviceType;
|
||||
this.lbMethod = lbMethod;
|
||||
this.persistenceType = persistenceType;
|
||||
this.gslbId = gslbId;
|
||||
this.revoked = revoked;
|
||||
}
|
||||
|
||||
|
|
@ -76,6 +81,10 @@ public class GlobalLoadBalancerConfigCommand extends Command {
|
|||
return persistenceType;
|
||||
}
|
||||
|
||||
public long getGslbId() {
|
||||
return this.gslbId;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class SiteLoadBalancerConfig {
|
|||
String servicePublicIp;
|
||||
|
||||
// port corresponding to the site load balanced service
|
||||
String port;
|
||||
String servicePort;
|
||||
|
||||
// Private IP corresponding to the GSLB service provider in the site.
|
||||
String gslbProviderPrivateIp;
|
||||
|
|
@ -42,16 +42,22 @@ public class SiteLoadBalancerConfig {
|
|||
// Public IP corresponding to the GSLB service provider in the site.
|
||||
String gslbProviderPublicIp;
|
||||
|
||||
public SiteLoadBalancerConfig(boolean revoked, String serviceType, String servicePublicIp, String port) {
|
||||
// zone id in which site is located
|
||||
long dataCenterId;
|
||||
|
||||
public SiteLoadBalancerConfig(boolean revoked, String serviceType, String servicePublicIp, String servicePort,
|
||||
long dataCenterId) {
|
||||
this.revoked = revoked;
|
||||
this.serviceType = serviceType;
|
||||
this.servicePublicIp = servicePublicIp;
|
||||
this.port = port;
|
||||
this.servicePort = servicePort;
|
||||
this.dataCenterId = dataCenterId;
|
||||
}
|
||||
|
||||
public SiteLoadBalancerConfig(String gslbProviderPublicIP, String gslbProviderPrivateIp, boolean local,
|
||||
boolean revoked, String serviceType, String servicePublicIp, String port) {
|
||||
this(revoked, serviceType, servicePublicIp, port);
|
||||
boolean revoked, String serviceType, String servicePublicIp, String port,
|
||||
long dataCenterId) {
|
||||
this(revoked, serviceType, servicePublicIp, port, dataCenterId);
|
||||
this.gslbProviderPrivateIp = gslbProviderPrivateIp;
|
||||
this.gslbProviderPublicIp = gslbProviderPublicIP;
|
||||
this.local = local;
|
||||
|
|
@ -73,12 +79,12 @@ public class SiteLoadBalancerConfig {
|
|||
this.servicePublicIp = servicePublicIp;
|
||||
}
|
||||
|
||||
public String getPublicPort() {
|
||||
return port;
|
||||
public String getServicePort() {
|
||||
return servicePort;
|
||||
}
|
||||
|
||||
public void setPublicPort(String port) {
|
||||
this.port = port;
|
||||
public void setServicePort(String port) {
|
||||
this.servicePort = port;
|
||||
}
|
||||
|
||||
public String getGslbProviderPrivateIp() {
|
||||
|
|
@ -93,6 +99,10 @@ public class SiteLoadBalancerConfig {
|
|||
return gslbProviderPublicIp;
|
||||
}
|
||||
|
||||
public long getDataCenterId() {
|
||||
return dataCenterId;
|
||||
}
|
||||
|
||||
public void setGslbProviderPublicIp(String publicIp) {
|
||||
this.gslbProviderPublicIp = publicIp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ public interface GlobalLoadBalancingRulesService {
|
|||
boolean removeFromGlobalLoadBalancerRule(RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd);
|
||||
|
||||
|
||||
GlobalLoadBalancerRule findById(long gslbRuleId);
|
||||
|
||||
List<GlobalLoadBalancerRule> listGlobalLoadBalancerRule(ListGlobalLoadBalancerRuleCmd listGslbCmd);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
|
|||
public static final String networkSyncObject = "network";
|
||||
public static final String vpcSyncObject = "vpc";
|
||||
public static final String snapshotHostSyncObject = "snapshothost";
|
||||
public static final String gslbSyncObject = "globalserverloadbalacner";
|
||||
|
||||
private AsyncJob job;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,14 @@ package org.apache.cloudstack.api.command.user.region.ha.gslb;
|
|||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.region.ha.GlobalLoadBalancerRule;
|
||||
import com.cloud.region.ha.GlobalLoadBalancingRulesService;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import org.apache.cloudstack.api.*;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.LoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -51,7 +50,7 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.LOAD_BALANCER_RULE_LIST, type=CommandType.LIST, collectionType=CommandType.UUID,
|
||||
entityType = LoadBalancerResponse.class, required=true, description="the list load balancer rules that " +
|
||||
entityType = FirewallRuleResponse.class, required=true, description="the list load balancer rules that " +
|
||||
"will be assigned to gloabal load balacner rule")
|
||||
private List<Long> loadBalancerRulesIds;
|
||||
|
||||
|
|
@ -115,15 +114,15 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
return BaseAsyncCmd.gslbSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
LoadBalancer lb = _lbService.findById(id);
|
||||
if(lb == null){
|
||||
GlobalLoadBalancerRule gslb = _gslbService.findById(id);
|
||||
if(gslb == null){
|
||||
throw new InvalidParameterValueException("Unable to find load balancer rule: " + id);
|
||||
}
|
||||
return lb.getNetworkId();
|
||||
return gslb.getId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,14 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import com.cloud.region.ha.GlobalLoadBalancerRule;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
@EntityReference(value= GlobalLoadBalancerRule.class)
|
||||
public class GlobalLoadBalancerResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
|
|
|
|||
|
|
@ -870,14 +870,14 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
|
||||
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
|
||||
//return true if a NetScaler device is configured in the zone
|
||||
return (nsGslbProvider == null);
|
||||
return (nsGslbProvider != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getZoneGslbProviderPublicIp(long zoneId) {
|
||||
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
|
||||
if (nsGslbProvider != null) {
|
||||
nsGslbProvider.getGslbSitePublicIP();
|
||||
return nsGslbProvider.getGslbSitePublicIP();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -886,7 +886,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
public String getZoneGslbProviderPrivateIp(long zoneId) {
|
||||
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
|
||||
if (nsGslbProvider != null) {
|
||||
nsGslbProvider.getGslbSitePrivateIP();
|
||||
return nsGslbProvider.getGslbSitePrivateIP();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@
|
|||
// under the License.
|
||||
package com.cloud.network.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.citrix.netscaler.nitro.exception.nitro_exception;
|
||||
import com.citrix.netscaler.nitro.resource.base.base_response;
|
||||
import com.citrix.netscaler.nitro.resource.config.autoscale.autoscalepolicy;
|
||||
|
|
@ -48,36 +41,6 @@ import com.cloud.agent.api.routing.*;
|
|||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.*;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.ExternalNetworkResourceUsageAnswer;
|
||||
import com.cloud.agent.api.ExternalNetworkResourceUsageCommand;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.ReadyAnswer;
|
||||
import com.cloud.agent.api.ReadyCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupExternalLoadBalancerCommand;
|
||||
import com.cloud.agent.api.routing.CreateLoadBalancerApplianceCommand;
|
||||
import com.cloud.agent.api.routing.DestroyLoadBalancerApplianceCommand;
|
||||
import com.cloud.agent.api.routing.HealthCheckLBConfigAnswer;
|
||||
import com.cloud.agent.api.routing.HealthCheckLBConfigCommand;
|
||||
import com.cloud.agent.api.routing.IpAssocAnswer;
|
||||
import com.cloud.agent.api.routing.IpAssocCommand;
|
||||
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
|
||||
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
||||
import com.cloud.agent.api.to.IpAddressTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.AutoScalePolicyTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.AutoScaleVmGroupTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.AutoScaleVmProfileTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.ConditionTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.CounterTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.DestinationTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.HealthCheckPolicyTO;
|
||||
import com.cloud.agent.api.to.LoadBalancerTO.StickinessPolicyTO;
|
||||
import com.cloud.agent.api.to.StaticNatRuleTO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
|
|
@ -896,6 +859,7 @@ public class NetscalerResource implements ServerResource {
|
|||
String persistenceType = gslbCmd.getPersistenceType();
|
||||
String serviceType = gslbCmd.getServiceType();
|
||||
boolean forRevoke = gslbCmd.isForRevoke();
|
||||
long gslbId = gslbCmd.getGslbId();
|
||||
List<SiteLoadBalancerConfig> sites = gslbCmd.getSiteDetails();
|
||||
|
||||
String domainName = gslbCmd.getDomainName();
|
||||
|
|
@ -906,34 +870,35 @@ public class NetscalerResource implements ServerResource {
|
|||
if (!forRevoke) { //check if the global load balancer rule is being added
|
||||
|
||||
// Add a GSLB virtual server
|
||||
GSLB.createVirtualServer(_netscalerService, vserverName, lbMethod, persistenceType, serviceType);
|
||||
GSLB.createVirtualServer(_netscalerService, vserverName, lbMethod, persistenceType, gslbId, serviceType);
|
||||
|
||||
if (sites != null) { // check if there are any sites that are participating in global load balancing
|
||||
for (SiteLoadBalancerConfig site : sites) {
|
||||
|
||||
String sitePrivateIP = site.getGslbProviderPrivateIp();
|
||||
String sitePublicIP = site.getGslbProviderPublicIp();
|
||||
String sitePublicPort = site.getPublicPort();
|
||||
String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP);
|
||||
String servicePublicIp = site.getServicePublicIp();
|
||||
String servicePublicPort = site.getServicePort();
|
||||
String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
|
||||
|
||||
// Add/Delete GSLB local and remote sites that are part of GSLB virtual server
|
||||
if (!site.forRevoke()) {
|
||||
String siteType = (site.isLocal()) ? "LOCAL" : "REMOTE";
|
||||
if (GSLB.getSiteObject(_netscalerService, siteName) != null) {
|
||||
GSLB.updateSite(_netscalerService, siteType, siteName, site.getGslbProviderPrivateIp(),
|
||||
GSLB.updateSite(_netscalerService, siteName, siteType, site.getGslbProviderPrivateIp(),
|
||||
site.getGslbProviderPublicIp());
|
||||
} else {
|
||||
GSLB.createSite(_netscalerService, siteType, siteName, site.getGslbProviderPrivateIp(),
|
||||
GSLB.createSite(_netscalerService, siteName, siteType, site.getGslbProviderPrivateIp(),
|
||||
site.getGslbProviderPublicIp());
|
||||
}
|
||||
}
|
||||
|
||||
// Add/Delete GSLB service corresponding the service running on each site
|
||||
String serviceName = GSLB.generateUniqueServiceName(siteName, sitePublicIP, sitePublicPort);
|
||||
String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
|
||||
if (!site.forRevoke()) {
|
||||
// create a 'gslbservice' object
|
||||
GSLB.createService(_netscalerService, serviceName, site.getServiceType(),
|
||||
sitePublicIP, sitePublicPort, siteName);
|
||||
servicePublicIp, servicePublicPort, siteName);
|
||||
|
||||
// Bind 'gslbservice' service object to GSLB virtual server
|
||||
GSLB.createVserverServiceBinding(_netscalerService, serviceName, vserverName);
|
||||
|
|
@ -967,11 +932,12 @@ public class NetscalerResource implements ServerResource {
|
|||
|
||||
String sitePrivateIP = site.getGslbProviderPrivateIp();
|
||||
String sitePublicIP = site.getGslbProviderPublicIp();
|
||||
String sitePublicPort = site.getPublicPort();
|
||||
String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP);
|
||||
String servicePublicIp = site.getServicePublicIp();
|
||||
String servicePublicPort = site.getServicePort();
|
||||
String siteName = GSLB.generateUniqueSiteName(sitePrivateIP, sitePublicIP, site.getDataCenterId());
|
||||
|
||||
// remove binding between virtual server and services
|
||||
String serviceName = GSLB.generateUniqueServiceName(siteName, sitePublicIP, sitePublicPort);
|
||||
String serviceName = GSLB.generateUniqueServiceName(siteName, servicePublicIp, servicePublicPort);
|
||||
GSLB.deleteVserverServiceBinding(_netscalerService, serviceName, vserverName);
|
||||
|
||||
// delete service object
|
||||
|
|
@ -986,6 +952,9 @@ public class NetscalerResource implements ServerResource {
|
|||
// delete GSLB virtual server
|
||||
GSLB.deleteVirtualServer(_netscalerService, vserverName);
|
||||
}
|
||||
|
||||
saveConfiguration();
|
||||
|
||||
} catch (Exception e) {
|
||||
if (shouldRetry(numRetries)) {
|
||||
return retry(gslbCmd, numRetries);
|
||||
|
|
@ -1003,7 +972,7 @@ public class NetscalerResource implements ServerResource {
|
|||
|
||||
// create a 'gslbsite' object representing a site
|
||||
private static void createSite(nitro_service client, String siteName,
|
||||
String siteType, String siteIP, String sitePublicIP) {
|
||||
String siteType, String siteIP, String sitePublicIP) throws ExecutionException{
|
||||
try {
|
||||
gslbsite site;
|
||||
site = getSiteObject(client, siteName);
|
||||
|
|
@ -1032,9 +1001,11 @@ public class NetscalerResource implements ServerResource {
|
|||
s_logger.debug("Successfully created GSLB site: " + siteName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Failed to create GSLB site: " + siteName + " due to " + e.getMessage();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to create GSLB site: " + siteName + " due to " + e.getMessage());
|
||||
s_logger.debug(errMsg);
|
||||
}
|
||||
throw new ExecutionException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1094,7 +1065,8 @@ public class NetscalerResource implements ServerResource {
|
|||
|
||||
// create a 'gslbvserver' object representing a globally load balanced service
|
||||
private static void createVirtualServer(nitro_service client, String vserverName, String lbMethod,
|
||||
String persistenceType, String serviceType) {
|
||||
String persistenceType, long persistenceId, String serviceType)
|
||||
throws ExecutionException {
|
||||
try {
|
||||
gslbvserver vserver;
|
||||
vserver = getVserverObject(client, vserverName);
|
||||
|
|
@ -1109,8 +1081,16 @@ public class NetscalerResource implements ServerResource {
|
|||
vserver.set_name(vserverName);
|
||||
vserver.set_lbmethod(lbMethod);
|
||||
vserver.set_persistencetype(persistenceType);
|
||||
if ("SOURCEIP".equalsIgnoreCase(persistenceType)) {
|
||||
vserver.set_persistenceid(persistenceId);
|
||||
}
|
||||
vserver.set_servicetype(serviceType);
|
||||
vserver.set_state("ENABLED");
|
||||
if (isUpdateSite) {
|
||||
if ("roundrobin".equalsIgnoreCase(lbMethod)) {
|
||||
vserver.set_netmask(null);
|
||||
vserver.set_v6netmasklen(null);
|
||||
}
|
||||
gslbvserver.update(client, vserver);
|
||||
} else {
|
||||
gslbvserver.add(client, vserver);
|
||||
|
|
@ -1121,9 +1101,11 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Failed to add GSLB virtual server: " + vserverName + " due to " + e.getMessage();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to add GSLB virtual server: " + vserverName + " due to " + e.getMessage());
|
||||
s_logger.debug(errMsg);
|
||||
}
|
||||
throw new ExecutionException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1198,8 +1180,8 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
|
||||
// create, delete, update, get the GSLB services
|
||||
private static void createService(nitro_service client, String serviceName, String serviceType, String publicIp,
|
||||
String publicPort, String siteName) {
|
||||
private static void createService(nitro_service client, String serviceName, String serviceType, String serviceIp,
|
||||
String servicePort, String siteName) throws ExecutionException{
|
||||
try {
|
||||
gslbservice service;
|
||||
service = getServiceObject(client, serviceName);
|
||||
|
|
@ -1212,11 +1194,14 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
|
||||
service.set_sitename(siteName);
|
||||
service.set_publicip(publicIp);
|
||||
service.set_publicport(Integer.getInteger(publicPort));
|
||||
service.set_servername(serviceIp);
|
||||
int port = Integer.parseInt(servicePort);
|
||||
service.set_port(port);
|
||||
service.set_servicename(serviceName);
|
||||
service.set_servicetype(serviceType);
|
||||
if (isUpdateSite) {
|
||||
service.set_viewip(null);
|
||||
service.set_viewname(null);
|
||||
gslbservice.update(client, service);
|
||||
} else {
|
||||
gslbservice.add(client, service);
|
||||
|
|
@ -1225,9 +1210,11 @@ public class NetscalerResource implements ServerResource {
|
|||
s_logger.debug("Successfully created service: " + serviceName + " at site: " + siteName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Failed to created service: " + serviceName + " at site: " + siteName;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to created service: " + serviceName + " at site: " + siteName);
|
||||
s_logger.debug(errMsg);
|
||||
}
|
||||
throw new ExecutionException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1275,20 +1262,24 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
}
|
||||
|
||||
private static void createVserverServiceBinding(nitro_service client, String serviceName, String vserverName) {
|
||||
private static void createVserverServiceBinding(nitro_service client, String serviceName, String vserverName)
|
||||
throws ExecutionException {
|
||||
try {
|
||||
gslbvserver_gslbservice_binding binding = new gslbvserver_gslbservice_binding();
|
||||
binding.set_name(vserverName);
|
||||
binding.set_servicename(serviceName);
|
||||
gslbvserver_gslbservice_binding.add(client, binding);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Successfully created service: " + serviceName + " and virtual server: "
|
||||
+ vserverName + " binding");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errMsg = "Failed to create service: " + serviceName + " and virtual server: "
|
||||
+ vserverName + " binding due to " + e.getMessage();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to create service: " + serviceName + " and virtual server: "
|
||||
+ vserverName + " binding due to " + e.getMessage());
|
||||
s_logger.debug(errMsg);
|
||||
}
|
||||
throw new ExecutionException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1389,8 +1380,8 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
}
|
||||
|
||||
private static String generateUniqueSiteName(String sitePrivateIp, String sitePublicIP) {
|
||||
return "cloud-site-" + sitePrivateIp + "-" + sitePublicIP;
|
||||
private static String generateUniqueSiteName(String sitePrivateIp, String sitePublicIP, long dataCenterId) {
|
||||
return "cloudsite" + String.valueOf(dataCenterId);
|
||||
}
|
||||
|
||||
private static String generateVirtualServerName(String domainName) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.dao.*;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.region.ha.GlobalLoadBalancerRule;
|
||||
|
|
@ -81,6 +82,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
|
|||
AgentManager _agentMgr;
|
||||
@Inject
|
||||
protected GslbServiceProvider _gslbProvider;
|
||||
@Inject
|
||||
protected List<NetworkElement> _networkElements;
|
||||
|
||||
@Override
|
||||
@DB
|
||||
|
|
@ -486,7 +489,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
|
|||
assert(gslbRule != null);
|
||||
|
||||
String lbMethod = gslbRule.getAlgorithm();
|
||||
String persistenceMethod = gslbRule.getUuid();
|
||||
String persistenceMethod = gslbRule.getPersistence();
|
||||
String serviceType = gslbRule.getServiceType();
|
||||
|
||||
// each Gslb rule will have a FQDN, formed from the domain name associated with the gslb rule
|
||||
|
|
@ -496,7 +499,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
|
|||
String gslbFqdn = domainName + providerDnsName;
|
||||
|
||||
GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn,
|
||||
lbMethod, persistenceMethod, serviceType, revoke);
|
||||
lbMethod, persistenceMethod, serviceType, gslbRuleId, revoke);
|
||||
|
||||
// list of the zones participating in global load balancing
|
||||
List<Long> gslbSiteIds = new ArrayList<Long>();
|
||||
|
|
@ -519,7 +522,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
|
|||
|
||||
IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
|
||||
SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType,
|
||||
ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()));
|
||||
ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()),
|
||||
dataCenterId);
|
||||
|
||||
siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId));
|
||||
siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId));
|
||||
|
|
@ -560,4 +564,9 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
|
|||
|
||||
return _gslbProvider.isServiceEnabledInZone(zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalLoadBalancerRule findById(long gslbRuleId) {
|
||||
return _gslbRuleDao.findById(gslbRuleId);
|
||||
}
|
||||
}
|
||||
|
|
@ -233,6 +233,7 @@ CREATE TABLE `cloud`.`global_load_balancer_lb_rule_map` (
|
|||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`gslb_rule_id` bigint unsigned NOT NULL,
|
||||
`lb_rule_id` bigint unsigned NOT NULL,
|
||||
`revoke` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 is when rule is set for Revoke',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY (`gslb_rule_id`, `lb_rule_id`),
|
||||
CONSTRAINT `fk_gslb_rule_id` FOREIGN KEY(`gslb_rule_id`) REFERENCES `global_load_balancing_rules`(`id`) ON DELETE CASCADE,
|
||||
|
|
|
|||
Loading…
Reference in New Issue