Skip to content

PowerFlex/ScaleIO - MDM and host SDC connection enhancements #11047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.cloud.resource.CommandWrapper;
import com.cloud.resource.ResourceWrapper;
import com.cloud.storage.template.TemplateProp;
import com.cloud.utils.exception.CloudRuntimeException;

@ResourceWrapper(handles = ModifyStoragePoolCommand.class)
public final class LibvirtModifyStoragePoolCommandWrapper extends CommandWrapper<ModifyStoragePoolCommand, Answer, LibvirtComputingResource> {
Expand All @@ -49,11 +50,16 @@
return answer;
}

final KVMStoragePool storagepool =
storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool()
.getUserInfo(), command.getPool().getType(), command.getDetails());
if (storagepool == null) {
return new Answer(command, false, " Failed to create storage pool");
final KVMStoragePool storagepool;
try {
storagepool =
storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool()
.getUserInfo(), command.getPool().getType(), command.getDetails());
if (storagepool == null) {
return new Answer(command, false, " Failed to create storage pool");
}
} catch (CloudRuntimeException e) {
return new Answer(command, false, String.format("Failed to create storage pool: %s", e.getLocalizedMessage()));

Check warning on line 62 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtModifyStoragePoolCommandWrapper.java#L61-L62

Added lines #L61 - L62 were not covered by tests
}

final Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.cloud.agent.api.PrepareStorageClientCommand;
import org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient;
import org.apache.cloudstack.storage.datastore.manager.ScaleIOSDCManager;
import org.apache.cloudstack.storage.datastore.util.ScaleIOUtil;
Expand All @@ -38,6 +40,7 @@
import org.apache.cloudstack.utils.qemu.QemuImgException;
import org.apache.cloudstack.utils.qemu.QemuImgFile;
import org.apache.cloudstack.utils.qemu.QemuObject;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -158,10 +161,44 @@
}
}
}

validateMdmState(details);

Check warning on line 165 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L165

Added line #L165 was not covered by tests

MapStorageUuidToStoragePool.put(uuid, storagePool);
return storagePool;
}

/**
* Validate Storage Pool state to ensure it healthy and can operate requests.
* There is observed situation where ScaleIO configuration file has different values than ScaleIO CLI.
* Validation compares values from both drv_cfg.txt and drv_cfg CLI and throws exception if there is mismatch.
*
* @param details see {@link PrepareStorageClientCommand#getDetails()}
* and {@link @UnprepareStorageClientCommand#getDetails()}, expected to contain
* {@link ScaleIOSDCManager#ValidateMdmsOnConnect#key()}
* @throws CloudRuntimeException in case if Storage Pool is not operate-able
*/
private void validateMdmState(Map<String, String> details) {
String configKey = ScaleIOSDCManager.ValidateMdmsOnConnect.key();
String configValue = details.get(configKey);

Check warning on line 183 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L181-L183

Added lines #L181 - L183 were not covered by tests

// be as much verbose as possible, otherwise it will be difficult to troubleshoot operational issue without logs
if (StringUtils.isEmpty(configValue)) {
logger.debug(String.format("Skipped ScaleIO validation as property %s not sent by Management Server", configKey));

Check warning on line 187 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L187

Added line #L187 was not covered by tests
} else if (Boolean.valueOf(configValue).equals(Boolean.FALSE)) {
logger.debug(String.format("Skipped ScaleIO validation as property %s received as %s", configKey, configValue));

Check warning on line 189 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L189

Added line #L189 was not covered by tests
} else {
Collection<String> mdmsConfig = ScaleIOUtil.getMdmsFromConfig();
Collection<String> mdmsCli = ScaleIOUtil.getMdmsFromCli();

Check warning on line 192 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L191-L192

Added lines #L191 - L192 were not covered by tests
if (!mdmsCli.equals(mdmsConfig)) {
String msg = String.format("MDM addresses from memory and configuration file don't match. " +

Check warning on line 194 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L194

Added line #L194 was not covered by tests
"Memory values: %s, configuration file values: %s", mdmsCli, mdmsConfig);
logger.warn(msg);
throw new CloudRuntimeException(msg);

Check warning on line 197 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L196-L197

Added lines #L196 - L197 were not covered by tests
}
}
}

Check warning on line 200 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L200

Added line #L200 was not covered by tests

@Override
public boolean deleteStoragePool(String uuid) {
ScaleIOStoragePool storagePool = (ScaleIOStoragePool) MapStorageUuidToStoragePool.get(uuid);
Expand Down Expand Up @@ -607,28 +644,37 @@
}

