Skip to content

Commit 5cbb182

Browse files
Damodar Reddykoushik-das
authored andcommitted
CLOUDSTACK-6636: [Windows] Can not create Template from ROOT snapshot on Windows management server with Xen/NFS storage type. This change is only for XenServer with NFS Storage Server. Will fix remaining when we touch them.
Signed-off-by: Koushik Das <koushik@apache.org>
1 parent 05c01a7 commit 5cbb182

7 files changed

Lines changed: 41 additions & 9 deletions

File tree

api/src/com/cloud/agent/api/to/DataStoreTO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ public interface DataStoreTO {
2626
String getUuid();
2727

2828
String getUrl();
29+
30+
String getPathSeparator();
2931
}

api/src/com/cloud/agent/api/to/NfsTO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class NfsTO implements DataStoreTO {
2323
private String _url;
2424
private DataStoreRole _role;
2525
private String uuid;
26+
private static final String pathSeparator = "/";
2627

2728
public NfsTO() {
2829

@@ -65,4 +66,9 @@ public String getUuid() {
6566
public void setUuid(String uuid) {
6667
this.uuid = uuid;
6768
}
69+
70+
@Override
71+
public String getPathSeparator() {
72+
return pathSeparator;
73+
}
6874
}

api/src/com/cloud/agent/api/to/S3TO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
4040
private Date created;
4141
private boolean enableRRS;
4242
private long maxSingleUploadSizeInBytes;
43+
private static final String pathSeparator = "/";
4344

4445
public S3TO() {
4546

@@ -289,4 +290,9 @@ public boolean getSingleUpload(long objSize) {
289290
}
290291
}
291292
}
293+
294+
@Override
295+
public String getPathSeparator() {
296+
return pathSeparator;
297+
}
292298
}

api/src/com/cloud/agent/api/to/SwiftTO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg {
2626

2727
String userName;
2828
String key;
29+
private static final String pathSeparator = "/";
2930

3031
public SwiftTO() {
3132
}
@@ -76,4 +77,9 @@ public String getEndPoint() {
7677
public String getUuid() {
7778
return null;
7879
}
80+
81+
@Override
82+
public String getPathSeparator() {
83+
return pathSeparator;
84+
}
7985
}

core/src/org/apache/cloudstack/storage/to/ImageStoreTO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ImageStoreTO implements DataStoreTO {
2727
private String providerName;
2828
private DataStoreRole role;
2929
private String uuid;
30+
private static final String pathSeparator = "/";
3031

3132
public ImageStoreTO() {
3233

@@ -98,4 +99,9 @@ public String getUrl() {
9899
public void setUuid(String uuid) {
99100
this.uuid = uuid;
100101
}
102+
103+
@Override
104+
public String getPathSeparator() {
105+
return pathSeparator;
106+
}
101107
}

core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class PrimaryDataStoreTO implements DataStoreTO {
4646
private int port;
4747
private final String url;
4848
private Map<String, String> details;
49+
private static final String pathSeparator = "/";
4950

5051
public PrimaryDataStoreTO(PrimaryDataStore dataStore) {
5152
this.uuid = dataStore.getUuid();
@@ -122,6 +123,11 @@ public void setPort(int port) {
122123
this.port = port;
123124
}
124125

126+
@Override
127+
public String getPathSeparator() {
128+
return pathSeparator;
129+
}
130+
125131
@Override
126132
public String toString() {
127133
return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid)

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public AttachAnswer attachIso(AttachCommand cmd) {
109109
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
110110
}
111111
NfsTO nfsStore = (NfsTO) store;
112-
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
112+
isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath();
113113
}
114114

115115
String vmName = cmd.getVmName();
@@ -290,7 +290,7 @@ public Answer dettachIso(DettachCommand cmd) {
290290
return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
291291
}
292292
NfsTO nfsStore = (NfsTO) store;
293-
isoURL = nfsStore.getUrl() + File.separator + data.getPath();
293+
isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath();
294294
}
295295

296296
try {
@@ -933,7 +933,7 @@ public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
933933
SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid());
934934
String srUuid = primaryStoragePool.getUuid(conn);
935935
URI uri = new URI(nfsStore.getUrl());
936-
String volumePath = uri.getHost() + ":" + uri.getPath() + File.separator + srcVolume.getPath();
936+
String volumePath = uri.getHost() + ":" + uri.getPath() + nfsStore.getPathSeparator() + srcVolume.getPath();
937937
String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait);
938938
VolumeObjectTO newVol = new VolumeObjectTO();
939939
newVol.setPath(uuid);
@@ -970,15 +970,15 @@ public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
970970
}
971971

972972
// Create a SR for the volume UUID folder
973-
secondaryStorage = hypervisorResource.createNfsSRbyURI(conn, new URI(nfsStore.getUrl() + File.separator + destVolume.getPath()), false);
973+
secondaryStorage = hypervisorResource.createNfsSRbyURI(conn, new URI(nfsStore.getUrl() + nfsStore.getPathSeparator() + destVolume.getPath()), false);
974974
// Look up the volume on the source primary storage pool
975975
VDI srcVdi = getVDIbyUuid(conn, srcVolume.getPath());
976976
// Copy the volume to secondary storage
977977
VDI destVdi = hypervisorResource.cloudVDIcopy(conn, srcVdi, secondaryStorage, wait);
978978
String destVolumeUUID = destVdi.getUuid(conn);
979979

980980
VolumeObjectTO newVol = new VolumeObjectTO();
981-
newVol.setPath(destVolume.getPath() + File.separator + destVolumeUUID + ".vhd");
981+
newVol.setPath(destVolume.getPath() + nfsStore.getPathSeparator() + destVolumeUUID + ".vhd");
982982
newVol.setSize(srcVolume.getSize());
983983
return new CopyCmdAnswer(newVol);
984984
} catch (Exception e) {
@@ -1282,7 +1282,7 @@ public Answer backupSnapshot(CopyCommand cmd) {
12821282
}
12831283
// finalPath = folder + File.separator + snapshotBackupUuid;
12841284
} else {
1285-
finalPath = folder + File.separator + snapshotBackupUuid;
1285+
finalPath = folder + cacheStore.getPathSeparator() + snapshotBackupUuid;
12861286
}
12871287

12881288
} finally {
@@ -1310,7 +1310,7 @@ public Answer backupSnapshot(CopyCommand cmd) {
13101310
String[] tmp = results.split("#");
13111311
snapshotBackupUuid = tmp[1];
13121312
physicalSize = Long.parseLong(tmp[2]);
1313-
finalPath = folder + File.separator + snapshotBackupUuid;
1313+
finalPath = folder + cacheStore.getPathSeparator() + snapshotBackupUuid;
13141314
}
13151315
}
13161316
// delete primary snapshots with only the last one left
@@ -1461,13 +1461,13 @@ public Answer createVolumeFromSnapshot(CopyCommand cmd) {
14611461
}
14621462
// Get the absolute path of the snapshot on the secondary storage.
14631463
String snapshotInstallPath = snapshot.getPath();
1464-
int index = snapshotInstallPath.lastIndexOf(File.separator);
1464+
int index = snapshotInstallPath.lastIndexOf(nfsImageStore.getPathSeparator());
14651465
String snapshotName = snapshotInstallPath.substring(index + 1);
14661466

14671467
if (!snapshotName.startsWith("VHD-") && !snapshotName.endsWith(".vhd")) {
14681468
snapshotInstallPath = snapshotInstallPath + ".vhd";
14691469
}
1470-
URI snapshotURI = new URI(secondaryStorageUrl + File.separator + snapshotInstallPath);
1470+
URI snapshotURI = new URI(secondaryStorageUrl + nfsImageStore.getPathSeparator() + snapshotInstallPath);
14711471
String snapshotPath = snapshotURI.getHost() + ":" + snapshotURI.getPath();
14721472
String srUuid = primaryStorageSR.getUuid(conn);
14731473
volumeUUID = copy_vhd_from_secondarystorage(conn, snapshotPath, srUuid, wait);

0 commit comments

Comments
 (0)