Skip to content

Commit 4ce8671

Browse files
PowerFlex on demand disable config key (#9664)
* Introduced configuration key "powerflex.connect.on.demand" to enable/disable PowerFlex on-demand connection from Host to Storage Pool feature. * Update plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java --------- Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent 21d107c commit 4ce8671

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2626
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
27+
import org.apache.cloudstack.framework.config.ConfigKey;
28+
import org.apache.cloudstack.framework.config.Configurable;
2729
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
2830
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient;
2931
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClientConnectionPool;
@@ -51,9 +53,18 @@
5153
import com.cloud.utils.exception.CloudRuntimeException;
5254

5355
@Component
54-
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
56+
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager, Configurable {
5557
private Logger logger = LogManager.getLogger(getClass());
5658

59+
static ConfigKey<Boolean> ConnectOnDemand = new ConfigKey<>("Storage",
60+
Boolean.class,
61+
"powerflex.connect.on.demand",
62+
Boolean.FALSE.toString(),
63+
"Connect PowerFlex client on Host when first Volume is mapped to SDC and disconnect when last Volume is unmapped from SDC," +
64+
" otherwise no action (that is connection remains in the same state whichever it is, connected or disconnected).",
65+
Boolean.TRUE,
66+
ConfigKey.Scope.Zone);
67+
5768
@Inject
5869
AgentManager agentManager;
5970
@Inject
@@ -94,6 +105,11 @@ public boolean areSDCConnectionsWithinLimit(Long storagePoolId) {
94105

95106
@Override
96107
public String prepareSDC(Host host, DataStore dataStore) {
108+
if (Boolean.FALSE.equals(ConnectOnDemand.valueIn(host.getDataCenterId()))) {
109+
logger.debug(String.format("On-demand connect/disconnect config %s disabled in the zone %d, no need to prepare SDC (check for connected SDC)", ConnectOnDemand.key(), host.getDataCenterId()));
110+
return getConnectedSdc(host, dataStore);
111+
}
112+
97113
String systemId = storagePoolDetailsDao.findDetail(dataStore.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
98114
if (systemId == null) {
99115
throw new CloudRuntimeException("Unable to prepare SDC, failed to get the system id for PowerFlex storage pool: " + dataStore.getName());
@@ -116,7 +132,7 @@ public String prepareSDC(Host host, DataStore dataStore) {
116132

117133
long poolId = dataStore.getId();
118134
long hostId = host.getId();
119-
String sdcId = getConnectedSdc(poolId, hostId);
135+
String sdcId = getConnectedSdc(host, dataStore);
120136
if (StringUtils.isNotBlank(sdcId)) {
121137
logger.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
122138
return sdcId;
@@ -227,6 +243,11 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId)
227243

228244
@Override
229245
public boolean stopSDC(Host host, DataStore dataStore) {
246+
if (Boolean.FALSE.equals(ConnectOnDemand.valueIn(host.getDataCenterId()))) {
247+
logger.debug(String.format("On-demand connect/disconnect config %s disabled in the zone %d, no need to unprepare SDC", ConnectOnDemand.key(), host.getDataCenterId()));
248+
return true;
249+
}
250+
230251
String systemId = storagePoolDetailsDao.findDetail(dataStore.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
231252
if (systemId == null) {
232253
throw new CloudRuntimeException("Unable to unprepare SDC, failed to get the system id for PowerFlex storage pool: " + dataStore.getName());
@@ -248,7 +269,7 @@ public boolean stopSDC(Host host, DataStore dataStore) {
248269

249270
long poolId = dataStore.getId();
250271
long hostId = host.getId();
251-
String sdcId = getConnectedSdc(poolId, hostId);
272+
String sdcId = getConnectedSdc(host, dataStore);
252273
if (StringUtils.isBlank(sdcId)) {
253274
logger.debug("SDC not connected, no need to unprepare it");
254275
return true;
@@ -297,7 +318,10 @@ private String getHostSdcId(String sdcGuid, long poolId) {
297318
}
298319
}
299320

300-
private String getConnectedSdc(long poolId, long hostId) {
321+
private String getConnectedSdc(Host host, DataStore dataStore) {
322+
long poolId = dataStore.getId();
323+
long hostId = host.getId();
324+
301325
try {
302326
StoragePoolHostVO poolHostVO = storagePoolHostDao.findByPoolHost(poolId, hostId);
303327
if (poolHostVO == null) {
@@ -344,4 +368,14 @@ private boolean isHostSdcConnected(String sdcId, long poolId) {
344368
private ScaleIOGatewayClient getScaleIOClient(final Long storagePoolId) throws Exception {
345369
return ScaleIOGatewayClientConnectionPool.getInstance().getClient(storagePoolId, storagePoolDetailsDao);
346370
}
371+
372+
@Override
373+
public String getConfigComponentName() {
374+
return ScaleIOSDCManager.class.getSimpleName();
375+
}
376+
377+
@Override
378+
public ConfigKey<?>[] getConfigKeys() {
379+
return new ConfigKey[]{ConnectOnDemand};
380+
}
347381
}

0 commit comments

Comments
 (0)