incubator-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 - implements logic of sending global load balancer config command to all the agents that represent the GSLB service provider in the zones particiapting in global load balancing
Date Tue, 26 Feb 2013 04:58:13 GMT
Updated Branches:
  refs/heads/gslb-wip 701f4cad4 -> 70e2eeaea


implements logic of sending global load balancer config command to all
the agents that represent the GSLB service provider in the zones
particiapting in global load balancing


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

Branch: refs/heads/gslb-wip
Commit: 70e2eeaea8c2c7cab4f0da2c9348052e5f4b757c
Parents: 701f4ca
Author: Murali Reddy <murali.reddy@citrix.com>
Authored: Tue Feb 26 10:26:34 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Tue Feb 26 10:26:34 2013 +0530

----------------------------------------------------------------------
 .../routing/GlobalLoadBalancerConfigCommand.java   |   77 +---
 .../agent/api/routing/SiteLoadBalancerConfig.java  |  112 +++++
 .../cloud/region/ha/GlobalLoadBalancerRule.java    |   12 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    1 +
 .../ha/gslb/CreateGlobalLoadBalancerRuleCmd.java   |    7 +
 .../gslb/RemoveFromGlobalLoadBalancerRuleCmd.java  |    6 +-
 server/src/com/cloud/configuration/Config.java     |   14 +-
 .../region/gslb/GlobalLoadBalancerDao.java         |   28 --
 .../region/gslb/GlobalLoadBalancerDaoImpl.java     |    4 +-
 .../gslb/GlobalLoadBalancerLbRuleMapDao.java       |    4 +
 .../gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java   |    6 +
 .../region/gslb/GlobalLoadBalancerRuleDao.java     |   28 ++
 .../region/gslb/GlobalLoadBalancerRuleVO.java      |   16 +-
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |  318 +++++++++++----
 setup/db/create-schema.sql                         |    1 +
 15 files changed, 453 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/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 90d39a3..4e75fba 100644
--- a/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
+++ b/api/src/com/cloud/agent/api/routing/GlobalLoadBalancerConfigCommand.java
@@ -19,6 +19,8 @@ package com.cloud.agent.api.routing;
 
 import com.cloud.agent.api.Command;
 
+import java.util.List;
+
 /**
  * GlobalLoadBalancerConfigCommand used for sending the GSLB configuration to GSLB service provider
  */
