diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index adc4190a3aa..cb2946331e4 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -844,4 +844,7 @@
+
+
+
diff --git a/server/src/com/cloud/deploy/PlannerHostReservationVO.java b/server/src/com/cloud/deploy/PlannerHostReservationVO.java
index 47e145739fa..cf5f03177f7 100644
--- a/server/src/com/cloud/deploy/PlannerHostReservationVO.java
+++ b/server/src/com/cloud/deploy/PlannerHostReservationVO.java
@@ -19,12 +19,16 @@ package com.cloud.deploy;
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;
import org.apache.cloudstack.api.InternalIdentity;
+import com.cloud.deploy.DeploymentPlanner.PlannerResourceUsage;
+
@Entity
@Table(name = "op_host_planner_reservation")
public class PlannerHostReservationVO implements InternalIdentity {
@@ -45,29 +49,27 @@ public class PlannerHostReservationVO implements InternalIdentity {
@Column(name="cluster_id")
private Long clusterId;
- @Column(name = "resource_type")
- private short resourceType;
-
- @Column(name = "domain_id")
- private long domainId;
-
- @Column(name = "account_id")
- private long accountId;
-
- @Column(name = "deployment_planner")
- private String deploymentPlanner;
+ @Column(name = "resource_usage")
+ @Enumerated(EnumType.STRING)
+ private PlannerResourceUsage resourceUsage;
public PlannerHostReservationVO() {
}
- public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId, short resourceType,
- String planner) {
+ public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId) {
this.hostId = hostId;
this.dataCenterId = dataCenterId;
this.podId = podId;
this.clusterId = clusterId;
- this.resourceType = resourceType;
- this.deploymentPlanner = planner;
+ }
+
+ public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId,
+ PlannerResourceUsage resourceUsage) {
+ this.hostId = hostId;
+ this.dataCenterId = dataCenterId;
+ this.podId = podId;
+ this.clusterId = clusterId;
+ this.resourceUsage = resourceUsage;
}
@Override
@@ -104,32 +106,12 @@ public class PlannerHostReservationVO implements InternalIdentity {
this.clusterId = new Long(clusterId);
}
- public short getResourceType() {
- return resourceType;
+ public PlannerResourceUsage getResourceUsage() {
+ return resourceUsage;
}
- public void setResourceType(short resourceType) {
- this.resourceType = resourceType;
- }
-
- public String getDeploymentPlanner() {
- return deploymentPlanner;
- }
-
- public long getDomainId() {
- return domainId;
- }
-
- public void setDomainId(long domainId) {
- this.domainId = domainId;
- }
-
- public long getAccountId() {
- return accountId;
- }
-
- public void setAccountId(long accountId) {
- this.accountId = accountId;
+ public void setResourceUsage(PlannerResourceUsage resourceType) {
+ this.resourceUsage = resourceType;
}
}
diff --git a/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java b/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
index 112af95cb2c..71e235da59d 100644
--- a/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
+++ b/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
@@ -21,4 +21,6 @@ import com.cloud.utils.db.GenericDao;
public interface PlannerHostReservationDao extends GenericDao {
+ PlannerHostReservationVO findByHostId(long hostId);
+
}
diff --git a/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java b/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
index ccda44b710b..7b120672a6c 100644
--- a/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
+++ b/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
@@ -16,12 +16,35 @@
// under the License.
package com.cloud.deploy.dao;
+import javax.annotation.PostConstruct;
import javax.ejb.Local;
import com.cloud.deploy.PlannerHostReservationVO;
import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
@Local(value = { PlannerHostReservationDao.class })
public class PlannerHostReservationDaoImpl extends GenericDaoBase implements
PlannerHostReservationDao {
+ private SearchBuilder _hostIdSearch;
+
+ public PlannerHostReservationDaoImpl() {
+
+ }
+
+ @PostConstruct
+ protected void init() {
+ _hostIdSearch = createSearchBuilder();
+ _hostIdSearch.and("hostId", _hostIdSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+ _hostIdSearch.done();
+ }
+
+ @Override
+ public PlannerHostReservationVO findByHostId(long hostId) {
+ SearchCriteria sc = _hostIdSearch.create();
+ sc.setParameters("hostId", hostId);
+ return findOneBy(sc);
+ }
+
}
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 3669384af69..131724ac9af 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -925,15 +925,10 @@ CREATE TABLE `cloud`.`op_host_planner_reservation` (
`pod_id` bigint unsigned,
`cluster_id` bigint unsigned,
`host_id` bigint unsigned,
- `account_id` bigint unsigned,
- `domain_id` bigint unsigned,
- `deployment_planner` varchar(255) COMMENT 'Name of the Planner',
- `resource_type` int(1) unsigned NOT NULL COMMENT 'shared(0) Vs dedicated(1)',
+ `resource_usage` varchar(255) COMMENT 'Shared(between planners) Vs Dedicated (exclusive usage to a planner)',
PRIMARY KEY (`id`),
INDEX `i_op_host_planner_reservation__host_type`(`host_id`, `resource_type`),
CONSTRAINT `fk_planner_reservation__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_planner_reservation__account_id` FOREIGN KEY `fk_resource_count__account_id`(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_planner_reservation__domain_id` FOREIGN KEY `fk_resource_count__domain_id`(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_planner_reservation__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_planner_reservation__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_planner_reservation__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE