diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java
index d6c215f42f0..1fd6214e348 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();
}
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 2e340bfbfab..adc4190a3aa 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -531,15 +531,11 @@
Deployment planners
-->
-
-
-
+
-
-
-
+
@@ -596,10 +592,6 @@
-
-
-
-
@@ -621,7 +613,7 @@
-
+
@@ -821,17 +813,13 @@
-
+
-
-
-
-
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 2ab98566e0a..57d2bc4c694 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;
- }
-
}
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 2db2051389d..5bdaa719b3c 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;
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 45fbeb782ab..00000000000
--- 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;
- }
-
-}
diff --git a/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java b/server/src/com/cloud/deploy/AbstractDeployPlannerSelector.java
deleted file mode 100755
index 7665687be60..00000000000
--- 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 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 params) {
- this.params = params;
- }
-
- @Override
- public Map 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 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;
- }
-}
diff --git a/server/src/com/cloud/deploy/DeployPlannerSelector.java b/server/src/com/cloud/deploy/DeployPlannerSelector.java
deleted file mode 100755
index 062b492d8fc..00000000000
--- 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);
-}
diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java
index e8504a991c1..65f285bbfaf 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;
}
}
diff --git a/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java b/server/src/com/cloud/deploy/HypervisorVmPlannerSelector.java
deleted file mode 100755
index ce494051376..00000000000
--- 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;
- }
-}
diff --git a/server/src/com/cloud/migration/ServiceOffering21VO.java b/server/src/com/cloud/migration/ServiceOffering21VO.java
index d07be6462f1..7a49e63e5b3 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;
+ }
}
diff --git a/server/src/com/cloud/service/ServiceOfferingVO.java b/server/src/com/cloud/service/ServiceOfferingVO.java
index 94a73515e6a..1a2ef5e734e 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;
+ }
+
}
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 05e2b49ffe4..2f0c2d3cd56 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) {
+ }
+ }
+ }
}
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index bc25bedde45..af2eb776c0a 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);