Skip to content

Commit 8db3c6d

Browse files
Added the PowerFlex/ScaleIO volume/snapshot name to the paths of respective CloudStack resources (Templates, Volumes, Snapshots and VM Snapshots)
1 parent 58896aa commit 8db3c6d

5 files changed

Lines changed: 97 additions & 60 deletions

File tree

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
141141
for (VolumeObjectTO volume : volumeTOs) {
142142
String volumeSnapshotName = String.format("%s-%s-%s-%s-%s", ScaleIOUtil.VMSNAPSHOT_PREFIX, vmSnapshotVO.getId(), volume.getId(),
143143
storagePool.getUuid().split("-")[0].substring(4), ManagementServerImpl.customCsIdentifier.value());
144-
srcVolumeDestSnapshotMap.put(volume.getPath(), volumeSnapshotName);
144+
srcVolumeDestSnapshotMap.put(ScaleIOUtil.getVolumePath(volume.getPath()), volumeSnapshotName);
145145

146146
virtual_size += volume.getSize();
147147
VolumeVO volumeVO = volumeDao.findById(volume.getId());
@@ -173,7 +173,9 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
173173
vmSnapshotDetails.add(new VMSnapshotDetailsVO(vmSnapshot.getId(), "SnapshotGroupId", snapshotGroupId, false));
174174

175175
for (int index = 0; index < volumeIds.size(); index++) {
176-
vmSnapshotDetails.add(new VMSnapshotDetailsVO(vmSnapshot.getId(), "Vol_" + volumeTOs.get(index).getId() + "_Snapshot", volumeIds.get(index), false));
176+
String volumeSnapshotName = srcVolumeDestSnapshotMap.get(ScaleIOUtil.getVolumePath(volumeTOs.get(index).getPath()));
177+
String pathWithScaleIOVolumeName = ScaleIOUtil.updatedPathWithVolumeName(volumeIds.get(index), volumeSnapshotName);
178+
vmSnapshotDetails.add(new VMSnapshotDetailsVO(vmSnapshot.getId(), "Vol_" + volumeTOs.get(index).getId() + "_Snapshot", pathWithScaleIOVolumeName, false));
177179
}
178180

179181
vmSnapshotDetailsDao.saveDetails(vmSnapshotDetails);
@@ -265,8 +267,8 @@ public boolean revertVMSnapshot(VMSnapshot vmSnapshot) {
265267
Map<String, String> srcSnapshotDestVolumeMap = new HashMap<>();
266268
for (VolumeObjectTO volume : volumeTOs) {
267269
VMSnapshotDetailsVO vmSnapshotDetail = vmSnapshotDetailsDao.findDetail(vmSnapshotVO.getId(), "Vol_" + volume.getId() + "_Snapshot");
268-
String srcSnapshotVolumeId = vmSnapshotDetail.getValue();
269-
String destVolumeId = volume.getPath();
270+
String srcSnapshotVolumeId = ScaleIOUtil.getVolumePath(vmSnapshotDetail.getValue());
271+
String destVolumeId = ScaleIOUtil.getVolumePath(volume.getPath());
270272
srcSnapshotDestVolumeMap.put(srcSnapshotVolumeId, destVolumeId);
271273
}
272274

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ public KVMStoragePool getStoragePool(String uuid, boolean refreshInfo) {
6767
}
6868

6969
@Override
70-
public KVMPhysicalDisk getPhysicalDisk(String volumeId, KVMStoragePool pool) {
71-
if (Strings.isNullOrEmpty(volumeId) || pool == null) {
72-
LOGGER.error("Unable to get physical disk, unspecified volumeid or pool");
70+
public KVMPhysicalDisk getPhysicalDisk(String volumePath, KVMStoragePool pool) {
71+
if (Strings.isNullOrEmpty(volumePath) || pool == null) {
72+
LOGGER.error("Unable to get physical disk, volume path or pool not specified");
7373
return null;
7474
}
7575

76+
String volumeId = ScaleIOUtil.getVolumePath(volumePath);
77+
7678
try {
7779
String diskFilePath = null;
7880
String systemId = ScaleIOUtil.getSystemIdForVolume(volumeId);
@@ -98,7 +100,7 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeId, KVMStoragePool pool) {
98100
}
99101
}
100102

101-
KVMPhysicalDisk disk = new KVMPhysicalDisk(diskFilePath, volumeId, pool);
103+
KVMPhysicalDisk disk = new KVMPhysicalDisk(diskFilePath, volumePath, pool);
102104
disk.setFormat(QemuImg.PhysicalDiskFormat.RAW);
103105

104106
long diskSize = getPhysicalDiskSize(diskFilePath);
@@ -107,8 +109,8 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeId, KVMStoragePool pool) {
107109

108110
return disk;
109111
} catch (Exception e) {
110-
LOGGER.error("Failed to get the physical disk: " + volumeId + " on the storage pool: " + pool.getUuid() + " due to " + e.getMessage());
111-
throw new CloudRuntimeException("Failed to get the physical disk: " + volumeId + " on the storage pool: " + pool.getUuid());
112+
LOGGER.error("Failed to get the physical disk: " + volumePath + " on the storage pool: " + pool.getUuid() + " due to " + e.getMessage());
113+
throw new CloudRuntimeException("Failed to get the physical disk: " + volumePath + " on the storage pool: " + pool.getUuid());
112114
}
113115
}
114116

@@ -136,6 +138,8 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S
136138
throw new CloudRuntimeException("Unable to connect physical disk due to insufficient data");
137139
}
138140

141+
volumePath = ScaleIOUtil.getVolumePath(volumePath);
142+
139143
int waitTimeInSec = DEFAULT_DISK_WAIT_TIME_IN_SECS;
140144
if (details != null && details.containsKey(StorageManager.STORAGE_POOL_DISK_WAIT.toString())) {
141145
String waitTime = details.get(StorageManager.STORAGE_POOL_DISK_WAIT.toString());

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/storage/ScaleIOStoragePoolTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ public void testDefaults() {
100100
}
101101

102102
public void testGetPhysicalDiskWithWildcardFileFilter() throws Exception {
103-
final String volumePath = "6c3362b500000001";
103+
final String volumePath = "6c3362b500000001:vol-139-3d2c-12f0";
104104
final String systemId = "218ce1797566a00f";
105105

106106
File dir = PowerMockito.mock(File.class);
107107
PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(dir);
108108

109109
// TODO: Mock file in dir
110110
File[] files = new File[1];
111-
String diskFilePath = ScaleIOUtil.DISK_PATH + File.separator + ScaleIOUtil.DISK_NAME_PREFIX + systemId + "-" + volumePath;
111+
String volumeId = ScaleIOUtil.getVolumePath(volumePath);
112+
String diskFilePath = ScaleIOUtil.DISK_PATH + File.separator + ScaleIOUtil.DISK_NAME_PREFIX + systemId + "-" + volumeId;
112113
files[0] = new File(diskFilePath);
113114
PowerMockito.when(dir.listFiles(any(FileFilter.class))).thenReturn(files);
114115

@@ -118,10 +119,11 @@ public void testGetPhysicalDiskWithWildcardFileFilter() throws Exception {
118119

119120
@Test
120121
public void testGetPhysicalDiskWithSystemId() throws Exception {
121-
final String volumePath = "6c3362b500000001";
122+
final String volumePath = "6c3362b500000001:vol-139-3d2c-12f0";
123+
final String volumeId = ScaleIOUtil.getVolumePath(volumePath);
122124
final String systemId = "218ce1797566a00f";
123125
PowerMockito.mockStatic(ScaleIOUtil.class);
124-
when(ScaleIOUtil.getSystemIdForVolume(volumePath)).thenReturn(systemId);
126+
when(ScaleIOUtil.getSystemIdForVolume(volumeId)).thenReturn(systemId);
125127

126128
// TODO: Mock file exists
127129
File file = PowerMockito.mock(File.class);
@@ -134,17 +136,18 @@ public void testGetPhysicalDiskWithSystemId() throws Exception {
134136

135137
@Test
136138
public void testConnectPhysicalDisk() {
137-
final String volumePath = "6c3362b500000001";
139+
final String volumePath = "6c3362b500000001:vol-139-3d2c-12f0";
140+
final String volumeId = ScaleIOUtil.getVolumePath(volumePath);
138141
final String systemId = "218ce1797566a00f";
139-
final String diskFilePath = ScaleIOUtil.DISK_PATH + File.separator + ScaleIOUtil.DISK_NAME_PREFIX + systemId + "-" + volumePath;
142+
final String diskFilePath = ScaleIOUtil.DISK_PATH + File.separator + ScaleIOUtil.DISK_NAME_PREFIX + systemId + "-" + volumeId;
140143
KVMPhysicalDisk disk = new KVMPhysicalDisk(diskFilePath, volumePath, pool);
141144
disk.setFormat(QemuImg.PhysicalDiskFormat.RAW);
142145
disk.setSize(8192);
143146
disk.setVirtualSize(8192);
144147

145148
assertEquals(disk.getPath(), "/dev/disk/by-id/emc-vol-218ce1797566a00f-6c3362b500000001");
146149

147-
when(adapter.getPhysicalDisk(volumePath, pool)).thenReturn(disk);
150+
when(adapter.getPhysicalDisk(volumeId, pool)).thenReturn(disk);
148151

149152
final boolean result = adapter.connectPhysicalDisk(volumePath, pool, null);
150153
assertTrue(result);

0 commit comments

Comments
 (0)