Skip to content

Commit 26a5b76

Browse files
committed
CLOUDSTACK-4109: fix upload volume to s3 for vmware
1 parent ec5f2c1 commit 26a5b76

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected Answer copyObject(DataObject srcData, DataObject destData) {
203203
}
204204
return answer;
205205
} catch (Exception e) {
206-
s_logger.debug("copy object failed: " + e.toString());
206+
s_logger.debug("copy object failed: ", e);
207207
if (cacheData != null) {
208208
cacheMgr.deleteCacheObject(cacheData);
209209
}

‎engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,9 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answe
502502
this.getId());
503503
VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
504504
volStore.setInstallPath(newVol.getPath());
505-
volStore.setSize(newVol.getSize());
505+
if (newVol.getSize() != null) {
506+
volStore.setSize(newVol.getSize());
507+
}
506508
this.volumeStoreDao.update(volStore.getId(), volStore);
507509
}
508510
}
@@ -595,7 +597,9 @@ public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer a
595597
this.getId());
596598
VolumeObjectTO newVol = (VolumeObjectTO) cpyAnswer.getNewData();
597599
volStore.setInstallPath(newVol.getPath());
598-
volStore.setSize(newVol.getSize());
600+
if (newVol.getSize() != null) {
601+
volStore.setSize(newVol.getSize());
602+
}
599603
this.volumeStoreDao.update(volStore.getId(), volStore);
600604
}
601605
}

‎plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageSubsystemCommandHandler.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
3131
import org.apache.cloudstack.storage.command.CopyCommand;
3232
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
33+
import org.apache.cloudstack.storage.to.VolumeObjectTO;
3334

3435
import java.io.File;
3536

@@ -76,6 +77,17 @@ protected Answer execute(CopyCommand cmd) {
7677
}
7778

7879
if (srcDataStore.getRole() == DataStoreRole.ImageCache && destDataStore.getRole() == DataStoreRole.Image) {
80+
//need to take extra processing for vmware, such as packing to ova, before sending to S3
81+
if (srcData.getObjectType() == DataObjectType.VOLUME) {
82+
NfsTO cacheStore = (NfsTO)srcDataStore;
83+
String parentPath = storageResource.getRootDir(cacheStore.getUrl());
84+
VolumeObjectTO vol = (VolumeObjectTO)srcData;
85+
String path = vol.getPath();
86+
int index = path.lastIndexOf(File.separator);
87+
String name = path.substring(index + 1);
88+
storageManager.createOva(parentPath + File.separator + path, name);
89+
vol.setPath(path + File.separator + name + ".ova");
90+
}
7991
needDelegation = true;
8092
}
8193

0 commit comments

Comments
 (0)