Skip to content

Commit 572fc11

Browse files
[PowerFlex] Add & Remove PowerFlex/ScaleIO MDMs for the storage SDC connections (#9903)
* Add & Remove PowerFlex/ScaleIO MDMs while preparing & unpreparing the storage SDC connections (instead of start & stop scini) * Add/Remove MDM IP addresses during Host connection/disconnection to/from storage pool when powerflex.connect.on.demand is false * unit test fixes * Don't remove MDM IPs from SDC when any volumes mapped to SDC * Don't remove MDM IPs when other pools of same ScaleIO/PowerFlex cluster are connected * rebase fixes * update changes, to not remove/disconnect MDMs on maintenance * import fixes after rebase
1 parent 64828f6 commit 572fc11

File tree

33 files changed

+767
-176
lines changed

33 files changed

+767
-176
lines changed

core/src/main/java/com/cloud/agent/api/ModifyStoragePoolAnswer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes,
4646
templateInfo = tInfo;
4747
}
4848

49+
public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, boolean success, String details) {
50+
super(cmd, success, details);
51+
}
52+
4953
public void setPoolInfo(StoragePoolInfo poolInfo) {
5054
this.poolInfo = poolInfo;
5155
}

core/src/main/java/com/cloud/agent/api/UnprepareStorageClientCommand.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@
1919

2020
package com.cloud.agent.api;
2121

22+
import java.util.Map;
23+
2224
import com.cloud.storage.Storage.StoragePoolType;
2325

