Skip to content

Commit e7d468e

Browse files
author
Sateesh Chodapuneedi
committed
CLOUDSTACK-2029 zone wide primary storage support for cloudstack over vmware deployments
DB changes to support hypervisor specific zone wide storage pool. Added method findZoneWideStoragePoolsByHypervisor to PrimaryStorageDaoImpl to find suitable zone wide storage pool of specific hypervisor type. Added column 'hypervisor' to table storage_pool. This column can be NULL. Used/populated only for zone wide primary storage pools. Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>
1 parent 2705f01 commit e7d468e

5 files changed

Lines changed: 55 additions & 7 deletions

File tree

engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
2424

25+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2526
import com.cloud.storage.StoragePoolStatus;
2627
import com.cloud.utils.db.GenericDao;
2728
/**
@@ -109,4 +110,6 @@ List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId,
109110
Long clusterId, String[] tags);
110111

111112
List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags);
113+
114+
List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType);
112115
}

engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.stereotype.Component;
3333

3434
import com.cloud.host.Status;
35+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
3536

3637
import com.cloud.storage.StoragePoolStatus;
3738

@@ -427,4 +428,14 @@ public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
427428

428429
return listBy(sc);
429430
}
431+
432+
@Override
433+
public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
434+
SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc = SearchCriteria2.create(StoragePoolVO.class);
435+
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
436+
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
437+
sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
438+
sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
439+
return sc.list();
440+
}
430441
}

engine/api/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
3333

34+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
3435
import com.cloud.storage.Storage.StoragePoolType;
3536
import com.cloud.storage.StoragePool;
3637
import com.cloud.storage.StoragePoolStatus;
@@ -102,6 +103,10 @@ public class StoragePoolVO implements StoragePool{
102103
@Enumerated(value = EnumType.STRING)
103104
private ScopeType scope;
104105

106+
@Column(name = "hypervisor")
107+
@Enumerated(value = EnumType.STRING)
108+
private HypervisorType hypervisor;
109+
105110
public long getId() {
106111
return id;
107112
}
@@ -276,6 +281,14 @@ public ScopeType getScope() {
276281
return this.scope;
277282
}
278283

284+
public HypervisorType getHypervisor() {
285+
return hypervisor;
286+
}
287+
288+
public void setHypervisor(HypervisorType hypervisor) {
289+
this.hypervisor = hypervisor;
290+
}
291+
279292
@Override
280293
public boolean equals(Object obj) {
281294
if (!(obj instanceof StoragePoolVO) || obj == null) {

server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
8585
poolResponse.setPodName(pool.getPodName());
8686
poolResponse.setCreated(pool.getCreated());
8787
poolResponse.setScope(pool.getScope().toString());
88+
if (pool.getHypervisor() != null) {
89+
poolResponse.setHypervisor(pool.getHypervisor().toString());
90+
}
8891

8992

9093
long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
@@ -143,6 +146,9 @@ public StoragePoolForMigrationResponse newStoragePoolForMigrationResponse(Storag
143146
poolResponse.setPodName(pool.getPodName());
144147
poolResponse.setCreated(pool.getCreated());
145148
poolResponse.setScope(pool.getScope().toString());
149+
if (pool.getHypervisor() != null) {
150+
poolResponse.setHypervisor(pool.getHypervisor().toString());
151+
}
146152

147153

148154
long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();

server/src/com/cloud/api/query/vo/StoragePoolJoinVO.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@
2424
import javax.persistence.Enumerated;
2525
import javax.persistence.Id;
2626
import javax.persistence.Table;
27-
import com.cloud.org.Cluster;
28-
import com.cloud.storage.StoragePoolStatus;
29-
import com.cloud.storage.Storage.StoragePoolType;
30-
import com.cloud.utils.db.GenericDao;
3127

3228
import org.apache.cloudstack.api.Identity;
3329
import org.apache.cloudstack.api.InternalIdentity;
3430
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
3531

32+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
33+
import com.cloud.org.Cluster;
34+
import com.cloud.storage.Storage.StoragePoolType;
35+
import com.cloud.storage.StoragePoolStatus;
36+
import com.cloud.utils.db.GenericDao;
37+
3638
/**
3739
* Storage Pool DB view.
3840
*
@@ -99,7 +101,7 @@ public class StoragePoolJoinVO extends BaseViewVO implements InternalIdentity, I
99101

100102
@Column(name="data_center_type")
101103
private String zoneType;
102-
104+
103105
@Column(name="pod_id")
104106
private long podId;
105107

@@ -128,11 +130,16 @@ public class StoragePoolJoinVO extends BaseViewVO implements InternalIdentity, I
128130

129131
@Column(name="job_status")
130132
private int jobStatus;
131-
133+
132134
@Column(name = "scope")
133135
@Enumerated(value = EnumType.STRING)
134136
private ScopeType scope;
135137

138+
139+
@Column(name = "hypervisor")
140+
@Enumerated(value = EnumType.STRING)
141+
private HypervisorType hypervisor;
142+
136143
/**
137144
* @return the scope
138145
*/
@@ -147,6 +154,14 @@ public void setScope(ScopeType scope) {
147154
this.scope = scope;
148155
}
149156

157+
public HypervisorType getHypervisor() {
158+
return hypervisor;
159+
}
160+
161+
public void setHypervisor(HypervisorType hypervisor) {
162+
this.hypervisor = hypervisor;
163+
}
164+
150165
@Override
151166
public long getId() {
152167
return id;
@@ -293,7 +308,7 @@ public String getZoneType() {
293308
public void setZoneType(String zoneType) {
294309
this.zoneType = zoneType;
295310
}
296-
311+
297312
public long getPodId() {
298313
return podId;
299314
}

0 commit comments

Comments
 (0)