Skip to content

Commit ac862df

Browse files
authored
Merge pull request #779 from sjyu1/ablestack-europa
europa 오류수정
2 parents ec3bd01 + 46d2fa5 commit ac862df

3 files changed

Lines changed: 52 additions & 11 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,8 +2695,19 @@ public Answer createVolumeFromSnapshot(final CopyCommand cmd) {
26952695

26962696
final String snapshotFullPath = snapshot.getPath();
26972697
final int index = snapshotFullPath.lastIndexOf("/");
2698-
final String snapshotPath = snapshotFullPath.substring(0, index);
2699-
final String snapshotName = snapshotFullPath.substring(index + 1);
2698+
final String snapshotPath;
2699+
final String snapshotName;
2700+
if (index >= 0) {
2701+
snapshotPath = snapshotFullPath.substring(0, index);
2702+
snapshotName = snapshotFullPath.substring(index + 1);
2703+
} else {
2704+
if (pool.getPoolType() == StoragePoolType.SharedMountPoint) {
2705+
snapshotPath = pool.getPath();
2706+
snapshotName = snapshotFullPath;
2707+
} else {
2708+
throw new CloudRuntimeException("Invalid snapshot path format: " + snapshotFullPath);
2709+
}
2710+
}
27002711
KVMPhysicalDisk disk = null;
27012712
if (imageStore instanceof NfsTO) {
27022713
disk = createVolumeFromSnapshotOnNFS(cmd, pool, imageStore, volume, snapshotPath, snapshotName);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10698,7 +10698,7 @@ public Optional<UserVm> cloneVirtualMachine(CloneVMCmd cmd) throws ResourceAlloc
1069810698
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot: " + e.getMessage(), e);
1069910699
}
1070010700

10701-
List<VMSnapshotDetailsVO> listSnapshots = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), "kvmStorageSnapshot");
10701+
List<VMSnapshotDetailsVO> listSnapshots = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), "kvmFileBasedStorageSnapshot");
1070210702

1070310703
Integer countOfCloneVM = cmd.getCount();
1070410704
for (int cnt = 1; cnt <= countOfCloneVM; cnt++) {

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import com.cloud.storage.VolumeApiService;
106106
import com.cloud.storage.VolumeVO;
107107
import com.cloud.storage.dao.DiskOfferingDao;
108+
import com.cloud.storage.dao.StoragePoolTagsDao;
108109
import com.cloud.storage.dao.GuestOSDao;
109110
import com.cloud.storage.dao.GuestOSHypervisorDao;
110111
import com.cloud.storage.dao.SnapshotDao;
@@ -250,6 +251,8 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
250251
@Inject
251252
private DiskOfferingDao diskOfferingDao;
252253
@Inject
254+
private StoragePoolTagsDao storagePoolTagsDao;
255+
@Inject
253256
private ResourceManager resourceManager;
254257
@Inject
255258
private ResourceLimitService resourceLimitService;
@@ -2201,16 +2204,43 @@ private List<StoragePoolVO> findInstanceConversionDestinationStoragePoolsInClust
22012204
Cluster destinationCluster, ServiceOfferingVO serviceOffering,
22022205
Map<String, Long> dataDiskOfferingMap,
22032206
DataStoreTO temporaryConvertLocation, boolean forceConvertToPool) {
2204-
List<StoragePoolVO> poolsList;
2207+
List<StoragePoolVO> poolsList = new ArrayList<>();
22052208
if (!forceConvertToPool) {
2206-
Set<StoragePoolVO> pools = new HashSet<>(primaryDataStoreDao.findClusterWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem));
2207-
pools.addAll(primaryDataStoreDao.findZoneWideStoragePoolsByHypervisorAndPoolType(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM, Storage.StoragePoolType.NetworkFilesystem));
2208-
if (pools.isEmpty()) {
2209-
String msg = String.format("Cannot find suitable storage pools in the cluster %s for the conversion", destinationCluster.getName());
2210-
logger.error(msg);
2211-
throw new CloudRuntimeException(msg);
2209+
// Try to find pools based on disk offering tags
2210+
Set<Long> candidatePoolIds = new HashSet<>();
2211+
if (serviceOffering.getDiskOfferingId() != null) {
2212+
DiskOfferingVO diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
2213+
if (diskOffering != null && StringUtils.isNotBlank(diskOffering.getTags())) {
2214+
String tag = diskOffering.getTags();
2215+
List<Long> ids = storagePoolTagsDao.listPoolIdsByTag(tag);
2216+
if (ids != null) {
2217+
candidatePoolIds.addAll(ids);
2218+
}
2219+
}
2220+
}
2221+
2222+
if (!candidatePoolIds.isEmpty()) {
2223+
for (Long poolid : candidatePoolIds) {
2224+
StoragePoolVO pool = primaryDataStoreDao.findById(poolid);
2225+
if (pool == null) {
2226+
continue;
2227+
}
2228+
poolsList.add(pool);
2229+
}
2230+
}
2231+
logger.info("find poolsList : " + poolsList);
2232+
2233+
// Fallback to previous behavior if no tagged pools found
2234+
if (poolsList.isEmpty()) {
2235+
Set<StoragePoolVO> pools = new HashSet<>(primaryDataStoreDao.listPoolsByCluster(destinationCluster.getId()));
2236+
pools.addAll(primaryDataStoreDao.findZoneWideStoragePoolsByHypervisor(destinationCluster.getDataCenterId(), Hypervisor.HypervisorType.KVM));
2237+
if (pools.isEmpty()) {
2238+
String msg = String.format("Cannot find suitable storage pools in the cluster %s for the conversion", destinationCluster.getName());
2239+
logger.error(msg);
2240+
throw new CloudRuntimeException(msg);
2241+
}
2242+
poolsList.addAll(pools);
22122243
}
2213-
poolsList = new ArrayList<>(pools);
22142244
} else {
22152245
DataStore dataStore = dataStoreManager.getDataStore(temporaryConvertLocation.getUuid(), temporaryConvertLocation.getRole());
22162246
poolsList = Collections.singletonList(primaryDataStoreDao.findById(dataStore.getId()));

0 commit comments

Comments
 (0)