2426
public class UnprepareStorageClientCommand extends Command {
2527
private StoragePoolType poolType;
2628
private String poolUuid;
29+
private Map<String, String> details;
2730

2831
public UnprepareStorageClientCommand() {
2932
}
3033

31-
public UnprepareStorageClientCommand(StoragePoolType poolType, String poolUuid) {
34+
public UnprepareStorageClientCommand(StoragePoolType poolType, String poolUuid, Map<String, String> details) {
3235
this.poolType = poolType;
3336
this.poolUuid = poolUuid;
37+
this.details = details;
3438
}
3539

3640
@Override
@@ -45,4 +49,8 @@ public StoragePoolType getPoolType() {
4549
public String getPoolUuid() {
4650
return poolUuid;
4751
}
52+
53+
public Map<String, String> getDetails() {
54+
return details;
55+
}
4856
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public interface DataStoreDriver {
4545
boolean canCopy(DataObject srcData, DataObject destData);
4646

4747
void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
48+
49+
default boolean canDisplayDetails() {
50+
return true;
51+
}
4852
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ default boolean canHostPrepareStoragePoolAccess(Host host, StoragePool pool) {
145145
return false;
146146
}
147147

148+
/**
149+
* intended for managed storage
150+
* returns true if the host can be disconnected from storage pool
151+
*/
152+
default boolean canDisconnectHostFromStoragePool(Host host, StoragePool pool) {
153+
return true;
154+
}
155+
148156
/**
149157
* Used by storage pools which want to keep VMs' information
150158
* @return true if additional VM info is needed (intended for storage pools).

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ static Boolean getFullCloneConfiguration(Long storeId) {
314314

315315
boolean canHostPrepareStoragePoolAccess(Host host, StoragePool pool);
316316

317+
boolean canDisconnectHostFromStoragePool(Host host, StoragePool pool);
318+
317319
Host getHost(long hostId);
318320

319321
Host updateSecondaryStorage(long secStorageId, String newUrl);

engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface StoragePoolHostDao extends GenericDao<StoragePoolHostVO, Long>
3030

3131
public StoragePoolHostVO findByPoolHost(long poolId, long hostId);
3232

33+
List<StoragePoolHostVO> findByLocalPath(String path);
34+
3335
List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus);
3436

3537
List<Long> findHostsConnectedToPools(List<Long> poolIds);

engine/schema/src/main/java/com/cloud/storage/dao/StoragePoolHostDaoImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo
4545
protected final SearchBuilder<StoragePoolHostVO> PoolSearch;
4646
protected final SearchBuilder<StoragePoolHostVO> HostSearch;
4747
protected final SearchBuilder<StoragePoolHostVO> PoolHostSearch;
48+
protected final SearchBuilder<StoragePoolHostVO> LocalPathSearch;
4849

4950
protected SearchBuilder<StoragePoolHostVO> poolNotInClusterSearch;
5051

@@ -77,6 +78,9 @@ public StoragePoolHostDaoImpl() {
7778
PoolHostSearch.and("host_id", PoolHostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
7879
PoolHostSearch.done();
7980

81+
LocalPathSearch = createSearchBuilder();
82+
LocalPathSearch.and("local_path", LocalPathSearch.entity().getLocalPath(), SearchCriteria.Op.EQ);
83+
LocalPathSearch.done();
8084
}
8185

8286
@PostConstruct
@@ -117,6 +121,13 @@ public StoragePoolHostVO findByPoolHost(long poolId, long hostId) {
117121
return findOneIncludingRemovedBy(sc);
118122
}
119123

124+
@Override
125+
public List<StoragePoolHostVO> findByLocalPath(String path) {
126+
SearchCriteria<StoragePoolHostVO> sc = LocalPathSearch.create();
127+
sc.setParameters("local_path", path);
128+
return listBy(sc);
129+
}
130+
120131
@Override
121132
public List<StoragePoolHostVO> listByHostStatus(long poolId, Status hostStatus) {
122133
TransactionLegacy txn = TransactionLegacy.currentTxn();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
6060

6161
StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details, List<String> tags, Boolean isTagARule);
6262

63+
StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details, List<String> tags, Boolean isTagARule, boolean displayDetails);
64+
6365
/**
6466
* Find pool by name.
6567
*
@@ -103,6 +105,8 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
103105

104106
void updateDetails(long poolId, Map<String, String> details);
105107

108+
void removeDetails(long poolId);
109+
106110
Map<String, String> getDetails(long poolId);
107111

108112
List<String> searchForStoragePoolTags(long poolId);

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,19 @@ public StoragePoolVO listById(Integer id) {
296296
}
297297

298298
@Override
299-
@DB
300299
public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details, List<String> tags, Boolean isTagARule) {
300+
return persist(pool, details, tags, isTagARule, true);
301+
}
302+
303+
@Override
304+
@DB
305+
public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details, List<String> tags, Boolean isTagARule, boolean displayDetails) {
301306
TransactionLegacy txn = TransactionLegacy.currentTxn();
302307
txn.start();
303308
pool = super.persist(pool);
304309
if (details != null) {
305310
for (Map.Entry<String, String> detail : details.entrySet()) {
306-
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue(), true);
311+
StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue(), displayDetails);
307312
_detailsDao.persist(vo);
308313
}
309314
}
@@ -570,6 +575,11 @@ public void updateDetails(long poolId, Map<String, String> details) {
570575
}
571576
}
572577

578+
@Override
579+
public void removeDetails(long poolId) {
580+
_detailsDao.removeDetails(poolId);
581+
}
582+
573583
@Override
574584
public Map<String, String> getDetails(long poolId) {
575585
return _detailsDao.listDetailsKeyPairs(poolId);

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient;
3535
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClientConnectionPool;
3636
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
37+
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
3738
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3839
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3940
import org.apache.cloudstack.storage.datastore.util.ScaleIOUtil;
@@ -301,7 +302,11 @@ public boolean revertVMSnapshot(VMSnapshot vmSnapshot) {
301302
srcSnapshotDestVolumeMap.put(srcSnapshotVolumeId, destVolumeId);
302303
}
303304

304-
String systemId = storagePoolDetailsDao.findDetail(storagePoolId, ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
305+
String systemId = null;
306+
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(storagePoolId, ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);
307+
if (systemIdDetail != null) {
308+
systemId = systemIdDetail.getValue();
309+
}
305310
if (systemId == null) {
306311
throw new CloudRuntimeException("Failed to get the system id for PowerFlex storage pool for reverting VM snapshot: " + vmSnapshot.getName());
307312
}
@@ -380,7 +385,11 @@ public boolean deleteVMSnapshot(VMSnapshot vmSnapshot) {
380385
try {
381386
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(vmSnapshot.getVmId());
382387
StoragePoolVO storagePool = vmSnapshotHelper.getStoragePoolForVM(userVm);
383-
String systemId = storagePoolDetailsDao.findDetail(storagePool.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
388+
String systemId = null;
389+
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);
390+
if (systemIdDetail != null) {
391+
systemId = systemIdDetail.getValue();
392+
}
384393
if (systemId == null) {
385394
throw new CloudRuntimeException("Failed to get the system id for PowerFlex storage pool for deleting VM snapshot: " + vmSnapshot.getName());
386395
}

0 commit comments

Comments
 (0)