cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [47/50] [abbrv] git commit: updated refs/heads/CLOUDSTACK-8301 to 8ff9000
Date Tue, 19 May 2015 16:21:33 GMT
CLOUDSTACK-8301: Enable configuring local storage use for system VMs at zone level
Code cleanup, added helper method to get default system offering based on "system.vm.use.local.storage".


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

Branch: refs/heads/CLOUDSTACK-8301
Commit: d423df66cc73c47d363736b7762e820d85f05b93
Parents: 3f7e31e
Author: Koushik Das <koushik@apache.org>
Authored: Thu May 14 17:30:19 2015 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Tue May 19 21:32:14 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/service/dao/ServiceOfferingDao.java    |  2 ++
 .../cloud/service/dao/ServiceOfferingDaoImpl.java    | 15 +++++++++++++++
 .../com/cloud/network/lb/LoadBalanceRuleHandler.java | 12 +-----------
 .../lb/InternalLoadBalancerVMManagerImpl.java        | 12 +-----------
 .../cloud/consoleproxy/ConsoleProxyManagerImpl.java  | 12 +-----------
 .../deployment/RouterDeploymentDefinition.java       | 10 +---------
 .../deployment/RouterDeploymentDefinitionTest.java   |  2 +-
 .../VpcRouterDeploymentDefinitionTest.java           |  2 +-
 .../SecondaryStorageManagerImpl.java                 | 12 +-----------
 9 files changed, 24 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
index 98dc317..aae61a1 100644
--- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDao.java
@@ -55,4 +55,6 @@ public interface ServiceOfferingDao extends GenericDao<ServiceOfferingVO,
Long>
     boolean isDynamic(long serviceOfferingId);
 
     ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, Map<String,
String> customParameters);
+
+    ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
index a3ffbc1..4a5a8b5 100644
--- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java
@@ -276,4 +276,19 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO,
Lo
 
         return list;
     }