@@ -40,10 +42,9 @@ public class GlobalLoadBalancerConfigCommand extends Command {
     boolean revoked;
 
     // list of the site details that are participating in the GSLB service
-    SiteLoadBalancer[] siteLoadBalancers;
+    List<SiteLoadBalancerConfig> siteLoadBalancers;
 
-    public  void GlobalLoadBalancerConfigCommand(SiteLoadBalancer[] slbs,
-                                                 String domainName,
+    public GlobalLoadBalancerConfigCommand(String domainName,
                                                  String lbMethod,
                                                  String persistenceType,
                                                  String serviceType,
@@ -53,13 +54,16 @@ public class GlobalLoadBalancerConfigCommand extends Command {
         this.lbMethod = lbMethod;
         this.persistenceType = persistenceType;
         this.revoked = revoked;
-        this.siteLoadBalancers = slbs;
     }
 
-    public SiteLoadBalancer[] getSiteDetails() {
+    public List<SiteLoadBalancerConfig> getSiteDetails() {
         return siteLoadBalancers;
     }
 
+    public void setSiteLoadBalancers(List<SiteLoadBalancerConfig> siteLoadBalancers) {
+        this.siteLoadBalancers = siteLoadBalancers;
+    }
+
     public String getServiceType() {
         return serviceType;
     }
@@ -84,67 +88,4 @@ public class GlobalLoadBalancerConfigCommand extends Command {
     public boolean executeInSequence() {
         return false;
     }
-
-    // details of site participating in the GLSB service
-    public class SiteLoadBalancer {
-        // true if the site is local (GSLB provider receiving GlobalLoadBalancerConfigCommand is in same site)
-        boolean local;
-
-        // true if the sire needs to be removed from GSLB service
-        boolean revoked;
-
-        // service type of the 'site load balanced' service
-        String serviceType;
-
-        // public IP corresponding to the site load balanced service
-        String servicePublicIp;
-
-        // port corresponding to the site load balanced service
-        String port;
-
-        // IP corresponding to the GSLB service provider in the site.
-        String gslbProviderIp;
-
-        // Public IP corresponding to the GSLB service provider in the site.
-        String gslbProviderPublicIp;
-
-        public void SiteLoadBalancer(String gslbProviderIp, String gslbProviderPublicIP, boolean local, boolean revoked,
-                                     String serviceType, String servicePublicIp, String port) {
-            this.gslbProviderIp = gslbProviderIp;
-            this.gslbProviderPublicIp = gslbProviderPublicIP;
-            this.local = local;
-            this.revoked = revoked;
-            this.serviceType = serviceType;
-            this.servicePublicIp = servicePublicIp;
-            this.port = port;
-        }
-
-        public String getServiceType() {
-            return  serviceType;
-        }
-
-        public String getServicePublicIp() {
-            return servicePublicIp;
-        }
-
-        public String getPublicPort() {
-            return port;
-        }
-
-        public String getGslbProviderPrivateIp() {
-            return gslbProviderIp;
-        }
-
-        public String getGslbProviderPublicIp() {
-            return gslbProviderPublicIp;
-        }
-
-        public boolean isLocal() {
-            return local;
-        }
-
-        public boolean forRevoke() {
-            return revoked;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/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
new file mode 100644
index 0000000..a1ee8f6
--- /dev/null
+++ b/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api.routing;
+
+// details of site participating in the GLSB service
+public class SiteLoadBalancerConfig {
+// true if the site is local (GSLB provider receiving GlobalLoadBalancerConfigCommand is in same site)
+    boolean local;
+
+    // true if the site needs to be removed from GSLB service
+    boolean revoked;
+
+    // service type of the 'site load balanced' service
+    String serviceType;
+
+    // public IP corresponding to the site load balanced service
+    String servicePublicIp;
+
+    // port corresponding to the site load balanced service
+    String port;
+
+    // IP corresponding to the GSLB service provider in the site.
+    String gslbProviderIp;
+
+    // Public IP corresponding to the GSLB service provider in the site.
+    String gslbProviderPublicIp;
+
+    public SiteLoadBalancerConfig(boolean revoked, String serviceType, String servicePublicIp, String port) {
+        this.revoked = revoked;
+        this.serviceType = serviceType;
+        this.servicePublicIp = servicePublicIp;
+        this.port = port;
+    }
+
+    public SiteLoadBalancerConfig(String gslbProviderIp, String gslbProviderPublicIP, boolean local, boolean revoked,
+                                 String serviceType, String servicePublicIp, String port) {
+        this.gslbProviderIp = gslbProviderIp;
+        this.gslbProviderPublicIp = gslbProviderPublicIP;
+        this.local = local;
+        this.revoked = revoked;
+        this.serviceType = serviceType;
+        this.servicePublicIp = servicePublicIp;
+        this.port = port;
+    }
+
+    public String getServiceType() {
+        return  serviceType;
+    }
+
+    public void setServiceType(String serviceType) {
+        this.serviceType = serviceType;
+    }
+
+    public String getServicePublicIp() {
+        return servicePublicIp;
+    }
+
+    public void SetServicePublicIp(String servicePublicIp) {
+        this.servicePublicIp = servicePublicIp;
+    }
+
+    public String getPublicPort() {
+        return port;
+    }
+
+    public void setPublicPort(String port) {
+        this.port = port;
+    }
+
+    public String getGslbProviderPrivateIp() {
+        return gslbProviderIp;
+    }
+
+    public void setGslbProviderPrivateIp(String privateIp) {
+        this.gslbProviderIp = privateIp;
+    }
+
+    public String getGslbProviderPublicIp() {
+        return gslbProviderPublicIp;
+    }
+
+    public void setGslbProviderPublicIp(String publicIp) {
+        this.gslbProviderPublicIp = publicIp;
+    }
+
+    public boolean isLocal() {
+        return local;
+    }
+
+    public void setLocal(boolean local) {
+        this.local = local;
+    }
+
+    public boolean forRevoke() {
+        return revoked;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/api/src/com/cloud/region/ha/GlobalLoadBalancerRule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/region/ha/GlobalLoadBalancerRule.java b/api/src/com/cloud/region/ha/GlobalLoadBalancerRule.java
index 2705664..597304f 100644
--- a/api/src/com/cloud/region/ha/GlobalLoadBalancerRule.java
+++ b/api/src/com/cloud/region/ha/GlobalLoadBalancerRule.java
@@ -52,6 +52,16 @@ public interface GlobalLoadBalancerRule extends Identity, InternalIdentity, Cont
         }
     }
 
+    enum ServiceType {
+        tcp,
+        udp;
+        public static  boolean isValidServiceType(String serviceType) {
+            if (tcp.name().equalsIgnoreCase(serviceType) || udp.name().equalsIgnoreCase(serviceType)) {
+                return true;
+            }
+            return false;
+        }
+    }
     enum State {
         Staged,
         Add,
@@ -74,4 +84,6 @@ public interface GlobalLoadBalancerRule extends Identity, InternalIdentity, Cont
     public long getAccountId();
 
     public State getState();
+
+    public String getServiceType();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 720a131..7e44f27 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -79,6 +79,7 @@ public class ApiConstants {
     public static final String GROUP_ID = "groupid";
     public static final String GSLB_LB_METHOD = "gslblbmethod";
     public static final String GSLB_SERVICE_DOMAIN_NAME = "gslbdomainname";
+    public static final String GSLB_SERVICE_TYPE = "gslbservicetype";
     public static final String GSLB_STICKY_SESSION_METHOD = "gslbstickysessionmethodname";
     public static final String GUEST_CIDR_ADDRESS = "guestcidraddress";
     public static final String HA_ENABLE = "haenable";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
index c0f5c84..d0f8935 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
@@ -69,6 +69,9 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
     @Parameter(name=ApiConstants.GSLB_SERVICE_DOMAIN_NAME, type = CommandType.STRING, required = true, description = "domain name for the GSLB service.")
     private String serviceDomainName;
 
+    @Parameter(name=ApiConstants.GSLB_SERVICE_TYPE, type = CommandType.STRING, required = true, description = "GSLB service type (tcp, udp)")
+    private String serviceType;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -101,6 +104,10 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
         return regionId;
     }
 
+    public String getServiceType() {
+        return serviceType;
+    }
+
     @Inject
     private GlobalLoadBalancingRulesService _gslbService;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java
index 0cd9737..ce2d81d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java
@@ -58,7 +58,7 @@ public class RemoveFromGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
 
-    public Long getGlobalLoadBalancerId() {
+    public Long getGlobalLoadBalancerRuleId() {
         return id;
     }
 
@@ -80,7 +80,7 @@ public class RemoveFromGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
 
     @Override
     public long getEntityOwnerId() {
-        GlobalLoadBalancerRule globalLoadBalancerRule = _entityMgr.findById(GlobalLoadBalancerRule.class, getGlobalLoadBalancerId());
+        GlobalLoadBalancerRule globalLoadBalancerRule = _entityMgr.findById(GlobalLoadBalancerRule.class, getGlobalLoadBalancerRuleId());
         if (globalLoadBalancerRule == null) {
             return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
         }
@@ -95,7 +95,7 @@ public class RemoveFromGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
     @Override
     public String getEventDescription() {
         return  "removing load balancer rules:" + StringUtils.join(getLoadBalancerRulesId(), ",") +
-                " from global load balancer: " + getGlobalLoadBalancerId();
+                " from global load balancer: " + getGlobalLoadBalancerRuleId();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 5e4996b..1b59ad5 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -16,10 +16,6 @@
 // under the License.
 package com.cloud.configuration;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
 import com.cloud.agent.AgentManager;
 import com.cloud.consoleproxy.ConsoleProxyManager;
 import com.cloud.ha.HighAvailabilityManager;
@@ -34,6 +30,10 @@ import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.template.TemplateManager;
 import com.cloud.vm.UserVmManager;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
 public enum Config {
 
 	// Alert
@@ -358,13 +358,15 @@ public enum Config {
     DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null),
 
 	ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost",
-	                null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
+	                null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
 	
 	ExternalBaremetalSystemUrl("Advanced", ManagementServer.class, String.class, "external.baremetal.system.url", null, "url of external baremetal system that CloudStack will talk to", null),
 	ExternalBaremetalResourceClassName("Advanced", ManagementServer.class, String.class, "external,baremetal.resource.classname", null, "class name for handling external baremetal resource", null),
 	EnableBaremetalSecurityGroupAgentEcho("Advanced", ManagementServer.class, Boolean.class, "enable.baremetal.securitygroup.agent.echo", "false", "After starting provision process, periodcially echo security agent installed in the template. Treat provisioning as success only if echo successfully", null),
 	IntervalToEchoBaremetalSecurityGroupAgent("Advanced", ManagementServer.class, Integer.class, "interval.baremetal.securitygroup.agent.echo", "10", "Interval to echo baremetal security group agent, in seconds", null),
-	TimeoutToEchoBaremetalSecurityGroupAgent("Advanced", ManagementServer.class, Integer.class, "timeout.baremetal.securitygroup.agent.echo", "3600", "Timeout to echo baremetal security group agent, in seconds, the provisioning process will be treated as a failure", null);
+	TimeoutToEchoBaremetalSecurityGroupAgent("Advanced", ManagementServer.class, Integer.class, "timeout.baremetal.securitygroup.agent.echo", "3600", "Timeout to echo baremetal security group agent, in seconds, the provisioning process will be treated as a failure", null),
+
+    CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", "default", " DNS name of the cloud", null);
 
 	private final String _category;
 	private final Class<?> _componentClass;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDao.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDao.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDao.java
deleted file mode 100644
index c87665e..0000000
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDao.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.cloudstack.region.gslb;
-
-import com.cloud.utils.db.GenericDao;
-
-import java.util.List;
-
-public interface GlobalLoadBalancerDao extends GenericDao<GlobalLoadBalancerRuleVO, Long> {
-
-    List<GlobalLoadBalancerRuleVO> listByRegionId(long regionId);
-    List<GlobalLoadBalancerRuleVO> listByDomainName(String domainName);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java
index 4021fc0..99f0df0 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java
@@ -26,8 +26,8 @@ import javax.ejb.Local;
 import java.util.List;
 
 @Component
-@Local(value={GlobalLoadBalancerDao.class})
-public class GlobalLoadBalancerDaoImpl extends GenericDaoBase<GlobalLoadBalancerRuleVO, Long> implements GlobalLoadBalancerDao {
+@Local(value={GlobalLoadBalancerRuleDao.class})
+public class GlobalLoadBalancerDaoImpl extends GenericDaoBase<GlobalLoadBalancerRuleVO, Long> implements GlobalLoadBalancerRuleDao {
 
     private final SearchBuilder<GlobalLoadBalancerRuleVO> listByDomainSearch;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java
index 8f8f7bb..5ce0b40 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java
@@ -22,5 +22,9 @@ import com.cloud.utils.db.GenericDao;
 import java.util.List;
 
 public interface GlobalLoadBalancerLbRuleMapDao extends GenericDao<GlobalLoadBalancerLbRuleMapVO, Long> {
+
     List<GlobalLoadBalancerLbRuleMapVO> listByGslbRuleId(long gslbRuleId);
+
+    GlobalLoadBalancerLbRuleMapVO findByGslbRuleIdAndLbRuleId(long gslbRuleId, long lbRuleId);
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java
index eb62253..c0bdd1d 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java
@@ -45,4 +45,10 @@ public class GlobalLoadBalancerLbRuleMapDaoImpl extends GenericDaoBase<GlobalLoa
         sc.setParameters("gslbLoadBalancerId", gslbRuleId);
         return listBy(sc);
     }
+
+    @Override
+    public GlobalLoadBalancerLbRuleMapVO findByGslbRuleIdAndLbRuleId(long gslbRuleId, long lbRuleId) {
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleDao.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleDao.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleDao.java
new file mode 100644
index 0000000..ca970a3
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleDao.java
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.region.gslb;
+
+import com.cloud.utils.db.GenericDao;
+
+import java.util.List;
+
+public interface GlobalLoadBalancerRuleDao extends GenericDao<GlobalLoadBalancerRuleVO, Long> {
+
+    List<GlobalLoadBalancerRuleVO> listByRegionId(long regionId);
+    List<GlobalLoadBalancerRuleVO> listByDomainName(String domainName);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
index 1f6bd8a..a70b305 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
@@ -46,6 +46,9 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
     @Column(name="gslb_domain_name")
     private String gslbDomain;
 
+    @Column(name="service_type")
+    private String serviceType;
+
     @Column(name="region_id")
     private int region;
 
@@ -67,7 +70,8 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
     }
 
     public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm,
-                                    String persistence, int regionId, long accountId, long domainId, State state) {
+                                    String persistence, String serviceType, int regionId, long accountId,
+                                    long domainId, State state) {
         this.name =name;
         this.description = description;
         this.region = regionId;
@@ -76,6 +80,7 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
         this.persistence = persistence;
         this.accountId = accountId;
         this.domainId = domainId;
+        this.serviceType = serviceType;
         this.uuid = UUID.randomUUID().toString();
         this.state = state;
     }
@@ -158,6 +163,15 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
         this.uuid = uuid;
     }
 
+    @Override
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    public void setServiceType(String serviceType) {
+        this.serviceType = serviceType;
+    }
+
     public void setState(GlobalLoadBalancerRule.State state) {
         this.state = state;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/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 8d5d374..104de5d 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -17,14 +17,17 @@
 
 package org.apache.cloudstack.region.gslb;
 
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand;
+import com.cloud.agent.api.routing.SiteLoadBalancerConfig;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.network.Network;
-import com.cloud.network.dao.LoadBalancerDao;
-import com.cloud.network.dao.LoadBalancerVO;
-import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.*;
 import com.cloud.network.rules.LoadBalancer;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.region.ha.GlobalLoadBalancerRule;
@@ -39,22 +42,27 @@ import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.*;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.region.dao.RegionDao;
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
 import java.security.spec.InvalidParameterSpecException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Component
 @Local(value = {GlobalLoadBalancingRulesService.class})
 public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingRulesService {
 
+    private static final Logger s_logger = Logger.getLogger(GlobalLoadBalancingRulesServiceImpl.class);
+
     @Inject
     AccountManager _accountMgr;
     @Inject
-    GlobalLoadBalancerDao _globalLoadBalancerDao;
+    GlobalLoadBalancerRuleDao _gslbRuleDao;
     @Inject
     GlobalLoadBalancerLbRuleMapDao _gslbLbMapDao;
     @Inject
@@ -65,6 +73,12 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
     LoadBalancerDao _lbDao;
     @Inject
     NetworkDao _networkDao;
+    @Inject
+    ConfigurationDao _globalConfigDao;
+    @Inject
+    IPAddressDao _ipAddressDao;
+    @Inject
+    AgentManager _agentMgr;
 
     @Override
     @DB
@@ -78,6 +92,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         String name = newGslb.getName();
         String description = newGslb.getDescription();
         String domainName = newGslb.getServiceDomainName();
+        String serviceType = newGslb.getServiceType();
 
         Account gslbOwner = _accountMgr.getAccount(newGslb.getEntityOwnerId());
 
@@ -89,7 +104,11 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             throw new InvalidParameterSpecException("Invalid persistence: " + stickyMethod);
         }
 
-        List<GlobalLoadBalancerRuleVO> gslbRules = _globalLoadBalancerDao.listByDomainName(domainName);
+        if (!GlobalLoadBalancerRule.ServiceType.isValidServiceType(serviceType)) {
+            throw new InvalidParameterSpecException("Invalid service type: " + serviceType);
+        }
+
+        List<GlobalLoadBalancerRuleVO> gslbRules = _gslbRuleDao.listByDomainName(domainName);
         if (gslbRules != null && !gslbRules.isEmpty()) {
             throw new InvalidParameterSpecException("There exist a GSLB rule with that conflicts with domain name : "
                     + domainName + " provided");
@@ -101,7 +120,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
 
         Region region = _regionDao.findById(regionId);
         if (region == null) {
-            throw new InvalidParameterSpecException("Invalid region ID: " + region.getName());
+            throw new InvalidParameterSpecException("Invalid region ID: " + regionId);
         }
 
         if (!region.checkIfServiceEnabled(Region.Service.Gslb)) {
@@ -111,9 +130,12 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         Transaction txn = Transaction.currentTxn();
         txn.start();
         GlobalLoadBalancerRuleVO newGslbRule = new GlobalLoadBalancerRuleVO(name, description, domainName, algorithm,
-                stickyMethod, regionId, gslbOwner.getId(), gslbOwner.getDomainId(), GlobalLoadBalancerRule.State.Staged);
-        _globalLoadBalancerDao.persist(newGslbRule);
+                stickyMethod, serviceType, regionId, gslbOwner.getId(), gslbOwner.getDomainId(),
+                GlobalLoadBalancerRule.State.Staged);
+        _gslbRuleDao.persist(newGslbRule);
         txn.commit();
+
+        s_logger.debug("successfully create new global load balancer rule for the account " + gslbOwner.getId());
         return newGslbRule;
     }
 
@@ -125,98 +147,208 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
 
         UserContext ctx = UserContext.current();
         Account caller = ctx.getCaller();
-        long gslbRuleId =  assignToGslbCmd.getGlobalLoadBalancerRuleId();
-        List<Long> lbRuleIds = assignToGslbCmd.getLoadBalancerRulesIds();
 
-        GlobalLoadBalancerRuleVO gslbRule = _globalLoadBalancerDao.findById(gslbRuleId);
+        long gslbRuleId =  assignToGslbCmd.getGlobalLoadBalancerRuleId();
+        GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
         if (gslbRule == null) {
-            throw new InvalidParameterValueException("Invalid GSLB rule id: " + gslbRuleId);
+            throw new InvalidParameterValueException("Invalid global load balancer rule id: " + gslbRuleId);
         }
 
         _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
 
         if (gslbRule.getState() == GlobalLoadBalancerRule.State.Revoke) {
-            throw new InvalidParameterValueException("GSLB rule id: " + gslbRuleId + " is in revoked state");
+            throw new InvalidParameterValueException("global load balancer rule id: " + gslbRuleId + " is in revoked state");
         }
 
-        /* check each of the load balance rule id is
-         * valid ID
-         * caller has access to the rule
-         * check rule is not revoked
-         * no two rules are in same zone
-         */
-        if (lbRuleIds != null) {
-            List<Long> zones = new ArrayList<Long>();
-            for (Long lbRuleId : lbRuleIds) {
-                LoadBalancerVO loadBalancer = _lbDao.findById(lbRuleId);
-                if (loadBalancer == null) {
-                    throw new InvalidParameterValueException("Invalid load balancer ID " + lbRuleId);
-                }
-
-                _accountMgr.checkAccess(caller, null, true, loadBalancer);
-
-                if (loadBalancer.getState() == LoadBalancer.State.Revoke) {
-                    throw new InvalidParameterValueException("Load balancer ID " + lbRuleId + " is in revoke state");
-                }
+        List<Long> newLbRuleIds = assignToGslbCmd.getLoadBalancerRulesIds();
+        if (newLbRuleIds == null || newLbRuleIds.isEmpty()) {
+            throw new InvalidParameterValueException("empty list of load balancer rule Ids specified to be assigned"
+            + " global load balancer rule");
+        }
+
+        // get the active list of LB rules id's that are assigned currently to GSLB rule and corresponding zones
+        List<Long> oldLbRuleIds = new ArrayList<Long>();
+        List<Long> oldZones = new ArrayList<Long>();
+        List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+        if (gslbLbMapVos != null) {
+            for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+                LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
                 Network network = _networkDao.findById(loadBalancer.getNetworkId());
-                if (zones.contains(network.getDataCenterId())) {
-                    throw new InvalidParameterValueException("Each load balancer rule specified should be in unique zone");
-                }
-                zones.add(network.getDataCenterId());
+                oldZones.add(network.getDataCenterId());
+                oldLbRuleIds.add(gslbLbMapVo.getLoadBalancerId());
             }
         }
 
+        List<Long> newZones = new ArrayList<Long>(oldZones);
+        /* check each of the load balancer rule id is
+         *     valid ID
+         *     caller has access to the rule
+         *     check rule is not revoked
+         *     no two rules are in same zone
+         *     rule is already assigned to gslb rule
+         */
+        for (Long lbRuleId : newLbRuleIds) {
+            LoadBalancerVO loadBalancer = _lbDao.findById(lbRuleId);
+            if (loadBalancer == null) {
+                throw new InvalidParameterValueException("Specified load balancer rule ID does not exist.");
+            }
+
+            _accountMgr.checkAccess(caller, null, true, loadBalancer);
+
+            if (loadBalancer.getState() == LoadBalancer.State.Revoke) {
+                throw new InvalidParameterValueException("Load balancer ID " + loadBalancer.getUuid()  + " is in revoke state");
+            }
+
+            if (oldLbRuleIds != null && oldLbRuleIds.contains(loadBalancer.getId())) {
+                throw new InvalidParameterValueException("Load balancer ID " + loadBalancer.getUuid() + " is already assigned");
+            }
+
+            Network network = _networkDao.findById(loadBalancer.getNetworkId());
+            if (oldZones.contains(network.getDataCenterId())) {
+                throw new InvalidParameterValueException("Each load balancer rule specified should be in unique zone");
+            }
+            newZones.add(network.getDataCenterId());
+        }
+
         Transaction txn = Transaction.currentTxn();
         txn.start();
 
-        // get the persisted list of LB rules that are assigned to GSLB rule
-        List<GlobalLoadBalancerLbRuleMapVO> gslbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+        // persist the mapping for the new Lb rule that needs to assigned to a gslb rule
+        for (Long lbRuleId : newLbRuleIds) {
+            GlobalLoadBalancerLbRuleMapVO newGslbLbMap = new GlobalLoadBalancerLbRuleMapVO();
+            newGslbLbMap.setGslbLoadBalancerId(gslbRuleId);
+            newGslbLbMap.setLoadBalancerId(lbRuleId);
+            _gslbLbMapDao.persist(newGslbLbMap);
+        }
 
-        // compare intended list of lb rules with earlier assigned lb rules, to figure mapping that needs to go
-        if (gslbMapVos != null) {
-            for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbMapVos) {
-                if (lbRuleIds == null || !lbRuleIds.contains(gslbLbMapVo.getLoadBalancerId())) {
-                    _gslbLbMapDao.remove(gslbLbMapVo.getId());
-                }
-            }
+        // mark the gslb rule state as add
+        if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged) {
+            gslbRule.setState(GlobalLoadBalancerRule.State.Add);
+            _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+        }
+
+        txn.commit();
+
+        s_logger.debug("Updated the global load balancer rule: " + gslbRuleId + " in database");
+
+        try {
+            s_logger.debug("Attempting to configure global load balancer rule configuration on the gslb service providers ");
+            // apply the gslb rule on to the back end gslb service providers
+            applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+
+            // on success set state to Active
+            gslbRule.setState(GlobalLoadBalancerRule.State.Active);
+            _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+            return true;
+        } catch (Exception e) {
+
+        }
+
+        return false;
+    }
+
+    @Override
+    @DB
+    @ActionEvent(eventType = EventTypes.EVENT_REMOVE_FROM_GLOBAL_LOAD_BALANCER_RULE, eventDescription =
+            "Removing a load balancer rule to be part of global load balancer rule")
+    public boolean removeFromGlobalLoadBalancerRule(RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd) {
+
+        UserContext ctx = UserContext.current();
+        Account caller = ctx.getCaller();
+
+        long gslbRuleId =  removeFromGslbCmd.getGlobalLoadBalancerRuleId();
+        GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+        if (gslbRule == null) {
+            throw new InvalidParameterValueException("Invalid global load balancer rule id: " + gslbRuleId);
         }
 
-        // persist the mapping of new Lb rule that needs to assigned to a gslb rule
-        if (lbRuleIds != null) {
-            for (Long lbRuleId : lbRuleIds) {
-                boolean  mappingExists = false;
-                for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbMapVos) {
-                    if (gslbLbMapVo.getGslbLoadBalancerId() == lbRuleId) {
-                        mappingExists = true;
-                        break;
-                    }
-                }
-                if (!mappingExists) {
-                    GlobalLoadBalancerLbRuleMapVO newGslbLbMap = new GlobalLoadBalancerLbRuleMapVO();
-                    newGslbLbMap.setGslbLoadBalancerId(gslbRuleId);
-                    newGslbLbMap.setLoadBalancerId(lbRuleId);
-                    _gslbLbMapDao.persist(newGslbLbMap);
-                }
+        _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
+
+        if (gslbRule.getState() == GlobalLoadBalancerRule.State.Revoke) {
+            throw new InvalidParameterValueException("global load balancer rule id: " + gslbRuleId + " is already in revoked state");
+        }
+
+        List<Long> lbRuleIdsToremove = removeFromGslbCmd.getLoadBalancerRulesId();
+        if (lbRuleIdsToremove == null || lbRuleIdsToremove.isEmpty()) {
+            throw new InvalidParameterValueException("empty list of load balancer rule Ids specified to be un-assigned"
+                    + " to global load balancer rule");
+        }
+
+        // get the active list of LB rules id's that are assigned currently to GSLB rule and corresponding zones
+        List<Long> oldLbRuleIds = new ArrayList<Long>();
+        List<Long> oldZones = new ArrayList<Long>();
+        List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+        if (gslbLbMapVos == null) {
+            throw new InvalidParameterValueException(" There are no load balancer rules that are assigned to global " +
+                    " load balancer rule id: " + gslbRule.getUuid() + " that are available for deletion");
+        }
+
+        for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+            LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
+            Network network = _networkDao.findById(loadBalancer.getNetworkId());
+            oldZones.add(network.getDataCenterId());
+            oldLbRuleIds.add(gslbLbMapVo.getLoadBalancerId());
+        }
+
+        for (Long lbRuleId : lbRuleIdsToremove) {
+            LoadBalancerVO loadBalancer = _lbDao.findById(lbRuleId);
+            if (loadBalancer == null) {
+                throw new InvalidParameterValueException("Specified load balancer rule ID does not exist.");
+            }
+
+            _accountMgr.checkAccess(caller, null, true, loadBalancer);
+
+            if (loadBalancer.getState() == LoadBalancer.State.Revoke) {
+                throw new InvalidParameterValueException("Load balancer ID " + loadBalancer.getUuid()  + " is in revoke state");
             }
+
+            if (oldLbRuleIds != null && !oldLbRuleIds.contains(loadBalancer.getId())) {
+                throw new InvalidParameterValueException("Load balancer ID " + loadBalancer.getUuid() + " is not assigned"
+                        + " to global load balancer rule: " + gslbRule.getUuid());
+            }
+        }
+
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+
+        // update the mapping of  gslb rule to Lb rule, to revoke state
+        for (Long lbRuleId : lbRuleIdsToremove) {
+            GlobalLoadBalancerLbRuleMapVO removeGslbLbMap = _gslbLbMapDao.findByGslbRuleIdAndLbRuleId(gslbRuleId, lbRuleId);
+            removeGslbLbMap.setRevoke(true);
+            _gslbLbMapDao.update(removeGslbLbMap.getId(), removeGslbLbMap);
         }
 
-        // mark the rule state as add
+        // mark the gslb rule state as add
         if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged) {
-            gslbRule.setState(GlobalLoadBalancerRule.State.Add);
-            _globalLoadBalancerDao.update(gslbRule.getId(), gslbRule);
+            gslbRule.setState(GlobalLoadBalancerRule.State.Active);
+            _gslbRuleDao.update(gslbRule.getId(), gslbRule);
         }
 
         txn.commit();
 
-        // apply rules on each of the GSLB providers at each site participating in the global load balancing rule
+        s_logger.debug("Updated the global load balancer rule: " + gslbRuleId + " in database");
+
+        try {
+            s_logger.debug("Attempting to configure global load balancer rule configuration on the gslb service providers ");
+
+            // apply the gslb rule on to the back end gslb service providers
+            applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+
+            // on success set state to Active
+            gslbRule.setState(GlobalLoadBalancerRule.State.Add);
+            _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+
+            return true;
+        } catch (Exception e) {
 
-        // on success set state to Active
+        }
 
         return false;
     }
 
     @Override
     public boolean deleteGlobalLoadBalancerRule(DeleteGlobalLoadBalancerRuleCmd deleteGslbCmd) {
+
         return false;
     }
 
@@ -230,16 +362,56 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         return null;
     }
 
-    @Override
-    public boolean removeFromGlobalLoadBalancerRule(RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd) {
-        return false;
-    }
+    private void applyGlobalLoadBalancerRuleConfig(long gslbRuleId, boolean revoke) {
 
-    private void deployGlobalLoadBalancerRule(GlobalLoadBalancerConfigCommand cmd) {
+        GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
 
-    }
+        String domainName = gslbRule.getGslbDomain();
+        String lbMethod = gslbRule.getAlgorithm();
+        String persistenceMethod = gslbRule.getUuid();
+        String serviceType = gslbRule.getServiceType();
+
+        String providerDnsName = _globalConfigDao.getValue(Config.CloudDnsName.name());
+        String gslbFqdn = domainName + providerDnsName;
+
+        GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn,
+                lbMethod, persistenceMethod, serviceType, revoke);
+
+        List<Long> gslbSiteIds = new ArrayList<Long>();
+
+        Map<Long, SiteLoadBalancerConfig> zoneSiteLoadbalancerMap = new HashMap<Long, SiteLoadBalancerConfig>();
 
-    private void configureZoneGslbProvider(long zoneId, GlobalLoadBalancerConfigCommand cmd) {
+        List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+        for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+            LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
+            Network network = _networkDao.findById(loadBalancer.getNetworkId());
 
+            gslbSiteIds.add(network.getDataCenterId());
+
+            IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
+            SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType,
+                    ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()));
+
+            zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
+        }
+
+        for (long zoneId: gslbSiteIds) {
+
+            List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
+
+            for (long innerLoopZoneId: gslbSiteIds) {
+                SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId);
+                siteLb.setLocal(zoneId == innerLoopZoneId);
+                slbs.add(siteLb);
+            }
+
+            long zoneGslbProviderHosId = 0;
+
+            gslbConfigCmd.setSiteLoadBalancers(slbs);
+            Answer answer = _agentMgr.easySend(zoneGslbProviderHosId, gslbConfigCmd);
+            if (answer == null) {
+
+            }
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/70e2eeae/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 1b792c9..09fc2f8 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -2665,6 +2665,7 @@ CREATE TABLE `cloud`.`global_load_balancing_rules` (
   `algorithm` varchar(255) NOT NULL COMMENT 'load balancing algorithm used to distribbute traffic across zones',
   `persistence` varchar(255) NOT NULL COMMENT 'session persistence used across the zone',
   `gslb_domain_name` varchar(255) NOT NULL COMMENT 'DNS name for the GSLB service that is used to provide a FQDN for the GSLB service',
+  `service_type` varchar(255) NOT NULL COMMENT 'type of the GSLB service',
   PRIMARY KEY  (`id`),
   CONSTRAINT `fk_global_load_balancing_rules_account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_global_load_balancing_rules_region_id` FOREIGN KEY(`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE


Mime
View raw message