mirror of https://github.com/apache/cloudstack.git
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 <sureshkumar.anaparti@gmail.com>
This commit is contained in:
parent
21d107c349
commit
4ce86711f9
|
|
@ -24,6 +24,8 @@ import javax.inject.Inject;
|
|||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient;
|
||||
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClientConnectionPool;
|
||||
|
|
@ -51,9 +53,18 @@ import com.cloud.utils.db.GlobalLock;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
||||
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager, Configurable {
|
||||
private Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
static ConfigKey<Boolean> ConnectOnDemand = new ConfigKey<>("Storage",
|
||||
Boolean.class,
|
||||
"powerflex.connect.on.demand",
|
||||
Boolean.FALSE.toString(),
|
||||
"Connect PowerFlex client on Host when first Volume is mapped to SDC and disconnect when last Volume is unmapped from SDC," +
|
||||
" otherwise no action (that is connection remains in the same state whichever it is, connected or disconnected).",
|
||||
Boolean.TRUE,
|
||||
ConfigKey.Scope.Zone);
|
||||
|
||||
@Inject
|
||||
AgentManager agentManager;
|
||||
@Inject
|
||||
|
|
@ -94,6 +105,11 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
|
||||
@Override
|
||||
public String prepareSDC(Host host, DataStore dataStore) {
|
||||
if (Boolean.FALSE.equals(ConnectOnDemand.valueIn(host.getDataCenterId()))) {
|
||||
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()));
|
||||
return getConnectedSdc(host, dataStore);
|
||||
}
|
||||
|
||||
String systemId = storagePoolDetailsDao.findDetail(dataStore.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
|
||||
if (systemId == null) {
|
||||
throw new CloudRuntimeException("Unable to prepare SDC, failed to get the system id for PowerFlex storage pool: " + dataStore.getName());
|
||||
|
|
@ -116,7 +132,7 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
|
||||
long poolId = dataStore.getId();
|
||||
long hostId = host.getId();
|
||||
String sdcId = getConnectedSdc(poolId, hostId);
|
||||
String sdcId = getConnectedSdc(host, dataStore);
|
||||
if (StringUtils.isNotBlank(sdcId)) {
|
||||
logger.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
|
||||
return sdcId;
|
||||
|
|
@ -227,6 +243,11 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
|
||||
@Override
|
||||
public boolean stopSDC(Host host, DataStore dataStore) {
|
||||
if (Boolean.FALSE.equals(ConnectOnDemand.valueIn(host.getDataCenterId()))) {
|
||||
logger.debug(String.format("On-demand connect/disconnect config %s disabled in the zone %d, no need to unprepare SDC", ConnectOnDemand.key(), host.getDataCenterId()));
|
||||
return true;
|
||||
}
|
||||
|
||||
String systemId = storagePoolDetailsDao.findDetail(dataStore.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID).getValue();
|
||||
if (systemId == null) {
|
||||
throw new CloudRuntimeException("Unable to unprepare SDC, failed to get the system id for PowerFlex storage pool: " + dataStore.getName());
|
||||
|
|
@ -248,7 +269,7 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
|
||||
long poolId = dataStore.getId();
|
||||
long hostId = host.getId();
|
||||
String sdcId = getConnectedSdc(poolId, hostId);
|
||||
String sdcId = getConnectedSdc(host, dataStore);
|
||||
if (StringUtils.isBlank(sdcId)) {
|
||||
logger.debug("SDC not connected, no need to unprepare it");
|
||||
return true;
|
||||
|
|
@ -297,7 +318,10 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
}
|
||||
}
|
||||
|
||||
private String getConnectedSdc(long poolId, long hostId) {
|
||||
private String getConnectedSdc(Host host, DataStore dataStore) {
|
||||
long poolId = dataStore.getId();
|
||||
long hostId = host.getId();
|
||||
|
||||
try {
|
||||
StoragePoolHostVO poolHostVO = storagePoolHostDao.findByPoolHost(poolId, hostId);
|
||||
if (poolHostVO == null) {
|
||||
|
|
@ -344,4 +368,14 @@ public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
|
|||
private ScaleIOGatewayClient getScaleIOClient(final Long storagePoolId) throws Exception {
|
||||
return ScaleIOGatewayClientConnectionPool.getInstance().getClient(storagePoolId, storagePoolDetailsDao);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return ScaleIOSDCManager.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey[]{ConnectOnDemand};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue