Skip to content
Merged
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
3 changes: 2 additions & 1 deletion api/src/main/java/com/cloud/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public static enum StoragePoolType {
PowerFlex(true, true), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
ManagedNFS(true, false),
Linstor(true, true),
DatastoreCluster(true, true); // for VMware, to abstract pool of clusters
DatastoreCluster(true, true), // for VMware, to abstract pool of clusters
StorPool(true, true);

private final boolean shared;
private final boolean overprovisioning;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,30 @@
// under the License.
package com.cloud.upgrade.dao;

import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;

import java.io.InputStream;
import java.sql.Connection;
import java.util.List;

import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;

import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.dao.VolumeDaoImpl;
import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.exception.CloudRuntimeException;

public class Upgrade41700to41710 implements DbUpgrade, DbUpgradeSystemVmTemplate {

final static Logger LOG = Logger.getLogger(Upgrade41610to41700.class);
private SystemVmTemplateRegistration systemVmTemplateRegistration;

private PrimaryDataStoreDao storageDao;
private VolumeDao volumeDao;

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.17.0.0", "4.17.1.0"};
Expand Down Expand Up @@ -56,6 +68,7 @@ public InputStream[] getPrepareScripts() {

@Override
public void performDataMigration(Connection conn) {
updateStorPoolStorageType();
}

@Override
Expand Down Expand Up @@ -83,4 +96,25 @@ public void updateSystemVmTemplates(Connection conn) {
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
}
}

private void updateStorPoolStorageType() {
storageDao = new PrimaryDataStoreDaoImpl();
List<StoragePoolVO> storPoolPools = storageDao.findPoolsByProvider("StorPool");
Comment thread
sureshanaparti marked this conversation as resolved.
for (StoragePoolVO storagePoolVO : storPoolPools) {
if (StoragePoolType.SharedMountPoint == storagePoolVO.getPoolType()) {
storagePoolVO.setPoolType(StoragePoolType.StorPool);
storageDao.update(storagePoolVO.getId(), storagePoolVO);
}
updateStorageTypeForStorPoolVolumes(storagePoolVO.getId());
}
}

private void updateStorageTypeForStorPoolVolumes(long storagePoolId) {
volumeDao = new VolumeDaoImpl();
List<VolumeVO> volumes = volumeDao.findByPoolId(storagePoolId, null);
for (VolumeVO volumeVO : volumes) {
volumeVO.setPoolType(StoragePoolType.StorPool);
volumeDao.update(volumeVO.getId(), volumeVO);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,8 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
dataStoreUrl = "nfs://" + psHost + File.separator + psPath;
physicalDisk = getPhysicalDiskFromNfsStore(dataStoreUrl, data);
} else if (primaryDataStoreTO.getPoolType().equals(StoragePoolType.SharedMountPoint) ||
primaryDataStoreTO.getPoolType().equals(StoragePoolType.Filesystem)) {
primaryDataStoreTO.getPoolType().equals(StoragePoolType.Filesystem) ||
primaryDataStoreTO.getPoolType().equals(StoragePoolType.StorPool)) {
physicalDisk = getPhysicalDiskPrimaryStore(primaryDataStoreTO, data);
}
}
Expand All @@ -2868,7 +2869,8 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
&& (pool.getType() == StoragePoolType.NetworkFilesystem
|| pool.getType() == StoragePoolType.SharedMountPoint
|| pool.getType() == StoragePoolType.Filesystem
|| pool.getType() == StoragePoolType.Gluster)) {
|| pool.getType() == StoragePoolType.Gluster
|| pool.getType() == StoragePoolType.StorPool)) {
Comment on lines 2869 to +2873
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create a Set with the types allowed and verify if it "contains", to reduce the if complexity.

setBackingFileFormat(physicalDisk.getPath());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;

@StorageAdaptorInfo(storagePoolType=StoragePoolType.SharedMountPoint)
@StorageAdaptorInfo(storagePoolType=StoragePoolType.StorPool)
public class StorPoolStorageAdaptor implements StorageAdaptor {
public static void SP_LOG(String fmt, Object... args) {
try (PrintWriter spLogFile = new PrintWriter(new BufferedWriter(new FileWriter("/var/log/cloudstack/agent/storpool-agent.log", true)))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCal

VolumeVO volume = volumeDao.findById(vinfo.getId());
volume.setPoolId(dataStore.getId());
volume.setPoolType(StoragePoolType.SharedMountPoint);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, you can keep pool type as StoragePoolType.StorPool

volume.setPath(path);
volumeDao.update(volume.getId(), volume);

Expand Down Expand Up @@ -716,7 +715,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
final String name = StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST tmpSnapName=%s ,srcUUID=%s", name, srcTO.getUuid());

if (checkStoragePool != null && checkStoragePool.getPoolType().equals(StoragePoolType.SharedMountPoint)) {
if (checkStoragePool != null && checkStoragePool.getPoolType().equals(StoragePoolType.StorPool)) {
SpConnectionDesc conn = StorPoolUtil.getSpConnection(dstData.getDataStore().getUuid(), dstData.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
String baseOn = StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
//uuid tag will be the same as srcData.uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
parameters.setUuid(conn.getTemplateName() + ";" + UUID.randomUUID().toString());
parameters.setZoneId(zoneId);
parameters.setProviderName(providerName);
parameters.setType(StoragePoolType.SharedMountPoint);
parameters.setType(StoragePoolType.StorPool);
parameters.setHypervisorType(HypervisorType.KVM);
parameters.setManaged(false);
parameters.setHost("n/a");
Expand Down