Skip to content
Merged
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/server/TaggedResourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ public interface TaggedResourceService {
String getUuid(String resourceId, ResourceObjectType resourceType);

public long getResourceId(String resourceId, ResourceObjectType resourceType);

/**
* Retrieves tags from resource.
* @param type
* @param resourceId
* @return If the list of tags is not null, returns a map with the tags, otherwise, returns null.
*/
public Map<String, String> getTagsFromResource(ResourceObjectType type, long resourceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.cloudstack.engine.subsystem.api.storage;

import com.cloud.agent.api.Answer;
import java.util.Map;

import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
Expand Down Expand Up @@ -100,4 +101,11 @@ public VolumeInfo getVolume() {
VolumeInfo updateHypervisorSnapshotReserveForVolume(DiskOffering diskOffering, long volumeId, HypervisorType hyperType);

void unmanageVolume(long volumeId);

/**
* After volume migration, copies snapshot policies from the source volume to destination volume; then, it destroys and expunges the source volume.
* @return If no exception happens, it will return false, otherwise true.
*/
boolean copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(ObjectInDataStoreStateMachine.Event destinationEvent, Answer destinationEventAnswer,
VolumeInfo sourceVolume, VolumeInfo destinationVolume, boolean retryExpungeVolumeAsync);
}
5 changes: 5 additions & 0 deletions engine/schema/src/main/java/com/cloud/storage/VolumeVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.GenericDao;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

@Entity
@Table(name = "volumes")
Expand Down Expand Up @@ -643,4 +644,8 @@ public Integer getHypervisorSnapshotReserve() {
public Class<?> getEntityType() {
return Volume.class;
}

public String getVolumeDescription(){
return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "name", "uuid");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2061,30 +2061,12 @@ private void handlePostMigration(boolean success, Map<VolumeInfo, VolumeInfo> sr
handleQualityOfServiceForVolumeMigration(destVolumeInfo, PrimaryDataStoreDriver.QualityOfServiceState.NO_MIGRATION);

if (success) {
srcVolumeInfo.processEvent(Event.OperationSuccessed);
destVolumeInfo.processEvent(Event.OperationSuccessed);

_volumeDao.updateUuid(srcVolumeInfo.getId(), destVolumeInfo.getId());

VolumeVO volumeVO = _volumeDao.findById(destVolumeInfo.getId());

volumeVO.setFormat(ImageFormat.QCOW2);

_volumeDao.update(volumeVO.getId(), volumeVO);

try {
_volumeService.destroyVolume(srcVolumeInfo.getId());

srcVolumeInfo = _volumeDataFactory.getVolume(srcVolumeInfo.getId());
_volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed, null, srcVolumeInfo, destVolumeInfo, false);

AsyncCallFuture<VolumeApiResult> destroyFuture = _volumeService.expungeVolumeAsync(srcVolumeInfo);

if (destroyFuture.get().isFailed()) {
LOGGER.debug("Failed to clean up source volume on storage");
}
} catch (Exception e) {
LOGGER.debug("Failed to clean up source volume on storage", e);
}

// Update the volume ID for snapshots on secondary storage
if (!_snapshotDao.listByVolumeId(srcVolumeInfo.getId()).isEmpty()) {
Expand Down
3 changes: 0 additions & 3 deletions engine/storage/volume/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
Expand Down
Loading