mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									05c01a7dc9
								
							
						
					
					
						commit
						5cbb182c6d
					
				| @ -26,4 +26,6 @@ public interface DataStoreTO { | |||||||
|     String getUuid(); |     String getUuid(); | ||||||
| 
 | 
 | ||||||
|     String getUrl(); |     String getUrl(); | ||||||
|  | 
 | ||||||
|  |     String getPathSeparator(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,6 +23,7 @@ public class NfsTO implements DataStoreTO { | |||||||
|     private String _url; |     private String _url; | ||||||
|     private DataStoreRole _role; |     private DataStoreRole _role; | ||||||
|     private String uuid; |     private String uuid; | ||||||
|  |     private static final String pathSeparator = "/"; | ||||||
| 
 | 
 | ||||||
|     public NfsTO() { |     public NfsTO() { | ||||||
| 
 | 
 | ||||||
| @ -65,4 +66,9 @@ public class NfsTO implements DataStoreTO { | |||||||
|     public void setUuid(String uuid) { |     public void setUuid(String uuid) { | ||||||
|         this.uuid = uuid; |         this.uuid = uuid; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getPathSeparator() { | ||||||
|  |         return pathSeparator; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -40,6 +40,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { | |||||||
|     private Date created; |     private Date created; | ||||||
|     private boolean enableRRS; |     private boolean enableRRS; | ||||||
|     private long maxSingleUploadSizeInBytes; |     private long maxSingleUploadSizeInBytes; | ||||||
|  |     private static final String pathSeparator = "/"; | ||||||
| 
 | 
 | ||||||
|     public S3TO() { |     public S3TO() { | ||||||
| 
 | 
 | ||||||
| @ -289,4 +290,9 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getPathSeparator() { | ||||||
|  |         return pathSeparator; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg { | |||||||
| 
 | 
 | ||||||
|     String userName; |     String userName; | ||||||
|     String key; |     String key; | ||||||
|  |     private static final String pathSeparator = "/"; | ||||||
| 
 | 
 | ||||||
|     public SwiftTO() { |     public SwiftTO() { | ||||||
|     } |     } | ||||||
| @ -76,4 +77,9 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg { | |||||||
|     public String getUuid() { |     public String getUuid() { | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getPathSeparator() { | ||||||
|  |         return pathSeparator; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -27,6 +27,7 @@ public class ImageStoreTO implements DataStoreTO { | |||||||
|     private String providerName; |     private String providerName; | ||||||
|     private DataStoreRole role; |     private DataStoreRole role; | ||||||
|     private String uuid; |     private String uuid; | ||||||
|  |     private static final String pathSeparator = "/"; | ||||||
| 
 | 
 | ||||||
|     public ImageStoreTO() { |     public ImageStoreTO() { | ||||||
| 
 | 
 | ||||||
| @ -98,4 +99,9 @@ public class ImageStoreTO implements DataStoreTO { | |||||||
|     public void setUuid(String uuid) { |     public void setUuid(String uuid) { | ||||||
|         this.uuid = uuid; |         this.uuid = uuid; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getPathSeparator() { | ||||||
|  |         return pathSeparator; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -46,6 +46,7 @@ public class PrimaryDataStoreTO implements DataStoreTO { | |||||||
|     private int port; |     private int port; | ||||||
|     private final String url; |     private final String url; | ||||||
|     private Map<String, String> details; |     private Map<String, String> details; | ||||||
|  |     private static final String pathSeparator = "/"; | ||||||
| 
 | 
 | ||||||
|     public PrimaryDataStoreTO(PrimaryDataStore dataStore) { |     public PrimaryDataStoreTO(PrimaryDataStore dataStore) { | ||||||
|         this.uuid = dataStore.getUuid(); |         this.uuid = dataStore.getUuid(); | ||||||
| @ -122,6 +123,11 @@ public class PrimaryDataStoreTO implements DataStoreTO { | |||||||
|         this.port = port; |         this.port = port; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @Override | ||||||
|  |     public String getPathSeparator() { | ||||||
|  |         return pathSeparator; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     @Override |     @Override | ||||||
|     public String toString() { |     public String toString() { | ||||||
|         return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid) |         return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid) | ||||||
|  | |||||||
| @ -109,7 +109,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                 return new AttachAnswer("Can't attach a iso which is not created on nfs: "); |                 return new AttachAnswer("Can't attach a iso which is not created on nfs: "); | ||||||
|             } |             } | ||||||
|             NfsTO nfsStore = (NfsTO) store; |             NfsTO nfsStore = (NfsTO) store; | ||||||
|             isoURL = nfsStore.getUrl() + File.separator + data.getPath(); |             isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         String vmName = cmd.getVmName(); |         String vmName = cmd.getVmName(); | ||||||
| @ -290,7 +290,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                 return new AttachAnswer("Can't attach a iso which is not created on nfs: "); |                 return new AttachAnswer("Can't attach a iso which is not created on nfs: "); | ||||||
|             } |             } | ||||||
|             NfsTO nfsStore = (NfsTO) store; |             NfsTO nfsStore = (NfsTO) store; | ||||||
|             isoURL = nfsStore.getUrl() + File.separator + data.getPath(); |             isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
| @ -933,7 +933,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                 SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid()); |                 SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid()); | ||||||
|                 String srUuid = primaryStoragePool.getUuid(conn); |                 String srUuid = primaryStoragePool.getUuid(conn); | ||||||
|                 URI uri = new URI(nfsStore.getUrl()); |                 URI uri = new URI(nfsStore.getUrl()); | ||||||
|                 String volumePath = uri.getHost() + ":" + uri.getPath() + File.separator + srcVolume.getPath(); |                 String volumePath = uri.getHost() + ":" + uri.getPath() + nfsStore.getPathSeparator() + srcVolume.getPath(); | ||||||
|                 String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait); |                 String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait); | ||||||
|                 VolumeObjectTO newVol = new VolumeObjectTO(); |                 VolumeObjectTO newVol = new VolumeObjectTO(); | ||||||
|                 newVol.setPath(uuid); |                 newVol.setPath(uuid); | ||||||
| @ -970,7 +970,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 // Create a SR for the volume UUID folder |                 // Create a SR for the volume UUID folder | ||||||
|                 secondaryStorage = hypervisorResource.createNfsSRbyURI(conn, new URI(nfsStore.getUrl() + File.separator + destVolume.getPath()), false); |                 secondaryStorage = hypervisorResource.createNfsSRbyURI(conn, new URI(nfsStore.getUrl() + nfsStore.getPathSeparator() + destVolume.getPath()), false); | ||||||
|                 // Look up the volume on the source primary storage pool |                 // Look up the volume on the source primary storage pool | ||||||
|                 VDI srcVdi = getVDIbyUuid(conn, srcVolume.getPath()); |                 VDI srcVdi = getVDIbyUuid(conn, srcVolume.getPath()); | ||||||
|                 // Copy the volume to secondary storage |                 // Copy the volume to secondary storage | ||||||
| @ -978,7 +978,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                 String destVolumeUUID = destVdi.getUuid(conn); |                 String destVolumeUUID = destVdi.getUuid(conn); | ||||||
| 
 | 
 | ||||||
|                 VolumeObjectTO newVol = new VolumeObjectTO(); |                 VolumeObjectTO newVol = new VolumeObjectTO(); | ||||||
|                 newVol.setPath(destVolume.getPath() + File.separator + destVolumeUUID + ".vhd"); |                 newVol.setPath(destVolume.getPath() + nfsStore.getPathSeparator() + destVolumeUUID + ".vhd"); | ||||||
|                 newVol.setSize(srcVolume.getSize()); |                 newVol.setSize(srcVolume.getSize()); | ||||||
|                 return new CopyCmdAnswer(newVol); |                 return new CopyCmdAnswer(newVol); | ||||||
|             } catch (Exception e) { |             } catch (Exception e) { | ||||||
| @ -1282,7 +1282,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                         } |                         } | ||||||
|                         // finalPath = folder + File.separator + snapshotBackupUuid; |                         // finalPath = folder + File.separator + snapshotBackupUuid; | ||||||
|                     } else { |                     } else { | ||||||
|                         finalPath = folder + File.separator + snapshotBackupUuid; |                         finalPath = folder + cacheStore.getPathSeparator() + snapshotBackupUuid; | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                 } finally { |                 } finally { | ||||||
| @ -1310,7 +1310,7 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|                     String[] tmp = results.split("#"); |                     String[] tmp = results.split("#"); | ||||||
|                     snapshotBackupUuid = tmp[1]; |                     snapshotBackupUuid = tmp[1]; | ||||||
|                     physicalSize = Long.parseLong(tmp[2]); |                     physicalSize = Long.parseLong(tmp[2]); | ||||||
|                     finalPath = folder + File.separator + snapshotBackupUuid; |                     finalPath = folder + cacheStore.getPathSeparator() + snapshotBackupUuid; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             // delete primary snapshots with only the last one left |             // delete primary snapshots with only the last one left | ||||||
| @ -1461,13 +1461,13 @@ public class XenServerStorageProcessor implements StorageProcessor { | |||||||
|             } |             } | ||||||
|             // Get the absolute path of the snapshot on the secondary storage. |             // Get the absolute path of the snapshot on the secondary storage. | ||||||
|             String snapshotInstallPath = snapshot.getPath(); |             String snapshotInstallPath = snapshot.getPath(); | ||||||
|             int index = snapshotInstallPath.lastIndexOf(File.separator); |             int index = snapshotInstallPath.lastIndexOf(nfsImageStore.getPathSeparator()); | ||||||
|             String snapshotName = snapshotInstallPath.substring(index + 1); |             String snapshotName = snapshotInstallPath.substring(index + 1); | ||||||
| 
 | 
 | ||||||
|             if (!snapshotName.startsWith("VHD-") && !snapshotName.endsWith(".vhd")) { |             if (!snapshotName.startsWith("VHD-") && !snapshotName.endsWith(".vhd")) { | ||||||
|                 snapshotInstallPath = snapshotInstallPath + ".vhd"; |                 snapshotInstallPath = snapshotInstallPath + ".vhd"; | ||||||
|             } |             } | ||||||
|             URI snapshotURI = new URI(secondaryStorageUrl + File.separator + snapshotInstallPath); |             URI snapshotURI = new URI(secondaryStorageUrl + nfsImageStore.getPathSeparator() + snapshotInstallPath); | ||||||
|             String snapshotPath = snapshotURI.getHost() + ":" + snapshotURI.getPath(); |             String snapshotPath = snapshotURI.getHost() + ":" + snapshotURI.getPath(); | ||||||
|             String srUuid = primaryStorageSR.getUuid(conn); |             String srUuid = primaryStorageSR.getUuid(conn); | ||||||
|             volumeUUID = copy_vhd_from_secondarystorage(conn, snapshotPath, srUuid, wait); |             volumeUUID = copy_vhd_from_secondarystorage(conn, snapshotPath, srUuid, wait); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user