cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [38/50] [abbrv] git commit: updated refs/heads/planner_reserve to 9b86516
Date Sun, 05 May 2013 08:00:03 GMT
Planner choice in ServiceOffering and Planners using the ServiceOffering in canHandle()

Also removed the DeployPlannerSelector.class adapter
Added an upgrade mechanism for 410to420


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

Branch: refs/heads/planner_reserve
Commit: 93277e864761eacb2023f2d29890791b9fbb5c62
Parents: 870d21c
Author: Prachi Damle <prachi@cloud.com>
Authored: Wed Apr 17 12:02:32 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Sat May 4 22:53:30 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/offering/ServiceOffering.java    |    2 +
 client/tomcatconf/applicationContext.xml.in        |   20 +---
 .../cloud/deploy/UserConcentratedPodPlanner.java   |   12 --
 .../com/cloud/deploy/UserDispersingPlanner.java    |   12 --
 .../manager/BaremetalPlannerSelector.java          |   39 -------
 .../deploy/AbstractDeployPlannerSelector.java      |   84 ---------------
 .../com/cloud/deploy/DeployPlannerSelector.java    |   24 ----
 server/src/com/cloud/deploy/FirstFitPlanner.java   |    7 +-
 .../cloud/deploy/HypervisorVmPlannerSelector.java  |   54 ---------
 .../com/cloud/migration/ServiceOffering21VO.java   |    5 +
 .../src/com/cloud/service/ServiceOfferingVO.java   |    5 +
 .../src/com/cloud/upgrade/dao/Upgrade410to420.java |   67 ++++++++++--
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   13 +--
 13 files changed, 81 insertions(+), 263 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/api/src/com/cloud/offering/ServiceOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java
index d6c215f..1fd6214 100755
--- a/api/src/com/cloud/offering/ServiceOffering.java
+++ b/api/src/com/cloud/offering/ServiceOffering.java
@@ -107,4 +107,6 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
     boolean getDefaultUse();
 
     String getSystemVmType();
+
+    String getDeploymentPlanner();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 2e340bf..adc4190 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -531,15 +531,11 @@
     Deployment planners
   -->
   <bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
-    <property name="name" value="UserDispersing"/>
-	<property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
-    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+    <property name="name" value="UserDispersingPlanner"/>
   </bean>
   
   <bean id="UserConcentratedPodPlanner" class="com.cloud.deploy.UserConcentratedPodPlanner">
-    <property name="name" value="UserConcentratedPod"/>
-	<property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
-    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+    <property name="name" value="UserConcentratedPodPlanner"/>
   </bean>
 
   <bean id="clusterBasedAgentLoadBalancerPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner">
@@ -596,10 +592,6 @@
     <property name="name" value="OvmGuru"/>
   </bean>
   
-  <bean id="HypervisorPlannerSelector" class="com.cloud.deploy.HypervisorVmPlannerSelector">
-    <property name="name" value="HypervisorPlannerSelector"/>
-  </bean>
-
   <!--
     Managers
   -->
@@ -621,7 +613,7 @@
   </bean>
 
   <bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
-    <property name="name" value="First Fit"/>
+    <property name="name" value="FirstFitPlanner"/>
     <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
     <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
   </bean>
@@ -821,17 +813,13 @@
   </bean>
 
   <bean id="BareMetalPlanner" class="com.cloud.baremetal.manager.BareMetalPlanner">
-    <property name="name" value="BareMetal Fit"/>
+    <property name="name" value="BareMetalPlanner"/>
   </bean>
   
   <bean id="BaremetalGuru" class="com.cloud.baremetal.manager.BareMetalGuru">
     <property name="name" value="BaremetalGuru"/>
   </bean>
 