if (!ScaleIOUtil.isSDCServiceActive()) {
logger.debug("SDC service is not active on host, starting it");
if (!ScaleIOUtil.startSDCService()) {
return new Ternary<>(false, null, "Couldn't start SDC service on host");
}
}

if (details != null && details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_MDMS)) {
if (MapUtils.isNotEmpty(details) && details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_MDMS)) {
// Assuming SDC service is started, add mdms
String mdms = details.get(ScaleIOGatewayClient.STORAGE_POOL_MDMS);
String[] mdmAddresses = mdms.split(",");
if (mdmAddresses.length > 0) {
if (ScaleIOUtil.mdmAdded(mdmAddresses[0])) {
if (ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Ternary<>(true, getSDCDetails(details), "MDM added, no need to prepare the SDC client");
}

ScaleIOUtil.addMdms(Arrays.asList(mdmAddresses));
if (!ScaleIOUtil.mdmAdded(mdmAddresses[0])) {
ScaleIOUtil.addMdms(mdmAddresses);

Check warning on line 662 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L662

Added line #L662 was not covered by tests
if (!ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Ternary<>(false, null, "Failed to add MDMs");
} else {
logger.debug(String.format("MDMs %s added to storage pool %s", mdms, uuid));
applyTimeout(details);

Check warning on line 667 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L666-L667

Added lines #L666 - L667 were not covered by tests
}
}
}

return new Ternary<>( true, getSDCDetails(details), "Prepared client successfully");
Map<String, String> sdcDetails = getSDCDetails(details);
if (MapUtils.isEmpty(sdcDetails)) {
return new Ternary<>(false, null, "Couldn't get the SDC details on the host");

Check warning on line 674 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L674

Added line #L674 was not covered by tests
}

return new Ternary<>(true, sdcDetails, "Prepared client successfully");
}

public Pair<Boolean, String> unprepareStorageClient(String uuid, Map<String, String> details) {
Expand All @@ -646,36 +692,110 @@
String mdms = details.get(ScaleIOGatewayClient.STORAGE_POOL_MDMS);
String[] mdmAddresses = mdms.split(",");
if (mdmAddresses.length > 0) {
if (!ScaleIOUtil.mdmAdded(mdmAddresses[0])) {
if (!ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Pair<>(true, "MDM not added, no need to unprepare the SDC client");
} else {
String configKey = ScaleIOSDCManager.BlockSdcUnprepareIfRestartNeededAndVolumesAreAttached.key();
String configValue = details.get(configKey);

if (StringUtils.isEmpty(configValue)) {
logger.debug(String.format("Configuration key %s not provided", configKey));
} else {
logger.debug(String.format("Configuration key %s provided as %s", configKey, configValue));

Check warning on line 704 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L704

Added line #L704 was not covered by tests
}
Boolean blockUnprepare = Boolean.valueOf(configValue);
if (!ScaleIOUtil.isRemoveMdmCliSupported() && !ScaleIOUtil.getVolumeIds().isEmpty() && Boolean.TRUE.equals(blockUnprepare)) {
return new Pair<>(false, "Failed to remove MDMs, SDC client requires service to be restarted, but there are Volumes attached to the Host");

Check warning on line 708 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L708

Added line #L708 was not covered by tests
}
}

ScaleIOUtil.removeMdms(Arrays.asList(mdmAddresses));
if (ScaleIOUtil.mdmAdded(mdmAddresses[0])) {
ScaleIOUtil.removeMdms(mdmAddresses);
if (ScaleIOUtil.isMdmPresent(mdmAddresses[0])) {
return new Pair<>(false, "Failed to remove MDMs, unable to unprepare the SDC client");
} else {
logger.debug(String.format("MDMs %s removed from storage pool %s", mdms, uuid));
applyTimeout(details);

Check warning on line 717 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L716-L717

Added lines #L716 - L717 were not covered by tests
}
}
}

/*
* TODO:
* 1. Verify on-demand is true
* 2. If on-demand is true check whether other MDM addresses are still present
* 3. If there are no MDM addresses, then stop SDC service.
*/

return new Pair<>(true, "Unprepared SDC client successfully");
}

/**
* Check whether details map has timeout configured and do "apply timeout" pause before returning response
* (to have ScaleIO changes applied).
*
* @param details see {@link PrepareStorageClientCommand#getDetails()}
* and {@link @UnprepareStorageClientCommand#getDetails()}, expected to contain
* {@link ScaleIOSDCManager#MdmsChangeApplyTimeout#key()}
*/
private void applyTimeout(Map<String, String> details) {
String configKey = ScaleIOSDCManager.MdmsChangeApplyTimeout.key();
String configValue = details.get(configKey);

Check warning on line 742 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L740-L742

Added lines #L740 - L742 were not covered by tests

if (StringUtils.isEmpty(configValue)) {
logger.debug(String.format("Apply timeout value not defined in property %s, skip", configKey));
return;

Check warning on line 746 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L745-L746

Added lines #L745 - L746 were not covered by tests
}
long timeoutMs;
try {
timeoutMs = Long.parseLong(configValue);
} catch (NumberFormatException e) {
logger.warn(String.format("Invalid apply timeout value defined in property %s, skip", configKey), e);
return;
}

Check warning on line 754 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L748-L754

Added lines #L748 - L754 were not covered by tests
if (timeoutMs < 1) {
logger.warn(String.format("Apply timeout value is too small (%s ms), skipping", timeoutMs));
return;

Check warning on line 757 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L756-L757

Added lines #L756 - L757 were not covered by tests
}
try {
Thread.sleep(timeoutMs);
} catch (InterruptedException e) {
logger.warn(String.format("Apply timeout %s ms interrupted", timeoutMs), e);
}
}

Check warning on line 764 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L759-L764

Added lines #L759 - L764 were not covered by tests

private Map<String, String> getSDCDetails(Map<String, String> details) {
Map<String, String> sdcDetails = new HashMap<String, String>();
if (details == null || !details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID)) {
if (MapUtils.isEmpty(details) || !details.containsKey(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID)) {
return sdcDetails;
}

String storageSystemId = details.get(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);
String sdcId = ScaleIOUtil.getSdcId(storageSystemId);
if (sdcId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_ID, sdcId);
} else {
if (StringUtils.isEmpty(storageSystemId)) {
return sdcDetails;

Check warning on line 774 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L774

Added line #L774 was not covered by tests
}

int waitTimeInSecs = 5;
int timeBetweenTries = 1000; // Try more frequently (every sec) and return early when SDC Id or Guid found
do {
String sdcId = ScaleIOUtil.getSdcId(storageSystemId);
if (sdcId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_ID, sdcId);
return sdcDetails;
}

String sdcGuId = ScaleIOUtil.getSdcGuid();
if (sdcGuId != null) {
sdcDetails.put(ScaleIOGatewayClient.SDC_GUID, sdcGuId);
return sdcDetails;
}
}

try {
Thread.sleep(timeBetweenTries);
} catch (Exception ignore) {
}
waitTimeInSecs--;

Check warning on line 796 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java#L792-L796

Added lines #L792 - L796 were not covered by tests
} while (waitTimeInSecs > 0);

return sdcDetails;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ public void testUnprepareStorageClient_RemoveMDMFailed() {
details.put(ScaleIOGatewayClient.STORAGE_POOL_MDMS, "1.1.1.1,2.2.2.2");
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl status scini"))).thenReturn(3);
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl is-enabled scini"))).thenReturn(0);
when(Script.executeCommand(Mockito.eq("sed -i '/1.1.1.1\\,/d' /etc/emc/scaleio/drv_cfg.txt"))).thenReturn(new Pair<>(null, null));
when(Script.runSimpleBashScriptForExitValue(Mockito.eq("systemctl restart scini"))).thenReturn(0);
when(Script.runSimpleBashScript(Mockito.eq("/opt/emc/scaleio/sdc/bin/drv_cfg --query_mdms|grep 1.1.1.1"))).thenReturn("MDM-ID 71fd458f0775010f SDC ID 4421a91a00000000 INSTALLATION ID 204930df2cbcaf8e IPs [0]-1.1.1.1 [1]-2.2.2.2");
when(Script.executeCommand(Mockito.eq("/opt/emc/scaleio/sdc/bin/drv_cfg"))).thenReturn(new Pair<>(null, null));
when(Script.executeCommand(Mockito.eq("/opt/emc/scaleio/sdc/bin/drv_cfg --query_vols"))).thenReturn(new Pair<>("", null));


Pair<Boolean, String> result = scaleIOStorageAdaptor.unprepareStorageClient(poolUuid, details);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface ScaleIOGatewayClient {
String GATEWAY_API_PASSWORD = "powerflex.gw.password";
String STORAGE_POOL_NAME = "powerflex.storagepool.name";
String STORAGE_POOL_SYSTEM_ID = "powerflex.storagepool.system.id";
/**
* Storage Pool Metadata Management (MDM) IP address(es).
*/
String STORAGE_POOL_MDMS = "powerflex.storagepool.mdms";
String SDC_ID = "powerflex.sdc.id";
String SDC_GUID = "powerflex.sdc.guid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import javax.inject.Inject;

import com.cloud.host.HostVO;
import com.cloud.storage.dao.StoragePoolAndAccessGroupMapDao;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.utils.StringUtils;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
Expand Down Expand Up @@ -105,8 +104,6 @@
@Inject
private AgentManager agentMgr;
private ScaleIOSDCManager sdcManager;
@Inject
private StoragePoolAndAccessGroupMapDao storagePoolAndAccessGroupMapDao;

public ScaleIOPrimaryDataStoreLifeCycle() {
sdcManager = new ScaleIOSDCManagerImpl();
Expand Down Expand Up @@ -306,14 +303,18 @@

@Override
public boolean maintain(DataStore store) {
Map<String,String> details = new HashMap<>();
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);
if (systemIdDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemIdDetail.getValue());
StoragePoolDetailVO mdmsDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_MDMS);
if (mdmsDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_MDMS, mdmsDetail.getValue());
details.put(ScaleIOSDCManager.ConnectOnDemand.key(), "false");
Map<String, String> details = new HashMap<>();
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(store.getId());
if (storagePoolVO != null) {
populateScaleIOConfiguration(details, storagePoolVO.getDataCenterId());
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);

Check warning on line 310 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L309-L310

Added lines #L309 - L310 were not covered by tests
if (systemIdDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemIdDetail.getValue());
StoragePoolDetailVO mdmsDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_MDMS);

Check warning on line 313 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L312-L313

Added lines #L312 - L313 were not covered by tests
if (mdmsDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_MDMS, mdmsDetail.getValue());
details.put(ScaleIOSDCManager.ConnectOnDemand.key(), "false");

Check warning on line 316 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L315-L316

Added lines #L315 - L316 were not covered by tests
}
}
}

