Updated Branches: refs/heads/gslb-wip fd18fb619 -> 89c33a01e
-introducing RegionServiceProvider and GslbServiceProvider -NetScaler element implements GslbServiceProvider Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/89c33a01 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/89c33a01 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/89c33a01 Branch: refs/heads/gslb-wip Commit: 89c33a01e70d329bdcd98242596a303f4b978431 Parents: a332bc2 Author: Murali Reddy <[email protected]> Authored: Thu Mar 7 20:05:51 2013 +0530 Committer: Murali Reddy <[email protected]> Committed: Thu Mar 7 20:05:51 2013 +0530 ---------------------------------------------------------------------- .../org/apache/cloudstack/api/ApiConstants.java | 1 + .../element/F5ExternalLoadBalancerElement.java | 59 +++------- .../api/commands/AddNetscalerLoadBalancerCmd.java | 25 ++-- .../cloud/network/element/NetscalerElement.java | 95 +++++++------- .../network/ExternalLoadBalancerDeviceManager.java | 3 +- .../ExternalLoadBalancerDeviceManagerImpl.java | 62 +++------- .../network/dao/ExternalLoadBalancerDeviceVO.java | 27 +++-- .../cloudstack/region/RegionServiceProvider.java | 23 ++++ .../gslb/GlobalLoadBalancingRulesServiceImpl.java | 99 +++++++++------ .../region/gslb/GslbServiceProvider.java | 36 ++++++ .../GlobalLoadBalancingRulesServiceImplTest.java | 38 ++++++- setup/db/create-schema.sql | 1 + 12 files changed, 269 insertions(+), 200 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/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 7e44f27..e1cf9a4 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -443,6 +443,7 @@ public class ApiConstants { public static final String AUTOSCALE_USER_ID = "autoscaleuserid"; public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername"; public static final String UCS_DN = "ucsdn"; + public static final String GSLB_PROVIDER = "gslbprovider"; public enum HostDetails { all, capacity, events, stats, min; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java index 94c098e..f9baad2 100644 --- a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java +++ b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java @@ -16,28 +16,8 @@ // under the License. package com.cloud.network.element; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import javax.inject.Inject; - -import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse; -import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; -import org.apache.log4j.Logger; - import com.cloud.api.ApiDBUtils; -import com.cloud.api.commands.AddExternalLoadBalancerCmd; -import com.cloud.api.commands.AddF5LoadBalancerCmd; -import com.cloud.api.commands.ConfigureF5LoadBalancerCmd; -import com.cloud.api.commands.DeleteExternalLoadBalancerCmd; -import com.cloud.api.commands.DeleteF5LoadBalancerCmd; -import com.cloud.api.commands.ListExternalLoadBalancersCmd; -import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd; -import com.cloud.api.commands.ListF5LoadBalancersCmd; +import com.cloud.api.commands.*; import com.cloud.api.response.F5LoadBalancerResponse; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; @@ -46,35 +26,17 @@ import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.deploy.DeployDestination; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InsufficientNetworkCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDetailsDao; -import com.cloud.network.ExternalLoadBalancerDeviceManager; -import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl; -import com.cloud.network.Network; +import com.cloud.network.*; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.NetworkModel; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.PublicIpAddress; -import com.cloud.network.dao.ExternalLoadBalancerDeviceDao; -import com.cloud.network.dao.ExternalLoadBalancerDeviceVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerVO; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.network.dao.*; import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.resource.F5BigIpResource; @@ -88,6 +50,13 @@ import com.cloud.vm.ReservationContext; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; import com.google.gson.Gson; +import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse; +import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.inject.Inject; +import java.util.*; @Local(value = {NetworkElement.class, LoadBalancingServiceProvider.class, IpDeployer.class}) public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, IpDeployer, F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager { @@ -294,7 +263,8 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan pNetwork = physicalNetworks.get(0); String deviceType = NetworkDevice.F5BigIpLoadBalancer.getName(); - lbDeviceVO = addExternalLoadBalancer(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceType, new F5BigIpResource()); + lbDeviceVO = addExternalLoadBalancer(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), + deviceType, new F5BigIpResource(), false); if (lbDeviceVO != null) { lbHost = _hostDao.findById(lbDeviceVO.getHostId()); @@ -347,7 +317,8 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan throw new InvalidParameterValueException("Invalid F5 load balancer device type"); } - return addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, new F5BigIpResource()); + return addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), + deviceName, new F5BigIpResource(), false); } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java index 80c8cb9..9de15d2 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java +++ b/plugins/network-elements/netscaler/src/com/cloud/api/commands/AddNetscalerLoadBalancerCmd.java @@ -15,23 +15,18 @@ package com.cloud.api.commands; -import javax.inject.Inject; - -import org.apache.cloudstack.api.*; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; -import org.apache.log4j.Logger; -import org.apache.cloudstack.api.APICommand; import com.cloud.api.response.NetscalerLoadBalancerResponse; import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.network.dao.ExternalLoadBalancerDeviceVO; import com.cloud.network.element.NetscalerLoadBalancerElementService; import com.cloud.user.UserContext; import com.cloud.utils.exception.CloudRuntimeException; +import org.apache.cloudstack.api.*; +import org.apache.cloudstack.api.response.PhysicalNetworkResponse; +import org.apache.log4j.Logger; + +import javax.inject.Inject; @APICommand(name = "addNetscalerLoadBalancer", responseObject=NetscalerLoadBalancerResponse.class, description="Adds a netscaler load balancer device") public class AddNetscalerLoadBalancerCmd extends BaseAsyncCmd { @@ -60,6 +55,10 @@ public class AddNetscalerLoadBalancerCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, required = true, description = "Netscaler device type supports NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer") private String deviceType; + @Parameter(name = ApiConstants.GSLB_PROVIDER, type = CommandType.BOOLEAN, required = false, + description = "true if NetScaler device bieng added is for providing GSLB service") + private boolean isGslbProvider; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -84,6 +83,10 @@ public class AddNetscalerLoadBalancerCmd extends BaseAsyncCmd { return deviceType; } + public boolean isGslbProvider() { + return isGslbProvider; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java index 8f902df..4392544 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java +++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java @@ -16,35 +16,16 @@ // under the License. package com.cloud.network.element; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import javax.inject.Inject; - -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; +import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand; import com.cloud.agent.api.routing.LoadBalancerConfigCommand; import com.cloud.agent.api.routing.SetStaticNatRulesAnswer; import com.cloud.agent.api.routing.SetStaticNatRulesCommand; import com.cloud.agent.api.to.LoadBalancerTO; import com.cloud.agent.api.to.StaticNatRuleTO; import com.cloud.api.ApiDBUtils; -import com.cloud.api.commands.AddNetscalerLoadBalancerCmd; -import com.cloud.api.commands.ConfigureNetscalerLoadBalancerCmd; -import com.cloud.api.commands.DeleteNetscalerLoadBalancerCmd; -import com.cloud.api.commands.ListNetscalerLoadBalancerNetworksCmd; -import com.cloud.api.commands.ListNetscalerLoadBalancersCmd; +import com.cloud.api.commands.*; import com.cloud.api.response.NetscalerLoadBalancerResponse; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; @@ -56,40 +37,19 @@ import com.cloud.dc.HostPodVO; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterIpAddressDao; import com.cloud.deploy.DeployDestination; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InsufficientNetworkCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDetailsDao; -import com.cloud.network.ExternalLoadBalancerDeviceManager; -import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl; -import com.cloud.network.IpAddress; -import com.cloud.network.NetScalerPodVO; -import com.cloud.network.Network; +import com.cloud.network.*; import com.cloud.network.Network.Capability; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.NetworkModel; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.PublicIpAddress; import com.cloud.network.as.AutoScaleCounter; import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterType; -import com.cloud.network.dao.ExternalLoadBalancerDeviceDao; -import com.cloud.network.dao.ExternalLoadBalancerDeviceVO; -import com.cloud.network.dao.NetScalerPodDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerVO; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.network.dao.*; import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.lb.LoadBalancingRule.LbDestination; @@ -110,10 +70,20 @@ import com.cloud.vm.ReservationContext; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; import com.google.gson.Gson; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; +import org.apache.cloudstack.region.gslb.GslbServiceProvider; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.inject.Inject; +import java.net.URI; +import java.util.*; @Local(value = {NetworkElement.class, StaticNatServiceProvider.class, LoadBalancingServiceProvider.class}) -public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer, -StaticNatServiceProvider { +public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, + NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer, StaticNatServiceProvider, + GslbServiceProvider { private static final Logger s_logger = Logger.getLogger(NetscalerElement.class); public static final AutoScaleCounterType AutoScaleCounterSnmp = new AutoScaleCounterType("snmp"); @@ -335,7 +305,8 @@ StaticNatServiceProvider { throw new InvalidParameterValueException(msg); } - ExternalLoadBalancerDeviceVO lbDeviceVO = addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, new NetscalerResource()); + ExternalLoadBalancerDeviceVO lbDeviceVO = addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), + cmd.getUsername(), cmd.getPassword(), deviceName, new NetscalerResource(), cmd.isGslbProvider()); return lbDeviceVO; } @@ -817,4 +788,32 @@ StaticNatServiceProvider { } return null; } + + @Override + public boolean isServiceEnabledInZone(long zoneId) { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public String getProviderPublicIp(long zoneId) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public String getProviderPrivateIp(long zoneId) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand gslbConfigCmd) { + + // get the host Id corresponding to GSLB service provider in the zone + long zoneGslbProviderHosId = 0; + + Answer answer = _agentMgr.easySend(zoneGslbProviderHosId, gslbConfigCmd); + if (answer == null) { + + } + return false; //To change body of implemented methods use File | Settings | File Templates. + } } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java index d979f07..34f5905 100644 --- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java +++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java @@ -46,7 +46,8 @@ public interface ExternalLoadBalancerDeviceManager extends Manager{ * @param server resource that will handle the commands specific to this device * @return Host object for the device added */ - public ExternalLoadBalancerDeviceVO addExternalLoadBalancer(long physicalNetworkId, String url, String username, String password, String deviceName, ServerResource resource); + public ExternalLoadBalancerDeviceVO addExternalLoadBalancer(long physicalNetworkId, String url, String username, + String password, String deviceName, ServerResource resource, boolean gslbProvider); /** * deletes load balancer device added in to a physical network http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java index bcefccc..33de0ee 100644 --- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java +++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java @@ -16,30 +16,13 @@ // under the License. package com.cloud.network; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import javax.inject.Inject; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupExternalLoadBalancerCommand; -import com.cloud.agent.api.routing.CreateLoadBalancerApplianceCommand; -import com.cloud.agent.api.routing.DestroyLoadBalancerApplianceCommand; -import com.cloud.agent.api.routing.IpAssocCommand; -import com.cloud.agent.api.routing.LoadBalancerConfigCommand; -import com.cloud.agent.api.routing.NetworkElementCommand; +import com.cloud.agent.api.routing.*; import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.LoadBalancerTO; -import org.apache.cloudstack.api.ApiConstants; import com.cloud.configuration.Config; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.dc.DataCenter; @@ -59,28 +42,11 @@ import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDetailsDao; -import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; import com.cloud.network.addr.PublicIp; -import com.cloud.network.dao.ExternalFirewallDeviceDao; -import com.cloud.network.dao.ExternalLoadBalancerDeviceDao; -import com.cloud.network.dao.ExternalLoadBalancerDeviceVO; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.InlineLoadBalancerNicMapDao; -import com.cloud.network.dao.InlineLoadBalancerNicMapVO; -import com.cloud.network.dao.LoadBalancerDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkExternalFirewallDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerDao; -import com.cloud.network.dao.NetworkExternalLoadBalancerVO; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; -import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.network.dao.*; import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceAllocationState; import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState; import com.cloud.network.element.IpDeployer; @@ -97,12 +63,7 @@ import com.cloud.network.rules.StaticNatImpl; import com.cloud.network.rules.dao.PortForwardingRulesDao; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.resource.ResourceManager; -import com.cloud.resource.ResourceState; -import com.cloud.resource.ResourceStateAdapter; -import com.cloud.resource.ServerResource; -import com.cloud.resource.UnableDeleteHostException; -import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse; +import com.cloud.resource.*; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.dao.AccountDao; @@ -120,6 +81,15 @@ import com.cloud.vm.Nic.State; import com.cloud.vm.NicVO; import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.NicDao; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse; +import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; +import org.apache.log4j.Logger; + +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import java.net.URI; +import java.util.*; public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements ExternalLoadBalancerDeviceManager, ResourceStateAdapter { @@ -187,7 +157,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase @Override @DB - public ExternalLoadBalancerDeviceVO addExternalLoadBalancer(long physicalNetworkId, String url, String username, String password, String deviceName, ServerResource resource) { + public ExternalLoadBalancerDeviceVO addExternalLoadBalancer(long physicalNetworkId, String url, + String username, String password, String deviceName, ServerResource resource, boolean gslbProvider) { PhysicalNetworkVO pNetwork = null; NetworkDevice ntwkDevice = NetworkDevice.getNetworkDevice(deviceName); @@ -253,7 +224,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase txn.start(); ExternalLoadBalancerDeviceVO lbDeviceVO = new ExternalLoadBalancerDeviceVO(host.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(), - deviceName, capacity, dedicatedUse); + deviceName, capacity, dedicatedUse, gslbProvider); _externalLoadBalancerDeviceDao.persist(lbDeviceVO); DetailVO hostDetail = new DetailVO(host.getId(), ApiConstants.LOAD_BALANCER_DEVICE_ID, String.valueOf(lbDeviceVO.getId())); @@ -499,7 +470,8 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase "&publicipvlan=" + publicIPVlanTag + "&publicipgateway=" + publicIPgateway; ExternalLoadBalancerDeviceVO lbAppliance = null; try { - lbAppliance = addExternalLoadBalancer(physicalNetworkId, url, username, password, createLbAnswer.getDeviceName(), createLbAnswer.getServerResource()); + lbAppliance = addExternalLoadBalancer(physicalNetworkId, url, username, password, + createLbAnswer.getDeviceName(), createLbAnswer.getServerResource(), false); } catch (Exception e) { s_logger.error("Failed to add load balancer appliance in to cloudstack due to " + e.getMessage() + ". So provisioned load balancer appliance will be destroyed."); } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/server/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java b/server/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java index cd9dffd..a859af1 100644 --- a/server/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java +++ b/server/src/com/cloud/network/dao/ExternalLoadBalancerDeviceVO.java @@ -20,17 +20,9 @@ import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.network.ExternalNetworkDeviceManager; +import javax.persistence.*; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - /** * ExternalLoadBalancerDeviceVO contains information on external load balancer devices (F5/Netscaler VPX,MPX,SDX) added into a deployment */ @@ -73,6 +65,9 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity @Column(name="is_dedicated") private boolean isDedicatedDevice; + @Column(name="is_gslb_provider") + private boolean gslbProvider; + @Column(name = "parent_host_id") private long parentHostId; @@ -93,7 +88,7 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity } public ExternalLoadBalancerDeviceVO(long hostId, long physicalNetworkId, String provider_name, String device_name, - long capacity, boolean dedicated) { + long capacity, boolean dedicated, boolean gslbProvider) { this.physicalNetworkId = physicalNetworkId; this.providerName = provider_name; this.deviceName = device_name; @@ -105,7 +100,7 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity this.isManagedDevice = false; this.state = LBDeviceState.Enabled; this.uuid = UUID.randomUUID().toString(); - + this.gslbProvider = gslbProvider; if (device_name.equalsIgnoreCase(ExternalNetworkDeviceManager.NetworkDevice.NetscalerSDXLoadBalancer.getName())) { this.allocationState = LBDeviceAllocationState.Provider; } @@ -113,7 +108,7 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity public ExternalLoadBalancerDeviceVO(long hostId, long physicalNetworkId, String provider_name, String device_name, long capacity, boolean dedicated, boolean managed, long parentHostId) { - this(hostId, physicalNetworkId, provider_name, device_name, capacity, dedicated); + this(hostId, physicalNetworkId, provider_name, device_name, capacity, dedicated, false); this.isManagedDevice = managed; this.parentHostId = parentHostId; } @@ -190,6 +185,14 @@ public class ExternalLoadBalancerDeviceVO implements InternalIdentity, Identity isDedicatedDevice = isDedicated; } + public boolean getGslbProvider() { + return gslbProvider; + } + + public void setGslbProvider(boolean gslbProvider) { + gslbProvider = gslbProvider; + } + public String getUuid() { return uuid; } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/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..28375a9 --- /dev/null +++ b/server/src/org/apache/cloudstack/region/RegionServiceProvider.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface RegionServiceProvider { + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/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 595986e..7d0bd96 100644 --- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java +++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java @@ -18,7 +18,6 @@ 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; @@ -26,6 +25,7 @@ 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.rules.LoadBalancer; @@ -79,6 +79,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR IPAddressDao _ipAddressDao; @Inject AgentManager _agentMgr; + @Inject + GslbServiceProvider _gslbProvider; @Override @DB @@ -114,7 +116,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR GlobalLoadBalancerRuleVO gslbRuleWithDomainName = _gslbRuleDao.findByDomainName(domainName); if (gslbRuleWithDomainName != null) { - throw new InvalidParameterValueException("Domain name is in use"); + throw new InvalidParameterValueException("Domain name " + domainName + "is in use"); } Region region = _regionDao.findById(regionId); @@ -123,7 +125,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR } if (!region.checkIfServiceEnabled(Region.Service.Gslb)) { - throw new InvalidParameterValueException("GSLB service is not enabled in region : " + region.getName()); + throw new CloudRuntimeException("GSLB service is not enabled in region : " + region.getName()); } Transaction txn = Transaction.currentTxn(); @@ -187,7 +189,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR * 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 + * rule is not already assigned to gslb rule */ for (Long lbRuleId : newLbRuleIds) { @@ -235,17 +237,17 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR } // mark the gslb rule state as add - if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged) { + if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged || gslbRule.getState() == + GlobalLoadBalancerRule.State.Active ) { gslbRule.setState(GlobalLoadBalancerRule.State.Add); _gslbRuleDao.update(gslbRule.getId(), gslbRule); } txn.commit(); - s_logger.debug("Updated the global load balancer rule: " + gslbRuleId + " in database"); - + boolean success = false; try { - s_logger.debug("Configuring global load balancer rule configuration on the gslb service providers "); + 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); @@ -254,10 +256,17 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR gslbRule.setState(GlobalLoadBalancerRule.State.Active); _gslbRuleDao.update(gslbRule.getId(), gslbRule); - return true; - } catch (Exception e) { - throw new CloudRuntimeException("Failed to configure gslb config due to " + e.getMessage()); + success = true; + + } catch (ResourceUnavailableException e) { + } + + if (!success) { + throw new CloudRuntimeException("Failed to apply gslb config"); + } + + return success; } @Override @@ -339,8 +348,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR txn.commit(); - s_logger.debug("Updated the global load balancer rule: " + gslbRuleId + " in database"); - + boolean success = false; try { s_logger.debug("Attempting to configure global load balancer rule configuration on the gslb service providers "); @@ -350,13 +358,16 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR // on success set state to Active gslbRule.setState(GlobalLoadBalancerRule.State.Active); _gslbRuleDao.update(gslbRule.getId(), gslbRule); + success = true; + } catch (ResourceUnavailableException e) { - return true; - } catch (Exception e) { + } + if (!success) { + throw new CloudRuntimeException("Failed to update removed load balancer details from gloabal load balancer"); } - return false; + return success; } @Override @@ -397,14 +408,20 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR txn.commit(); - // send the new configuration to back end + boolean success = false; try { - applyGlobalLoadBalancerRuleConfig(gslbRuleId, true); - } catch (Exception e) { + if (gslbLbMapVos != null) { + applyGlobalLoadBalancerRuleConfig(gslbRuleId, true); + } + success = true; + } catch (ResourceUnavailableException e) { } - return false; + if (!success) { + throw new CloudRuntimeException("Failed to update the gloabal load balancer"); + } + return success; } @Override @@ -453,7 +470,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR _gslbRuleDao.update(gslbRule.getId(), gslbRule); return gslbRule; - } catch (Exception e) { + } catch (ResourceUnavailableException e) { throw new CloudRuntimeException("Failed to configure gslb config due to " + e.getMessage()); } } @@ -463,32 +480,36 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR return null; } - private void applyGlobalLoadBalancerRuleConfig(long gslbRuleId, boolean revoke) { + private boolean applyGlobalLoadBalancerRuleConfig(long gslbRuleId, boolean revoke) throws ResourceUnavailableException { GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId); + assert(gslbRule != null); - String domainName = gslbRule.getGslbDomain(); String lbMethod = gslbRule.getAlgorithm(); String persistenceMethod = gslbRule.getUuid(); 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 + String domainName = gslbRule.getGslbDomain(); String providerDnsName = _globalConfigDao.getValue(Config.CloudDnsName.name()); String gslbFqdn = domainName + providerDnsName; GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn, lbMethod, persistenceMethod, serviceType, 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); - if (gslbLbMapVos == null || gslbLbMapVos.isEmpty()) { - return; - } + 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()); @@ -500,8 +521,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType, ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart())); - siteLb.setGslbProviderPublicIp(null); - siteLb.setGslbProviderPrivateIp(null); + siteLb.setGslbProviderPublicIp(_gslbProvider.getProviderPublicIp(dataCenterId)); + siteLb.setGslbProviderPrivateIp(_gslbProvider.getProviderPrivateIp(dataCenterId)); zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb); } @@ -519,19 +540,23 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR } gslbConfigCmd.setSiteLoadBalancers(slbs); - - // get the host Id corresponding to GSLB service provider in the zone - long zoneGslbProviderHosId = 0; - - Answer answer = _agentMgr.easySend(zoneGslbProviderHosId, gslbConfigCmd); - if (answer == null) { - + 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) { - //TODO: check if zone is enabled for GSLB service - return true; + + if (_gslbProvider == null) { + throw new CloudRuntimeException("No GSLB provider is available"); + } + + return _gslbProvider.isServiceEnabledInZone(zoneId); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/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..416f187 --- /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 getProviderPublicIp(long zoneId); + + public String getProviderPrivateIp(long zoneId); + + public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand gslbConfigCmd) + throws ResourceUnavailableException; + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java ---------------------------------------------------------------------- diff --git a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java index 141cdb6..cea4fd9 100644 --- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java +++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java @@ -1,3 +1,18 @@ +// 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; @@ -12,6 +27,7 @@ import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.UserContext; import com.cloud.utils.db.Transaction; +import com.cloud.utils.net.Ip; import junit.framework.Assert; import junit.framework.TestCase; import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadBalancerRuleCmd; @@ -456,7 +472,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { try { gslbServiceImpl.createGlobalLoadBalancerRule(createCmd); } catch (InvalidParameterValueException e) { - Assert.assertTrue(e.getMessage().contains("Domain name is in use")); + Assert.assertTrue(e.getMessage().contains("Domain name " + "gslb-rule-domain" + "is in use")); } } @@ -498,6 +514,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { Field networkIdField = LoadBalancerVO.class.getSuperclass().getDeclaredField("networkId"); networkIdField.setAccessible(true); networkIdField.set(lbRule, new Long(1)); + Field sourceIpAddressId = LoadBalancerVO.class.getSuperclass().getDeclaredField("sourceIpAddressId"); + sourceIpAddressId.setAccessible(true); + sourceIpAddressId.set(lbRule, new Long(1)); when(gslbServiceImpl._lbDao.findById(new Long(1))).thenReturn(lbRule); Field lbRules = _class.getDeclaredField("loadBalancerRulesIds"); @@ -512,6 +531,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { dcID.set(networkVo, new Long(1)); when(gslbServiceImpl._networkDao.findById(new Long(1))).thenReturn(networkVo); + IPAddressVO ip = new IPAddressVO(new Ip("10.1.1.1"), 1, 1,1 ,true); + when(gslbServiceImpl._ipAddressDao.findById(new Long(1))).thenReturn(ip); + try { gslbServiceImpl.assignToGlobalLoadBalancerRule(assignCmd); } catch (Exception e) { @@ -668,6 +690,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { gslbServiceImpl._globalConfigDao = Mockito.mock(ConfigurationDao.class); gslbServiceImpl._ipAddressDao = Mockito.mock(IPAddressDao.class); gslbServiceImpl._agentMgr = Mockito.mock(AgentManager.class); + gslbServiceImpl._gslbProvider = Mockito.mock(GslbServiceProvider.class); RemoveFromGlobalLoadBalancerRuleCmd removeFromGslbCmd = new RemoveFromGlobalLoadBalancerRuleCmdExtn(); Class<?> _class = removeFromGslbCmd.getClass().getSuperclass(); @@ -692,6 +715,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { Field idField = LoadBalancerVO.class.getSuperclass().getDeclaredField("id"); idField.setAccessible(true); idField.set(lbRule, new Long(1)); + Field sourceIpAddressId = LoadBalancerVO.class.getSuperclass().getDeclaredField("sourceIpAddressId"); + sourceIpAddressId.setAccessible(true); + sourceIpAddressId.set(lbRule, new Long(1)); when(gslbServiceImpl._lbDao.findById(new Long(1))).thenReturn(lbRule); Field lbRules = _class.getDeclaredField("loadBalancerRulesIds"); @@ -713,6 +739,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { when(gslbServiceImpl._gslbLbMapDao.findByGslbRuleIdAndLbRuleId(new Long(1), new Long(1))).thenReturn(gslbLbMap); + IPAddressVO ip = new IPAddressVO(new Ip("10.1.1.1"), 1, 1,1 ,true); + when(gslbServiceImpl._ipAddressDao.findById(new Long(1))).thenReturn(ip); + gslbServiceImpl.removeFromGlobalLoadBalancerRule(removeFromGslbCmd); } @@ -856,7 +885,12 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase { "test-domain", "roundrobin", "sourceip", "tcp", 1, 1, 1, GlobalLoadBalancerRule.State.Active); when(gslbServiceImpl._gslbRuleDao.findById(new Long(1))).thenReturn(gslbRule); - when(gslbServiceImpl._gslbLbMapDao.listByGslbRuleId(new Long(1))).thenReturn(null); + GlobalLoadBalancerLbRuleMapVO gslbLbMap = new GlobalLoadBalancerLbRuleMapVO(); + gslbLbMap.setGslbLoadBalancerId(1); + gslbLbMap.setLoadBalancerId(1); + List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapList = new ArrayList<GlobalLoadBalancerLbRuleMapVO>(); + gslbLbMapList.add(gslbLbMap); + when(gslbServiceImpl._gslbLbMapDao.listByGslbRuleId(new Long(1))).thenReturn(gslbLbMapList); try { gslbServiceImpl.deleteGlobalLoadBalancerRule(deleteCmd); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89c33a01/setup/db/create-schema.sql ---------------------------------------------------------------------- diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 09fc2f8..04fc2dd 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -2131,6 +2131,7 @@ CREATE TABLE `cloud`.`external_load_balancer_devices` ( `allocation_state` varchar(32) NOT NULL DEFAULT 'Free' COMMENT 'Allocation state (Free/Shared/Dedicated/Provider) of the device', `is_dedicated` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance is provisioned for dedicated use only', `is_managed` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance is provisioned and its life cycle is managed by by cloudstack', + `is_gslb_provider` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance provides gslb service as well', `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external load balancer device', `parent_host_id` bigint unsigned COMMENT 'if the load balancer appliance is cloudstack managed, then host id on which this appliance is provisioned', PRIMARY KEY (`id`),