-  <bean id="BaremetalPlannerSelector" class="com.cloud.baremetal.manager.BaremetalPlannerSelector">
-    <property name="name" value="BaremetalPlannerSelector"/>
-  </bean>
-
   <bean id="BaremetalManager" class="com.cloud.baremetal.manager.BaremetalManagerImpl"/>
   <bean id="BaremetalDhcpManager" class="com.cloud.baremetal.networkservice.BaremetalDhcpManagerImpl"/>
   <bean id="BaremetalKickStartPxeService" class="com.cloud.baremetal.networkservice.BaremetalKickStartServiceImpl"/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
index 2ab9856..57d2bc4 100644
--- a/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
+++ b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java
@@ -24,7 +24,6 @@ import javax.ejb.Local;
 
 import org.apache.log4j.Logger;
 
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
@@ -141,15 +140,4 @@ public class UserConcentratedPodPlanner extends FirstFitPlanner implements
Deplo
         
     }
 
-    @Override
-    public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
-        if(vm.getHypervisorType() != HypervisorType.BareMetal){
-            //check the allocation strategy
-            if (_allocationAlgorithm != null && (_allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_random.toString())
|| _allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_firstfit.toString()))){
-                return true;
-            }
-        }
-        return false;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
----------------------------------------------------------------------
diff --git a/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
b/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
index 2db2051..5bdaa71 100755
--- a/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
+++ b/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java
@@ -29,7 +29,6 @@ import javax.naming.ConfigurationException;
 import org.apache.log4j.Logger;
 
 import com.cloud.configuration.Config;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine;
@@ -191,17 +190,6 @@ public class UserDispersingPlanner extends FirstFitPlanner implements
Deployment
     }
     
 