+
+    @Override
+    public ServiceOfferingVO findDefaultSystemOffering(String offeringName, Boolean useLocalStorage)
{
+        String name = offeringName;
+        if (useLocalStorage != null && useLocalStorage.booleanValue()) {
+            name += "-Local";
+        }
+        ServiceOfferingVO serviceOffering = findByName(name);
+        if (serviceOffering == null) {
+            String message = "System service offering " + name + " not found";
+            s_logger.error(message);
+            throw new CloudRuntimeException(message);
+        }
+        return serviceOffering;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java
b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java
index f2c4685..e90af37 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/LoadBalanceRuleHandler.java
@@ -282,17 +282,7 @@ public class LoadBalanceRuleHandler {
                     userId =  _userDao.listByAccount(owner.getAccountId()).get(0).getId();
                 }
 
-                String offeringName = ServiceOffering.elbVmDefaultOffUniqueName;
-                Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
-                if (useLocalStorage != null && useLocalStorage.booleanValue()) {
-                    offeringName += "-Local";
-                }
-                ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findByName(offeringName);
-                if (elasticLbVmOffering == null) {
-                    String message = "System service offering " + offeringName + " not found";
-                    s_logger.error(message);
-                    throw new CloudRuntimeException(message);
-                }
+                ServiceOfferingVO elasticLbVmOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.elbVmDefaultOffUniqueName,
ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
                 elbVm = new DomainRouterVO(id, elasticLbVmOffering.getId(), vrProvider.getId(),
VirtualMachineName.getSystemVmName(id, _instance, ELB_VM_NAME_PREFIX),
                         template.getId(), template.getHypervisorType(), template.getGuestOSId(),
owner.getDomainId(), owner.getId(), userId, false, RedundantState.UNKNOWN,
                         elasticLbVmOffering.getOfferHA(), false, null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index 818ad88..4bd852d 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -623,17 +623,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
In
             final LinkedHashMap<Network, List<? extends NicProfile>> networks
= createInternalLbVmNetworks(guestNetwork, plan, requestedGuestIp);
             long internalLbVmOfferingId = _internalLbVmOfferingId;
             if (internalLbVmOfferingId == 0L) {
-                String offeringName = ServiceOffering.internalLbVmDefaultOffUniqueName;
-                Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
-                if (useLocalStorage != null && useLocalStorage.booleanValue()) {
-                    offeringName += "-Local";
-                }
-                ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(offeringName);
-                if (serviceOffering == null) {
-                    String message = "System service offering " + offeringName + " not found";
-                    s_logger.error(message);
-                    throw new CloudRuntimeException(message);
-                }
+                ServiceOfferingVO serviceOffering = _serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.internalLbVmDefaultOffUniqueName,
ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
                 internalLbVmOfferingId = serviceOffering.getId();
             }
             //Pass startVm=false as we are holding the network lock that needs to be released
at the end of vm allocation

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index f8d7474..476cc8e 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -718,17 +718,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
 
         ServiceOfferingVO serviceOffering = _serviceOffering;
         if (serviceOffering == null) {
-            String offeringName = ServiceOffering.consoleProxyDefaultOffUniqueName;
-            Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
-            if (useLocalStorage != null && useLocalStorage.booleanValue()) {
-                offeringName += "-Local";
-            }
-            serviceOffering = _offeringDao.findByName(offeringName);
-            if (serviceOffering == null) {
-                String message = "System service offering " + offeringName + " not found";
-                s_logger.error(message);
-                throw new CloudRuntimeException(message);
-            }
+            serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.consoleProxyDefaultOffUniqueName,
ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
         }
         ConsoleProxyVO proxy =
             new ConsoleProxyVO(id, serviceOffering.getId(), name, template.getId(), template.getHypervisorType(),
template.getGuestOSId(), dataCenterId,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
----------------------------------------------------------------------
diff --git a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
index 569200c..2d04a7e 100644
--- a/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
+++ b/server/src/org/cloud/network/router/deployment/RouterDeploymentDefinition.java
@@ -360,15 +360,7 @@ public class RouterDeploymentDefinition {
     }
 
     protected void findDefaultServiceOfferingId() {
-        String offeringName = ServiceOffering.routerDefaultOffUniqueName;
-        Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
-        if (useLocalStorage != null && useLocalStorage.booleanValue()) {
-            offeringName += "-Local";
-        }
-        ServiceOfferingVO serviceOffering = serviceOfferingDao.findByName(offeringName);
-        if (serviceOffering == null) {
-            throw new CloudRuntimeException("System service offering " + offeringName + "
not found");
-        }
+        ServiceOfferingVO serviceOffering = serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.routerDefaultOffUniqueName,
ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId()));
         serviceOfferingId = serviceOffering.getId();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
index b266f88..1570a2e 100644
--- a/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
+++ b/server/test/org/cloud/network/router/deployment/RouterDeploymentDefinitionTest.java
@@ -658,7 +658,7 @@ public class RouterDeploymentDefinitionTest extends RouterDeploymentDefinitionTe
         when(mockNw.getNetworkOfferingId()).thenReturn(OFFERING_ID);
         when(mockNetworkOfferingDao.findById(OFFERING_ID)).thenReturn(mockNwOfferingVO);
         when(mockNwOfferingVO.getServiceOfferingId()).thenReturn(null);
-        when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO);
+        when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO);
         when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
 
         // Execute

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
index 5a34ebf..13c20ae 100644
--- a/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
+++ b/server/test/org/cloud/network/router/deployment/VpcRouterDeploymentDefinitionTest.java
@@ -184,7 +184,7 @@ public class VpcRouterDeploymentDefinitionTest extends RouterDeploymentDefinitio
         final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class);
         when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering);
         when(vpcOffering.getServiceOfferingId()).thenReturn(null);
-        when(mockServiceOfferingDao.findByName(Matchers.anyString())).thenReturn(mockSvcOfferingVO);
+        when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO);
         when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID);
 
         // Execute

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d423df66/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 445852d..453a4cb 100644
--- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -578,17 +578,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements
Secondar
 
         ServiceOfferingVO serviceOffering = _serviceOffering;
         if (serviceOffering == null) {
-            String offeringName = ServiceOffering.ssvmDefaultOffUniqueName;
-            Boolean useLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId);
-            if (useLocalStorage != null && useLocalStorage.booleanValue()) {
-                offeringName += "-Local";
-            }
-            serviceOffering = _offeringDao.findByName(offeringName);
-            if (serviceOffering == null) {
-                String message = "System service offering " + offeringName + " not found";
-                s_logger.error(message);
-                throw new CloudRuntimeException(message);
-            }
+            serviceOffering = _offeringDao.findDefaultSystemOffering(ServiceOffering.ssvmDefaultOffUniqueName,
ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dataCenterId));
         }
         SecondaryStorageVmVO secStorageVm =
             new SecondaryStorageVmVO(id, serviceOffering.getId(), name, template.getId(),
template.getHypervisorType(), template.getGuestOSId(), dataCenterId,


Mime
View raw message