Expand All @@ -324,14 +325,15 @@

@Override
public boolean cancelMaintain(DataStore store) {
Map<String,String> details = new HashMap<>();
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);
if (systemIdDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemIdDetail.getValue());
sdcManager = ComponentContext.inject(sdcManager);
if (sdcManager.areSDCConnectionsWithinLimit(store.getId())) {
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(store.getId());
if (storagePoolVO != null) {
Map<String, String> details = new HashMap<>();
StoragePoolVO storagePoolVO = primaryDataStoreDao.findById(store.getId());
if (storagePoolVO != null) {
populateScaleIOConfiguration(details, storagePoolVO.getDataCenterId());
StoragePoolDetailVO systemIdDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID);

Check warning on line 332 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L331-L332

Added lines #L331 - L332 were not covered by tests
if (systemIdDetail != null) {
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemIdDetail.getValue());
sdcManager = ComponentContext.inject(sdcManager);

Check warning on line 335 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L334-L335

Added lines #L334 - L335 were not covered by tests
if (sdcManager.areSDCConnectionsWithinLimit(store.getId())) {
details.put(ScaleIOSDCManager.ConnectOnDemand.key(), String.valueOf(ScaleIOSDCManager.ConnectOnDemand.valueIn(storagePoolVO.getDataCenterId())));
StoragePoolDetailVO mdmsDetail = storagePoolDetailsDao.findDetail(store.getId(), ScaleIOGatewayClient.STORAGE_POOL_MDMS);
if (mdmsDetail != null) {
Expand Down Expand Up @@ -409,4 +411,14 @@
private static boolean isSupportedHypervisorType(Hypervisor.HypervisorType hypervisorType) {
return Hypervisor.HypervisorType.KVM.equals(hypervisorType);
}

private void populateScaleIOConfiguration(Map<String, String> details, long dataCenterId) {

Check warning on line 415 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L415

Added line #L415 was not covered by tests
if (details == null) {
details = new HashMap<>();

Check warning on line 417 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L417

Added line #L417 was not covered by tests
}

details.put(ScaleIOSDCManager.MdmsChangeApplyTimeout.key(), String.valueOf(ScaleIOSDCManager.MdmsChangeApplyTimeout.valueIn(dataCenterId)));
details.put(ScaleIOSDCManager.ValidateMdmsOnConnect.key(), String.valueOf(ScaleIOSDCManager.ValidateMdmsOnConnect.valueIn(dataCenterId)));
details.put(ScaleIOSDCManager.BlockSdcUnprepareIfRestartNeededAndVolumesAreAttached.key(), String.valueOf(ScaleIOSDCManager.BlockSdcUnprepareIfRestartNeededAndVolumesAreAttached.valueIn(dataCenterId)));
}

Check warning on line 423 in plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/ScaleIOPrimaryDataStoreLifeCycle.java#L420-L423

Added lines #L420 - L423 were not covered by tests
}
Loading
Loading