cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: refs/heads/gslb-wip - fixing some issues found in unit testing
Date Tue, 26 Mar 2013 06:30:51 GMT
Updated Branches:
  refs/heads/gslb-wip d56ccd438 -> 83d381f25


fixing some issues found in unit testing


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/83d381f2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/83d381f2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/83d381f2

Branch: refs/heads/gslb-wip
Commit: 83d381f25ca9e718ce61c1fb2f14bba30a29859f
Parents: d56ccd4
Author: Murali Reddy <murali.reddy@citrix.com>
Authored: Tue Mar 26 12:00:13 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Tue Mar 26 12:00:13 2013 +0530

----------------------------------------------------------------------
 .../routing/GlobalLoadBalancerConfigCommand.java   |    9 ++
 .../agent/api/routing/SiteLoadBalancerConfig.java  |   28 +++--
 .../region/ha/GlobalLoadBalancingRulesService.java |    2 +
 .../org/apache/cloudstack/api/BaseAsyncCmd.java    |    1 +
 .../ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java |   13 +-
 .../api/response/GlobalLoadBalancerResponse.java   |    3 +
 .../cloud/network/element/NetscalerElement.java    |    6 +-
 .../cloud/network/resource/NetscalerResource.java  |  113 +++++++--------
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |   15 ++-
 setup/db/db/schema-410to420.sql                    |    1 +
 10 files changed, 108 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java b/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
index 4e75fba..b3603c8 100644
--- a/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
+++ b/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java b/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
index 0b998f0..cca5de8 100644
--- a/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
+++ b/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/com/cloud/region/ha/GlobalLoadBalancingRulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/region/ha/GlobalLoadBalancingRulesService.java b/api/src/com/cloud/region/ha/GlobalLoadBalancingRulesService.java
index b891c96..e2f097e 100644
--- a/api/src/com/cloud/region/ha/GlobalLoadBalancingRulesService.java
+++ b/api/src/com/cloud/region/ha/GlobalLoadBalancingRulesService.java
@@ -40,6 +40,8 @@ public interface GlobalLoadBalancingRulesService {
     boolean removeFromGlobalLoadBalancerRule(RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd);
 
 
+    GlobalLoadBalancerRule findById(long gslbRuleId);
+
     List<GlobalLoadBalancerRule> listGlobalLoadBalancerRule(ListGlobalLoadBalancerRuleCmd
listGslbCmd);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
index 97edb4c..f3b3170 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -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;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
index 15bbac9..1c07a0a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
@@ -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();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/api/src/org/apache/cloudstack/api/response/GlobalLoadBalancerResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/GlobalLoadBalancerResponse.java b/api/src/org/apache/cloudstack/api/response/GlobalLoadBalancerResponse.java
index b168ae8..0fd064f 100644
--- a/api/src/org/apache/cloudstack/api/response/GlobalLoadBalancerResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/GlobalLoadBalancerResponse.java
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index 860665a..dae13bb 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index b5ab3ce..2958cdd 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
index c70fa67..40085aa 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -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);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83d381f2/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 83fcd39..f4a40d7 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -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,


Mime
View raw message