You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/03/29 19:20:28 UTC
[12/50] [abbrv] CLOUDSTACK-653 : High Availability: implement GSLB
(Global Server Load Balancing) capability for ELB service
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index efdee20..f80e0c2 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -16,105 +16,6 @@
// under the License.
package com.cloud.server;
-import java.lang.reflect.Field;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.UUID;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.PostConstruct;
-import javax.crypto.Mac;
-import javax.crypto.spec.SecretKeySpec;
-import javax.inject.Inject;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
-import org.apache.cloudstack.api.ApiConstants;
-
-import com.cloud.event.ActionEventUtils;
-import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
-
-import org.apache.cloudstack.api.command.admin.account.*;
-import org.apache.cloudstack.api.command.admin.autoscale.*;
-import org.apache.cloudstack.api.command.admin.cluster.*;
-import org.apache.cloudstack.api.command.admin.config.*;
-import org.apache.cloudstack.api.command.admin.domain.*;
-import org.apache.cloudstack.api.command.admin.host.*;
-import org.apache.cloudstack.api.command.admin.ldap.*;
-import org.apache.cloudstack.api.command.admin.network.*;
-import org.apache.cloudstack.api.command.admin.offering.*;
-import org.apache.cloudstack.api.command.admin.pod.*;
-import org.apache.cloudstack.api.command.admin.region.*;
-import org.apache.cloudstack.api.command.admin.resource.*;
-import org.apache.cloudstack.api.command.admin.router.*;
-import org.apache.cloudstack.api.command.admin.storage.*;
-import org.apache.cloudstack.api.command.admin.swift.*;
-import org.apache.cloudstack.api.command.admin.systemvm.*;
-import org.apache.cloudstack.api.command.admin.template.*;
-import org.apache.cloudstack.api.command.admin.usage.*;
-import org.apache.cloudstack.api.command.admin.user.*;
-import org.apache.cloudstack.api.command.admin.vlan.*;
-import org.apache.cloudstack.api.command.admin.vm.*;
-import org.apache.cloudstack.api.command.admin.vpc.*;
-import org.apache.cloudstack.api.command.admin.zone.*;
-import org.apache.cloudstack.api.command.user.account.*;
-import org.apache.cloudstack.api.command.user.address.*;
-import org.apache.cloudstack.api.command.user.autoscale.*;
-import org.apache.cloudstack.api.command.user.config.*;
-import org.apache.cloudstack.api.command.user.event.*;
-import org.apache.cloudstack.api.command.user.firewall.*;
-import org.apache.cloudstack.api.command.user.guest.*;
-import org.apache.cloudstack.api.command.user.iso.*;
-import org.apache.cloudstack.api.command.user.job.*;
-import org.apache.cloudstack.api.command.user.loadbalancer.*;
-import org.apache.cloudstack.api.command.user.nat.*;
-import org.apache.cloudstack.api.command.user.network.*;
-import org.apache.cloudstack.api.command.user.offering.*;
-import org.apache.cloudstack.api.command.user.project.*;
-import org.apache.cloudstack.api.command.user.region.*;
-import org.apache.cloudstack.api.command.user.resource.*;
-import org.apache.cloudstack.api.command.user.securitygroup.*;
-import org.apache.cloudstack.api.command.user.snapshot.*;
-import org.apache.cloudstack.api.command.user.ssh.*;
-import org.apache.cloudstack.api.command.user.tag.*;
-import org.apache.cloudstack.api.command.user.template.*;
-import org.apache.cloudstack.api.command.user.vm.*;
-import org.apache.cloudstack.api.command.user.vmgroup.*;
-import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd;
-import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
-import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
-import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToSnapshotCmd;
-import org.apache.cloudstack.api.command.user.volume.*;
-import org.apache.cloudstack.api.command.user.vpc.*;
-import org.apache.cloudstack.api.command.user.vpn.*;
-import org.apache.cloudstack.api.command.user.zone.*;
-import org.apache.cloudstack.api.response.ExtractResponse;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
-
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.GetVncPortAnswer;
import com.cloud.agent.api.GetVncPortCommand;
@@ -126,12 +27,7 @@ import com.cloud.alert.AlertManager;
import com.cloud.alert.AlertVO;
import com.cloud.alert.dao.AlertDao;
import com.cloud.api.ApiDBUtils;
-import com.cloud.api.query.vo.EventJoinVO;
-import com.cloud.async.AsyncJobExecutor;
-import com.cloud.async.AsyncJobManager;
-import com.cloud.async.AsyncJobResult;
-import com.cloud.async.AsyncJobVO;
-import com.cloud.async.BaseAsyncJobExecutor;
+import com.cloud.async.*;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
@@ -144,36 +40,19 @@ import com.cloud.configuration.ConfigurationVO;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.consoleproxy.ConsoleProxyManagementState;
import com.cloud.consoleproxy.ConsoleProxyManager;
-import com.cloud.dc.AccountVlanMapVO;
-import com.cloud.dc.ClusterVO;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.HostPodVO;
-import com.cloud.dc.Pod;
-import com.cloud.dc.PodVlanMapVO;
-import com.cloud.dc.Vlan;
+import com.cloud.dc.*;
import com.cloud.dc.Vlan.VlanType;
-import com.cloud.dc.VlanVO;
-import com.cloud.dc.dao.AccountVlanMapDao;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.HostPodDao;
-import com.cloud.dc.dao.PodVlanMapDao;
-import com.cloud.dc.dao.VlanDao;
+import com.cloud.dc.dao.*;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
import com.cloud.event.ActionEvent;
+import com.cloud.event.ActionEventUtils;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InternalErrorException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.OperationTimedoutException;
-import com.cloud.exception.PermissionDeniedException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.exception.StorageUnavailableException;
+import com.cloud.exception.*;
import com.cloud.ha.HighAvailabilityManager;
import com.cloud.host.DetailVO;
import com.cloud.host.Host;
@@ -190,13 +69,7 @@ import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
import com.cloud.info.ConsoleProxyInfo;
import com.cloud.keystore.KeystoreManager;
import com.cloud.network.IpAddress;
-import com.cloud.network.as.ConditionVO;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.network.dao.IPAddressVO;
-import com.cloud.network.dao.LoadBalancerDao;
-import com.cloud.network.dao.LoadBalancerVO;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.*;
import com.cloud.org.Cluster;
import com.cloud.org.Grouping.AllocationState;
import com.cloud.projects.Project;
@@ -207,26 +80,10 @@ import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.server.auth.UserAuthenticator;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
-import com.cloud.storage.GuestOS;
-import com.cloud.storage.GuestOSCategoryVO;
-import com.cloud.storage.GuestOSVO;
-import com.cloud.storage.GuestOsCategory;
-import com.cloud.storage.Storage;
-import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.*;
import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.StorageManager;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.Upload;
import com.cloud.storage.Upload.Mode;
-import com.cloud.storage.UploadVO;
-import com.cloud.storage.Volume;
-import com.cloud.storage.VolumeVO;
-import com.cloud.storage.dao.DiskOfferingDao;
-import com.cloud.storage.dao.GuestOSCategoryDao;
-import com.cloud.storage.dao.GuestOSDao;
-import com.cloud.storage.dao.UploadDao;
-import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.*;
import com.cloud.storage.s3.S3Manager;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.storage.snapshot.SnapshotManager;
@@ -236,64 +93,142 @@ import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.template.TemplateManager;
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
-import com.cloud.user.Account;
-import com.cloud.user.AccountManager;
-import com.cloud.user.SSHKeyPair;
-import com.cloud.user.SSHKeyPairVO;
-import com.cloud.user.User;
-import com.cloud.user.UserContext;
-import com.cloud.user.UserVO;
+import com.cloud.user.*;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.SSHKeyPairDao;
import com.cloud.user.dao.UserDao;
-import com.cloud.utils.EnumUtils;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.Pair;
-import com.cloud.utils.PasswordGenerator;
-import com.cloud.utils.Ternary;
-import com.cloud.utils.component.Adapter;
-import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.*;
import com.cloud.utils.component.ComponentLifecycle;
-import com.cloud.utils.component.Manager;
import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.component.SystemIntegrityChecker;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.crypt.DBEncryptionUtil;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.db.JoinBuilder;
+import com.cloud.utils.db.*;
import com.cloud.utils.db.JoinBuilder.JoinType;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.mgmt.JmxUtil;
-import com.cloud.utils.mgmt.ManagementBean;
import com.cloud.utils.net.MacAddress;
import com.cloud.utils.net.NetUtils;
import com.cloud.utils.ssh.SSHKeysHelper;
-import com.cloud.vm.ConsoleProxyVO;
-import com.cloud.vm.InstanceGroupVO;
-import com.cloud.vm.SecondaryStorageVmVO;
-import com.cloud.vm.UserVmVO;
-import com.cloud.vm.VMInstanceVO;
-import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.*;
import com.cloud.vm.VirtualMachine.State;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.VirtualMachineProfileImpl;
-import com.cloud.vm.dao.ConsoleProxyDao;
-import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.InstanceGroupDao;
-import com.cloud.vm.dao.SecondaryStorageVmDao;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
-
+import com.cloud.vm.dao.*;
import edu.emory.mathcs.backport.java.util.Arrays;
import edu.emory.mathcs.backport.java.util.Collections;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
+import org.apache.cloudstack.api.command.admin.account.*;
+import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd;
+import org.apache.cloudstack.api.command.admin.autoscale.DeleteCounterCmd;
+import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
+import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
+import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
+import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd;
+import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
+import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd;
+import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
+import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
+import org.apache.cloudstack.api.command.admin.domain.*;
+import org.apache.cloudstack.api.command.admin.host.*;
+import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
+import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
+import org.apache.cloudstack.api.command.admin.network.*;
+import org.apache.cloudstack.api.command.admin.offering.*;
+import org.apache.cloudstack.api.command.admin.pod.CreatePodCmd;
+import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
+import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
+import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
+import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
+import org.apache.cloudstack.api.command.admin.region.RemoveRegionCmd;
+import org.apache.cloudstack.api.command.admin.region.UpdateRegionCmd;
+import org.apache.cloudstack.api.command.admin.resource.*;
+import org.apache.cloudstack.api.command.admin.router.*;
+import org.apache.cloudstack.api.command.admin.storage.*;
+import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
+import org.apache.cloudstack.api.command.admin.swift.ListSwiftsCmd;
+import org.apache.cloudstack.api.command.admin.systemvm.*;
+import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd;
+import org.apache.cloudstack.api.command.admin.usage.*;
+import org.apache.cloudstack.api.command.admin.user.*;
+import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
+import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
+import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
+import org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd;
+import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
+import org.apache.cloudstack.api.command.admin.vpc.*;
+import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
+import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
+import org.apache.cloudstack.api.command.admin.zone.MarkDefaultZoneForAccountCmd;
+import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
+import org.apache.cloudstack.api.command.user.account.AddAccountToProjectCmd;
+import org.apache.cloudstack.api.command.user.account.DeleteAccountFromProjectCmd;
+import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
+import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
+import org.apache.cloudstack.api.command.user.address.AssociateIPAddrCmd;
+import org.apache.cloudstack.api.command.user.address.DisassociateIPAddrCmd;
+import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd;
+import org.apache.cloudstack.api.command.user.autoscale.*;
+import org.apache.cloudstack.api.command.user.config.ListCapabilitiesCmd;
+import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
+import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
+import org.apache.cloudstack.api.command.user.event.ListEventTypesCmd;
+import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
+import org.apache.cloudstack.api.command.user.firewall.*;
+import org.apache.cloudstack.api.command.user.guest.ListGuestOsCategoriesCmd;
+import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
+import org.apache.cloudstack.api.command.user.iso.*;
+import org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd;
+import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
+import org.apache.cloudstack.api.command.user.loadbalancer.*;
+import org.apache.cloudstack.api.command.user.nat.*;
+import org.apache.cloudstack.api.command.user.network.*;
+import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
+import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
+import org.apache.cloudstack.api.command.user.project.*;
+import org.apache.cloudstack.api.command.user.region.ListRegionsCmd;
+import org.apache.cloudstack.api.command.user.region.ha.gslb.*;
+import org.apache.cloudstack.api.command.user.resource.*;
+import org.apache.cloudstack.api.command.user.securitygroup.*;
+import org.apache.cloudstack.api.command.user.snapshot.*;
+import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
+import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
+import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
+import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
+import org.apache.cloudstack.api.command.user.tag.CreateTagsCmd;
+import org.apache.cloudstack.api.command.user.tag.DeleteTagsCmd;
+import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
+import org.apache.cloudstack.api.command.user.template.*;
+import org.apache.cloudstack.api.command.user.vm.*;
+import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
+import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
+import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
+import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
+import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToSnapshotCmd;
+import org.apache.cloudstack.api.command.user.volume.*;
+import org.apache.cloudstack.api.command.user.vpc.*;
+import org.apache.cloudstack.api.command.user.vpn.*;
+import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
+import org.apache.cloudstack.api.response.ExtractResponse;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.lang.reflect.Field;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
public class ManagementServerImpl extends ManagerBase implements ManagementServer {
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
@@ -2242,6 +2177,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
cmdList.add(DeleteAlertsCmd.class);
cmdList.add(ArchiveEventsCmd.class);
cmdList.add(DeleteEventsCmd.class);
+ cmdList.add(CreateGlobalLoadBalancerRuleCmd.class);
+ cmdList.add(DeleteGlobalLoadBalancerRuleCmd.class);
+ cmdList.add(ListGlobalLoadBalancerRuleCmd.class);
+ cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
+ cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
cmdList.add(ListStorageProvidersCmd.class);
return cmdList;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/server/src/org/apache/cloudstack/region/RegionServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/RegionServiceProvider.java b/server/src/org/apache/cloudstack/region/RegionServiceProvider.java
new file mode 100755
index 0000000..ad7e22f
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/RegionServiceProvider.java
@@ -0,0 +1,25 @@
+/*
+ * 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;
+
+import com.cloud.utils.component.Adapter;
+
+public interface RegionServiceProvider extends Adapter {
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/server/src/org/apache/cloudstack/region/RegionVO.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/RegionVO.java b/server/src/org/apache/cloudstack/region/RegionVO.java
index 907c11d..6890bc8 100644
--- a/server/src/org/apache/cloudstack/region/RegionVO.java
+++ b/server/src/org/apache/cloudstack/region/RegionVO.java
@@ -36,6 +36,18 @@ public class RegionVO implements Region{
@Column(name="end_point")
private String endPoint;
+
+ public boolean getGslbEnabled() {
+ return gslbEnabled;
+ }
+
+ public void setGslbEnabled(boolean gslbEnabled) {
+ this.gslbEnabled = gslbEnabled;
+ }
+
+ @Column(name="gslb_service_enabled")
+ private boolean gslbEnabled;
+
public RegionVO() {
}
@@ -43,6 +55,7 @@ public class RegionVO implements Region{
this.id = id;
this.name = name;
this.endPoint = endPoint;
+ this.gslbEnabled = true;
}
public int getId() {
@@ -65,4 +78,10 @@ public class RegionVO implements Region{
this.endPoint = endPoint;
}
+
+ @Override
+ public boolean checkIfServiceEnabled(Service service) {
+ return gslbEnabled;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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
new file mode 100644
index 0000000..0020f5d
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerDaoImpl.java
@@ -0,0 +1,58 @@
+// 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.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.util.List;
+
+@Component
+@Local(value={GlobalLoadBalancerRuleDao.class})
+public class GlobalLoadBalancerDaoImpl extends GenericDaoBase<GlobalLoadBalancerRuleVO, Long> implements GlobalLoadBalancerRuleDao {
+
+ private final SearchBuilder<GlobalLoadBalancerRuleVO> listByDomainSearch;
+ private final SearchBuilder<GlobalLoadBalancerRuleVO> listByRegionIDSearch;
+
+ public GlobalLoadBalancerDaoImpl() {
+ listByDomainSearch = createSearchBuilder();
+ listByDomainSearch.and("gslbDomain", listByDomainSearch.entity().getGslbDomain(), SearchCriteria.Op.EQ);
+ listByDomainSearch.done();
+
+ listByRegionIDSearch = createSearchBuilder();
+ listByRegionIDSearch.and("region", listByRegionIDSearch.entity().getRegion(), SearchCriteria.Op.EQ);
+ listByRegionIDSearch.done();
+ }
+
+ @Override
+ public List<GlobalLoadBalancerRuleVO> listByRegionId(int regionId) {
+ SearchCriteria<GlobalLoadBalancerRuleVO> sc = listByRegionIDSearch.create();
+ sc.setParameters("region", regionId);
+ return listBy(sc);
+ }
+
+ @Override
+ public GlobalLoadBalancerRuleVO findByDomainName(String domainName) {
+ SearchCriteria<GlobalLoadBalancerRuleVO> sc = listByDomainSearch.create();
+ sc.setParameters("gslbDomain", domainName);
+ return findOneBy(sc);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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
new file mode 100644
index 0000000..5ce0b40
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDao.java
@@ -0,0 +1,30 @@
+// 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 GlobalLoadBalancerLbRuleMapDao extends GenericDao<GlobalLoadBalancerLbRuleMapVO, Long> {
+
+ List<GlobalLoadBalancerLbRuleMapVO> listByGslbRuleId(long gslbRuleId);
+
+ GlobalLoadBalancerLbRuleMapVO findByGslbRuleIdAndLbRuleId(long gslbRuleId, long lbRuleId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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
new file mode 100644
index 0000000..2a6e72b
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapDaoImpl.java
@@ -0,0 +1,63 @@
+// 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.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import java.util.List;
+
+@Component
+@Local(value={GlobalLoadBalancerLbRuleMapDao.class})
+@DB(txn = false)
+public class GlobalLoadBalancerLbRuleMapDaoImpl extends GenericDaoBase<GlobalLoadBalancerLbRuleMapVO, Long> implements GlobalLoadBalancerLbRuleMapDao {
+
+ private final SearchBuilder<GlobalLoadBalancerLbRuleMapVO> listByGslbRuleId;
+ private final SearchBuilder<GlobalLoadBalancerLbRuleMapVO> listByLbGslbRuleId;
+
+ public GlobalLoadBalancerLbRuleMapDaoImpl() {
+ listByGslbRuleId = createSearchBuilder();
+ listByGslbRuleId.and("gslbLoadBalancerId", listByGslbRuleId.entity().getGslbLoadBalancerId(), SearchCriteria.Op.EQ);
+ listByGslbRuleId.done();
+
+ listByLbGslbRuleId = createSearchBuilder();
+ listByLbGslbRuleId.and("gslbLoadBalancerId", listByLbGslbRuleId.entity().getGslbLoadBalancerId(), SearchCriteria.Op.EQ);
+ listByLbGslbRuleId.and("loadBalancerId", listByLbGslbRuleId.entity().getLoadBalancerId(), SearchCriteria.Op.EQ);
+ listByLbGslbRuleId.done();
+ }
+
+ @Override
+ public List<GlobalLoadBalancerLbRuleMapVO> listByGslbRuleId(long gslbRuleId) {
+ SearchCriteria<GlobalLoadBalancerLbRuleMapVO> sc = listByGslbRuleId.create();
+ sc.setParameters("gslbLoadBalancerId", gslbRuleId);
+ return listBy(sc);
+ }
+
+ @Override
+ public GlobalLoadBalancerLbRuleMapVO findByGslbRuleIdAndLbRuleId(long gslbRuleId, long lbRuleId) {
+ SearchCriteria<GlobalLoadBalancerLbRuleMapVO> sc = listByLbGslbRuleId.create();
+ sc.setParameters("gslbLoadBalancerId", gslbRuleId);
+ sc.setParameters("loadBalancerId", lbRuleId);
+ return findOneBy(sc);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapVO.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapVO.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapVO.java
new file mode 100644
index 0000000..6a1e17d
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerLbRuleMapVO.java
@@ -0,0 +1,83 @@
+// 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 org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name=("global_load_balancer_lb_rule_map"))
+public class GlobalLoadBalancerLbRuleMapVO implements InternalIdentity {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="lb_rule_id")
+ private long loadBalancerId;
+
+ @Column(name="gslb_rule_id")
+ private long gslbLoadBalancerId;
+
+ @Column(name="revoke")
+ private boolean revoke = false;
+
+ public GlobalLoadBalancerLbRuleMapVO() {
+
+ }
+
+ public GlobalLoadBalancerLbRuleMapVO(long loadBalancerId, long gslbLoadBalancerId) {
+ this.loadBalancerId = loadBalancerId;
+ this.gslbLoadBalancerId = gslbLoadBalancerId;
+ this.revoke = false;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getLoadBalancerId() {
+ return loadBalancerId;
+ }
+
+ public long getGslbLoadBalancerId() {
+ return gslbLoadBalancerId;
+ }
+
+ public void setLoadBalancerId(long loadBalancerId) {
+ this.loadBalancerId = loadBalancerId;
+ }
+
+ public void setGslbLoadBalancerId(long gslbLoadBalancerId) {
+ this.gslbLoadBalancerId = gslbLoadBalancerId;
+ }
+
+ public boolean isRevoke() {
+ return revoke;
+ }
+
+ public void setRevoke(boolean revoke) {
+ this.revoke = revoke;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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..1b44caa
--- /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(int regionId);
+ GlobalLoadBalancerRuleVO findByDomainName(String domainName);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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
new file mode 100644
index 0000000..a70b305
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java
@@ -0,0 +1,183 @@
+// 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.region.ha.GlobalLoadBalancerRule;
+
+import javax.persistence.*;
+import java.util.UUID;
+
+@Entity
+@Table(name=("global_load_balancing_rules"))
+public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ long id;
+
+ @Column(name="name")
+ private String name;
+
+ @Column(name="description", length=4096)
+ private String description;
+
+ @Column(name="algorithm")
+ private String algorithm;
+
+ @Column(name="persistence")
+ private String persistence;
+
+ @Column(name="gslb_domain_name")
+ private String gslbDomain;
+
+ @Column(name="service_type")
+ private String serviceType;
+
+ @Column(name="region_id")
+ private int region;
+
+ @Column(name="account_id")
+ long accountId;
+
+ @Column(name="domain_id", updatable=false)
+ long domainId;
+
+ @Column(name="uuid")
+ String uuid;
+
+ @Enumerated(value=EnumType.STRING)
+ @Column(name="state")
+ GlobalLoadBalancerRule.State state;
+
+ public GlobalLoadBalancerRuleVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm,
+ String persistence, String serviceType, int regionId, long accountId,
+ long domainId, State state) {
+ this.name =name;
+ this.description = description;
+ this.region = regionId;
+ this.algorithm = algorithm;
+ this.gslbDomain = gslbDomain;
+ this.persistence = persistence;
+ this.accountId = accountId;
+ this.domainId = domainId;
+ this.serviceType = serviceType;
+ this.uuid = UUID.randomUUID().toString();
+ this.state = state;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ @Override
+ public String getPersistence() {
+ return persistence;
+ }
+
+ @Override
+ public int getRegion() {
+ return region;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public long getDomainId() {
+ return domainId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setAlgorithm(String algorithm) {
+ this.algorithm = algorithm;
+ }
+
+ public void setPersistence(String persistence) {
+ this.persistence = persistence;
+ }
+
+ @Override
+ public String getGslbDomain() {
+ return gslbDomain;
+ }
+
+ public void setGslbDomain(String gslbDomain) {
+ this.gslbDomain = gslbDomain;
+ }
+
+ public void setRegion(int region) {
+ this.region =region;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ 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;
+ }
+
+ @Override
+ public GlobalLoadBalancerRule.State getState() {
+ return state;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5fb8349/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
new file mode 100644
index 0000000..1d4720e
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -0,0 +1,592 @@
+// 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.agent.AgentManager;
+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.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;
+import com.cloud.region.ha.GlobalLoadBalancingRulesService;
+import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
+import com.cloud.user.UserContext;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.net.NetUtils;
+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.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
+ GlobalLoadBalancerRuleDao _gslbRuleDao;
+ @Inject
+ GlobalLoadBalancerLbRuleMapDao _gslbLbMapDao;
+ @Inject
+ RegionDao _regionDao;
+ @Inject
+ RulesManager _rulesMgr;
+ @Inject
+ LoadBalancerDao _lbDao;
+ @Inject
+ NetworkDao _networkDao;
+ @Inject
+ ConfigurationDao _globalConfigDao;
+ @Inject
+ IPAddressDao _ipAddressDao;
+ @Inject
+ AgentManager _agentMgr;
+ @Inject
+ protected GslbServiceProvider _gslbProvider;
+ @Inject
+ protected List<NetworkElement> _networkElements;
+
+ @Override
+ @DB
+ @ActionEvent(eventType = EventTypes.EVENT_GLOBAL_LOAD_BALANCER_CREATE, eventDescription = "creating global load " +
+ "balancer rule", create = true)
+ public GlobalLoadBalancerRule createGlobalLoadBalancerRule(CreateGlobalLoadBalancerRuleCmd newRule) {
+
+ Integer regionId = newRule.getRegionId();
+ String algorithm = newRule.getAlgorithm();
+ String stickyMethod = newRule.getStickyMethod();
+ String name = newRule.getName();
+ String description = newRule.getDescription();
+ String domainName = newRule.getServiceDomainName();
+ String serviceType = newRule.getServiceType();
+
+ Account gslbOwner = _accountMgr.getAccount(newRule.getEntityOwnerId());
+
+ if (!GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
+ throw new InvalidParameterValueException("Invalid Algorithm: " + algorithm);
+ }
+
+ if (!GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
+ throw new InvalidParameterValueException("Invalid persistence: " + stickyMethod);
+ }
+
+ if (!GlobalLoadBalancerRule.ServiceType.isValidServiceType(serviceType)) {
+ throw new InvalidParameterValueException("Invalid service type: " + serviceType);
+ }
+
+ if (!NetUtils.verifyDomainName(domainName)){
+ throw new InvalidParameterValueException("Invalid domain name : " + domainName);
+ }
+
+ GlobalLoadBalancerRuleVO gslbRuleWithDomainName = _gslbRuleDao.findByDomainName(domainName);
+ if (gslbRuleWithDomainName != null) {
+ throw new InvalidParameterValueException("Domain name " + domainName + "is in use");
+ }
+
+ Region region = _regionDao.findById(regionId);
+ if (region == null) {
+ throw new InvalidParameterValueException("Invalid region ID: " + regionId);
+ }
+
+ if (!region.checkIfServiceEnabled(Region.Service.Gslb)) {
+ throw new CloudRuntimeException("GSLB service is not enabled in region : " + region.getName());
+ }
+
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ GlobalLoadBalancerRuleVO newGslbRule = new GlobalLoadBalancerRuleVO(name, description, domainName, algorithm,
+ stickyMethod, serviceType, regionId, gslbOwner.getId(), gslbOwner.getDomainId(),
+ GlobalLoadBalancerRule.State.Staged);
+ _gslbRuleDao.persist(newGslbRule);
+ txn.commit();
+
+ s_logger.debug("successfully created new global load balancer rule for the account " + gslbOwner.getId());
+
+ return newGslbRule;
+ }
+
+ @Override
+ @DB
+ @ActionEvent(eventType = EventTypes.EVENT_ASSIGN_TO_GLOBAL_LOAD_BALANCER_RULE, eventDescription =
+ "Assigning a load balancer rule to global load balancer rule", async=true)
+ public boolean assignToGlobalLoadBalancerRule(AssignToGlobalLoadBalancerRuleCmd assignToGslbCmd) {
+
+ UserContext ctx = UserContext.current();
+ Account caller = ctx.getCaller();
+
+ long gslbRuleId = assignToGslbCmd.getGlobalLoadBalancerRuleId();
+ GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+ if (gslbRule == null) {
+ throw new InvalidParameterValueException("Invalid global load balancer rule id: " + gslbRule.getUuid());
+ }
+
+ _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
+
+ if (gslbRule.getState() == GlobalLoadBalancerRule.State.Revoke) {
+ throw new InvalidParameterValueException("global load balancer rule id: " + gslbRule.getUuid()
+ + " is in revoked 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");
+ }
+
+ List<Long> oldLbRuleIds = new ArrayList<Long>();
+ List<Long> oldZones = new ArrayList<Long>();
+ List<Long> newZones = new ArrayList<Long>(oldZones);
+
+ // get the list of load balancer rules id's that are assigned currently to GSLB rule and corresponding zone id's
+ 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());
+ oldZones.add(network.getDataCenterId());
+ oldLbRuleIds.add(gslbLbMapVo.getLoadBalancerId());
+ }
+ }
+
+ /* check each of the load balancer rule id passed in the 'AssignToGlobalLoadBalancerRuleCmd' command is
+ * valid ID
+ * caller has access to the rule
+ * check rule is not revoked
+ * no two rules are in same zone
+ * rule is not 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 != null && oldZones.contains(network.getDataCenterId()) ||
+ newZones != null && newZones.contains(network.getDataCenterId())) {
+ throw new InvalidParameterValueException("Load balancer rule specified should be in unique zone");
+ }
+
+ newZones.add(network.getDataCenterId());
+ }
+
+ // check each of the zone has a GSLB service provider configured
+ for (Long zoneId: newZones) {
+ if (!checkGslbServiceEnabledInZone(zoneId)) {
+ throw new InvalidParameterValueException("GSLB service is not enabled in the Zone");
+ }
+ }
+
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+
+ // 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);
+ }
+
+ // mark the gslb rule state as add
+ if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged || gslbRule.getState() ==
+ GlobalLoadBalancerRule.State.Active ) {
+ gslbRule.setState(GlobalLoadBalancerRule.State.Add);
+ _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+ }
+
+ txn.commit();
+
+ boolean success = false;
+ try {
+ s_logger.debug("Configuring gslb rule configuration on the gslb service providers in the participating zones");
+
+ // apply the gslb rule on to the back end gslb service providers on zones participating in gslb
+ applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+
+ // on success set state to Active
+ gslbRule.setState(GlobalLoadBalancerRule.State.Active);
+ _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+
+ success = true;
+
+ } catch (ResourceUnavailableException e) {
+ throw new CloudRuntimeException("Failed to apply gslb config");
+ }
+
+ return success;
+ }
+
+ @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: " + gslbRule.getUuid());
+ }
+
+ _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.getLoadBalancerRulesIds();
+ 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 rule id's that are assigned currently to GSLB rule and corresponding zone id's
+ 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 (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);
+ }
+
+ for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+ LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
+ Network network = _networkDao.findById(loadBalancer.getNetworkId());
+ oldLbRuleIds.add(gslbLbMapVo.getLoadBalancerId());
+ oldZones.add(network.getDataCenterId());
+ }
+
+ for (Long lbRuleId : lbRuleIdsToremove) {
+ LoadBalancerVO loadBalancer = _lbDao.findById(lbRuleId);
+ 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 gslb rule state as add
+ if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged) {
+ gslbRule.setState(GlobalLoadBalancerRule.State.Add);
+ _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+ }
+
+ txn.commit();
+
+ boolean success = false;
+ 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);
+ success = true;
+ } catch (ResourceUnavailableException e) {
+ throw new CloudRuntimeException("Failed to update removed load balancer details from gloabal load balancer");
+ }
+
+ return success;
+ }
+
+ @Override
+ @DB
+ @ActionEvent(eventType = EventTypes.EVENT_GLOBAL_LOAD_BALANCER_DELETE, eventDescription =
+ "Delete global load balancer rule")
+ public boolean deleteGlobalLoadBalancerRule(DeleteGlobalLoadBalancerRuleCmd deleteGslbCmd) {
+
+ UserContext ctx = UserContext.current();
+ Account caller = ctx.getCaller();
+
+ long gslbRuleId = deleteGslbCmd.getGlobalLoadBalancerId();
+ GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+ if (gslbRule == null) {
+ 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("global load balancer rule id: " + gslbRuleId + " is already in revoked state");
+ }
+
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+
+ List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+ if (gslbLbMapVos != null) {
+ //mark all the GSLB-LB mapping to be in revoke state
+ for (GlobalLoadBalancerLbRuleMapVO gslbLbMap : gslbLbMapVos) {
+ gslbLbMap.setRevoke(true);
+ }
+ }
+
+ //mark the GSlb rule to be in revoke state
+ gslbRule.setState(GlobalLoadBalancerRule.State.Revoke);
+ _gslbRuleDao.update(gslbRuleId, gslbRule);
+
+ txn.commit();
+
+ boolean success = false;
+ try {
+ if (gslbLbMapVos != null) {
+ applyGlobalLoadBalancerRuleConfig(gslbRuleId, true);
+ }
+ success = true;
+ } catch (ResourceUnavailableException e) {
+ throw new CloudRuntimeException("Failed to update the gloabal load balancer");
+ }
+
+ return success;
+ }
+
+ @Override
+ public GlobalLoadBalancerRule updateGlobalLoadBalancerRule(UpdateGlobalLoadBalancerRuleCmd updateGslbCmd) {
+
+ String algorithm = updateGslbCmd.getAlgorithm();
+ String stickyMethod = updateGslbCmd.getStickyMethod();
+ String description = updateGslbCmd.getDescription();
+
+ long gslbRuleId = updateGslbCmd.getId();
+ GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+ if (gslbRule == null) {
+ throw new InvalidParameterValueException("Invalid global load balancer rule id: " + gslbRuleId);
+ }
+
+ UserContext ctx = UserContext.current();
+ Account caller = ctx.getCaller();
+
+ _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
+
+
+ if (!GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
+ throw new InvalidParameterValueException("Invalid Algorithm: " + algorithm);
+ }
+
+ if (!GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
+ throw new InvalidParameterValueException("Invalid persistence: " + stickyMethod);
+ }
+
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ gslbRule.setAlgorithm(algorithm);
+ gslbRule.setPersistence(stickyMethod);
+ gslbRule.setDescription(description);
+ _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+ txn.commit();
+
+ try {
+ s_logger.debug("Updated global load balancer with id " + gslbRule.getUuid());
+
+ // apply the gslb rule on to the back end gslb service providers on zones participating in gslb
+ applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);
+
+ // on success set state to Active
+ gslbRule.setState(GlobalLoadBalancerRule.State.Active);
+ _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+
+ return gslbRule;
+ } catch (ResourceUnavailableException e) {
+ throw new CloudRuntimeException("Failed to configure gslb config due to " + e.getMessage());
+ }
+ }
+
+ @Override
+ public List<GlobalLoadBalancerRule> listGlobalLoadBalancerRule(ListGlobalLoadBalancerRuleCmd listGslbCmd) {
+ Integer regionId = listGslbCmd.getRegionId();
+ Long ruleId = listGslbCmd.getId();
+ List<GlobalLoadBalancerRule> response = new ArrayList<GlobalLoadBalancerRule>();
+ if (regionId == null && ruleId == null) {
+ throw new InvalidParameterValueException("Invalid arguments. At least one of region id, " +
+ "rule id must be specified");
+ }
+
+ if (regionId != null && ruleId != null) {
+ throw new InvalidParameterValueException("Invalid arguments. Only one of region id, " +
+ "rule id must be specified");
+ }
+
+ if (ruleId != null) {
+ GlobalLoadBalancerRule gslbRule = _gslbRuleDao.findById(ruleId);
+ if (gslbRule == null) {
+ throw new InvalidParameterValueException("Invalid gslb rule id specified");
+ }
+ response.add(gslbRule);
+ return response;
+ }
+
+ if (regionId != null) {
+ List<GlobalLoadBalancerRuleVO> gslbRules = _gslbRuleDao.listByRegionId(regionId);
+ if (gslbRules != null) {
+ response.addAll(gslbRules);
+ }
+ return response;
+ }
+
+ return null;
+ }
+
+ private boolean applyGlobalLoadBalancerRuleConfig(long gslbRuleId, boolean revoke) throws ResourceUnavailableException {
+
+ GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+ assert(gslbRule != null);
+
+ String lbMethod = gslbRule.getAlgorithm();
+ 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
+ // and the deployment DNS name configured in global config parameter 'cloud.dns.name'
+ String domainName = gslbRule.getGslbDomain();
+ String providerDnsName = _globalConfigDao.getValue(Config.CloudDnsName.key());
+ String gslbFqdn = domainName + "." + providerDnsName;
+
+ GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn,
+ lbMethod, persistenceMethod, serviceType, gslbRuleId, revoke);
+
+ // list of the zones participating in global load balancing
+ List<Long> gslbSiteIds = new ArrayList<Long>();
+
+ // map of the zone and info corresponding to the load balancer configured in the zone
+ Map<Long, SiteLoadBalancerConfig> zoneSiteLoadbalancerMap = new HashMap<Long, SiteLoadBalancerConfig>();
+
+ List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+
+ assert (gslbLbMapVos != null && !gslbLbMapVos.isEmpty());
+
+ for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+
+ // get the zone in which load balancer rule is deployed
+ LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
+ Network network = _networkDao.findById(loadBalancer.getNetworkId());
+ long dataCenterId = network.getDataCenterId();
+
+ gslbSiteIds.add(dataCenterId);
+
+ IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
+ SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType,
+ ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()),
+ dataCenterId);
+
+ siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId));
+ siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId));
+
+ zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
+ }
+
+ // loop through all the zones, participating in GSLB, and send GSLB config command
+ // to the corresponding GSLB service provider in that zone
+ for (long zoneId: gslbSiteIds) {
+
+ List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
+
+ // set site as 'local' for the site in that zone
+ for (long innerLoopZoneId: gslbSiteIds) {
+ SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId);
+ siteLb.setLocal(zoneId == innerLoopZoneId);
+ slbs.add(siteLb);
+ }
+
+ gslbConfigCmd.setSiteLoadBalancers(slbs);
+
+ try {
+ _gslbProvider.applyGlobalLoadBalancerRule(zoneId, gslbConfigCmd);
+ } catch (ResourceUnavailableException e) {
+ s_logger.warn("Failed to configure GSLB rul in the zone " + zoneId + " due to " + e.getMessage());
+ throw new CloudRuntimeException("Failed to configure GSLB rul in the zone");
+ }
+ }
+
+ return true;
+ }
+
+ private boolean checkGslbServiceEnabledInZone(long zoneId) {
+
+ if (_gslbProvider == null) {
+ throw new CloudRuntimeException("No GSLB provider is available");
+ }
+
+ 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/c5fb8349/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java b/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
new file mode 100755
index 0000000..4338d65
--- /dev/null
+++ b/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
@@ -0,0 +1,36 @@
+/*
+ * 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.agent.api.routing.GlobalLoadBalancerConfigCommand;
+import com.cloud.exception.ResourceUnavailableException;
+import org.apache.cloudstack.region.RegionServiceProvider;
+
+public interface GslbServiceProvider extends RegionServiceProvider {
+
+ public boolean isServiceEnabledInZone(long zoneId);
+
+ public String getZoneGslbProviderPublicIp(long zoneId);
+
+ public String getZoneGslbProviderPrivateIp(long zoneId);
+
+ public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand gslbConfigCmd)
+ throws ResourceUnavailableException;
+
+}