-    @Override
-    public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
-        if(vm.getHypervisorType() != HypervisorType.BareMetal){
-            //check the allocation strategy
-            if (_allocationAlgorithm != null && _allocationAlgorithm.equals(AllocationAlgorithm.userdispersing.toString()))
{
-                return true;
-            }
-        }
-        return false;
-    }
-    
     float _userDispersionWeight;
 
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java
deleted file mode 100755
index 45fbeb7..0000000
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalPlannerSelector.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.baremetal.manager;
-
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import com.cloud.deploy.AbstractDeployPlannerSelector;
-import com.cloud.deploy.DeployPlannerSelector;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.vm.UserVmVO;
-@Local(value = {DeployPlannerSelector.class})
-public class BaremetalPlannerSelector extends AbstractDeployPlannerSelector{
-
-    @Override
-    public String selectPlanner(UserVmVO vm) {
-        if (vm.getHypervisorType() == HypervisorType.BareMetal) {
-            return "BareMetalPlanner";
-        }
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java b/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java
deleted file mode 100755
index 7665687..0000000
--- a/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.deploy;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import com.cloud.configuration.Config;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.UserVmVO;
-
-public abstract class AbstractDeployPlannerSelector extends AdapterBase implements DeployPlannerSelector
{
-    protected Map<String, Object>  params;
-    protected String name;
-    protected int runLevel;
-
-    @Inject
-    protected ConfigurationDao _configDao;
-    protected String _allocationAlgorithm = "random";
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Override
-    public void setConfigParams(Map<String, Object> params) {
-        this.params = params;
-    }
-
-    @Override
-    public Map<String, Object> getConfigParams() {
-        return params;
-    }
-
-    @Override
-    public int getRunLevel() {
-        return runLevel;
-    }
-
-    @Override
-    public void setRunLevel(int level) {
-        this.runLevel = level;
-    }
-
-    @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
-        super.configure(name, params);
-        _allocationAlgorithm = _configDao.getValue(Config.VmAllocationAlgorithm.key());
-        return true;
-    }
-
-    @Override
-    public boolean start() {
-        return true;
-    }
-
-    @Override
-    public boolean stop() {
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/deploy/DeployPlannerSelector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeployPlannerSelector.java b/server/src/com/cloud/deploy/DeployPlannerSelector.java
deleted file mode 100755
index 062b492..0000000
--- a/server/src/com/cloud/deploy/DeployPlannerSelector.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.deploy;
-
-import com.cloud.utils.component.Adapter;
-import com.cloud.vm.UserVmVO;
-
-public interface DeployPlannerSelector extends Adapter {
-    String selectPlanner(UserVmVO vm);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/deploy/FirstFitPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java
index e8504a9..65f285b 100755
--- a/server/src/com/cloud/deploy/FirstFitPlanner.java
+++ b/server/src/com/cloud/deploy/FirstFitPlanner.java
@@ -859,9 +859,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner
{
 
     @Override
     public boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan
plan, ExcludeList avoid) {
-        if(vm.getHypervisorType() != HypervisorType.BareMetal){
-            //check the allocation strategy
-            if (_allocationAlgorithm != null && (_allocationAlgorithm.equals(AllocationAlgorithm.random.toString())
|| _allocationAlgorithm.equals(AllocationAlgorithm.firstfit.toString()))) {
+        // check what the ServiceOffering says
+        ServiceOffering offering = vm.getServiceOffering();
+        if (offering != null && offering.getDeploymentPlanner() != null) {
+            if (offering.getDeploymentPlanner().equals(this.getName())) {
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java b/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
deleted file mode 100755
index ce49405..0000000
--- a/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.deploy;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.deploy.DeploymentPlanner.AllocationAlgorithm;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.vm.UserVmVO;
-
-@Local(value = {DeployPlannerSelector.class})
-public class HypervisorVmPlannerSelector extends AbstractDeployPlannerSelector {
-    private static final Logger s_logger = Logger.getLogger(HypervisorVmPlannerSelector.class);
-
-    @Override
-    public String selectPlanner(UserVmVO vm) {
-        if (vm.getHypervisorType() != HypervisorType.BareMetal) {
-            //check the allocation strategy
-            if (_allocationAlgorithm != null) {
-                if (_allocationAlgorithm.equals(AllocationAlgorithm.random.toString())
-                        || _allocationAlgorithm.equals(AllocationAlgorithm.firstfit.toString()))
{
-                    return "FirstFitPlanner";
-                } else if (_allocationAlgorithm.equals(AllocationAlgorithm.userdispersing.toString()))
{
-                    return "UserDispersingPlanner";
-                } else if (_allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_random.toString())
-                        || _allocationAlgorithm.equals(AllocationAlgorithm.userconcentratedpod_firstfit.toString()))
{
-                    return "UserConcentratedPodPlanner";
-                }
-            } else {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("The allocation algorithm is null, cannot select the planner");
-                }
-            }
-        }
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/migration/ServiceOffering21VO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/migration/ServiceOffering21VO.java b/server/src/com/cloud/migration/ServiceOffering21VO.java
index d07be64..7a49e63 100644
--- a/server/src/com/cloud/migration/ServiceOffering21VO.java
+++ b/server/src/com/cloud/migration/ServiceOffering21VO.java
@@ -174,5 +174,10 @@ public class ServiceOffering21VO extends DiskOffering21VO implements
ServiceOffe
         return false;
     }
 
+    @Override
+    public String getDeploymentPlanner() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/service/ServiceOfferingVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/service/ServiceOfferingVO.java b/server/src/com/cloud/service/ServiceOfferingVO.java
index 94a7351..1a2ef5e 100755
--- a/server/src/com/cloud/service/ServiceOfferingVO.java
+++ b/server/src/com/cloud/service/ServiceOfferingVO.java
@@ -208,4 +208,9 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
         return volatileVm;
     }
 
+    @Override
+    public String getDeploymentPlanner() {
+        return deploymentPlanner;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 05e2b49..2f0c2d3 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -17,6 +17,7 @@
 
 package com.cloud.upgrade.dao;
 
+import com.cloud.deploy.DeploymentPlanner;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;
 import org.apache.log4j.Logger;
@@ -66,9 +67,10 @@ public class Upgrade410to420 implements DbUpgrade {
         updatePrimaryStore(conn);
         addEgressFwRulesForSRXGuestNw(conn);
         upgradeEIPNetworkOfferings(conn);
+        updateServiceOfferingDeploymentPlanner(conn);
     }
-	
-	private void updateSystemVmTemplates(Connection conn) {
+
+    private void updateSystemVmTemplates(Connection conn) {
 	    PreparedStatement sql = null;
         try {
             sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where
type = 'SYSTEM' or type = 'BUILTIN'");
@@ -84,7 +86,7 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
 	}
-	
+
 	private void updatePrimaryStore(Connection conn) {
 	    PreparedStatement sql = null;
 	    PreparedStatement sql2 = null;
@@ -93,7 +95,7 @@ public class Upgrade410to420 implements DbUpgrade {
             sql.setString(1, "ancient primary data store provider");
             sql.setString(2, "HOST");
             sql.executeUpdate();
-            
+
             sql2 = conn.prepareStatement("update storage_pool set storage_provider_name =
? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");
             sql2.setString(1, "ancient primary data store provider");
             sql2.setString(2, "CLUSTER");
@@ -107,7 +109,7 @@ public class Upgrade410to420 implements DbUpgrade {
                 } catch (SQLException e) {
                 }
             }
-            
+
             if (sql2 != null) {
                 try {
                     sql2.close();
@@ -235,7 +237,7 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
     }
-    
+
     private void createPlaceHolderNics(Connection conn) {
         PreparedStatement pstmt = null;
         ResultSet rs = null;
@@ -256,7 +258,7 @@ public class Upgrade410to420 implements DbUpgrade {
                     pstmt.setLong(4, networkId);
                     pstmt.executeUpdate();
                     s_logger.debug("Created placeholder nic for the ipAddress " + ip);
-                
+
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to create placeholder nics", e);
@@ -272,8 +274,8 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
     }
-    
-    
+
+
     private void updateRemoteAccessVpn(Connection conn) {
         PreparedStatement pstmt = null;
         ResultSet rs = null;
@@ -399,4 +401,51 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
     }
+
+    private void updateServiceOfferingDeploymentPlanner(Connection conn) {
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
+
+        try {
+            pstmt = conn
+                    .prepareStatement("select value from `cloud`.`configuration` where name
= 'vm.allocation.algorithm'");
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                String globalValue = rs.getString(1);
+                String plannerName = "FirstFitPlanner";
+
+                if (globalValue != null) {
+                    if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.random.toString()))
{
+                        plannerName = "FirstFitPlanner";
+                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.firstfit.toString()))
{
+                        plannerName = "FirstFitPlanner";
+                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_firstfit
+                            .toString())) {
+                        plannerName = "UserConcentratedPodPlanner";
+                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_random
+                            .toString())) {
+                        plannerName = "UserConcentratedPodPlanner";
+                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userdispersing.toString()))
{
+                        plannerName = "UserDispersingPlanner";
+                    }
+                }
+                // update service offering with the planner name
+                pstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` set deployment_planner=?");
+                pstmt.setString(1, plannerName);
+                pstmt.executeUpdate();
+            }
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable to set deployment_planner for service
offerings", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93277e86/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index bc25bed..af2eb77 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3067,16 +3067,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
 
         VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
 
-        String plannerName = null;
-        for (DeployPlannerSelector dps : plannerSelectors) {
-            plannerName = dps.selectPlanner(vm);
-            if (plannerName != null) {
-                break;
-            }
-        }
-        if (plannerName == null) {
-            throw new CloudRuntimeException(String.format("cannot find DeployPlannerSelector
for vm[uuid:%s, hypervisorType:%s]", vm.getUuid(), vm.getHypervisorType()));
-        }
+        // Get serviceOffering for Virtual Machine
+        ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getServiceOfferingId());
+        String plannerName = offering.getDeploymentPlanner();
 
         String reservationId = vmEntity.reserve(plannerName, plan, new ExcludeList(), new
Long(callerUser.getId()).toString());
         vmEntity.deploy(reservationId, new Long(callerUser.getId()).toString(), params);


Mime
View raw message