mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-8418: [Hyper-V] use systemvm.iso from secondary storage and stop copying to local disk
this closes #198
This commit is contained in:
		
							parent
							
								
									c355810034
								
							
						
					
					
						commit
						f86c0a23c1
					
				| @ -1,4 +1,4 @@ | ||||
| // Licensed to the Apache Software Foundation (ASF) under one | ||||
| // Licensed to the Apache Software Foundation (ASF) under one | ||||
| // or more contributor license agreements.  See the NOTICE file | ||||
| // distributed with this work for additional information | ||||
| // regarding copyright ownership.  The ASF licenses this file | ||||
| @ -76,7 +76,6 @@ namespace CloudStack.Plugin.AgentShell | ||||
|             rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName; | ||||
|             rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory; | ||||
|             rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path; | ||||
|             rsrcCnf.systemVmIso = null; | ||||
| 
 | ||||
|             // Side effect:  loads the assembly containing HypervResourceController, which | ||||
|             // allows HttpSelfHostServer to route requests to the controller. | ||||
|  | ||||
| @ -81,7 +81,6 @@ namespace HypervResource | ||||
|         public string RootDeviceName; | ||||
|         public ulong ParentPartitionMinMemoryMb; | ||||
|         public string LocalSecondaryStoragePath; | ||||
|         public string systemVmIso; | ||||
| 
 | ||||
|         private string getPrimaryKey(string id) | ||||
|         { | ||||
| @ -157,7 +156,6 @@ namespace HypervResource | ||||
|         public static HypervResourceControllerConfig config = new HypervResourceControllerConfig(); | ||||
| 
 | ||||
|         private static ILog logger = LogManager.GetLogger(typeof(HypervResourceController)); | ||||
|         private string systemVmIso  = ""; | ||||
|         Dictionary<String, String> contextMap = new Dictionary<String, String>(); | ||||
| 
 | ||||
|         public static void Initialize() | ||||
| @ -1160,39 +1158,25 @@ namespace HypervResource | ||||
| 
 | ||||
|                 try | ||||
|                 { | ||||
|                     string systemVmIsoPath = systemVmIso; | ||||
|                     lock (systemVmIso) | ||||
|                     string systemVmIsoPath = null; | ||||
|                     String uriStr = (String)cmd.secondaryStorage; | ||||
|                     if (!String.IsNullOrEmpty(uriStr)) | ||||
|                     { | ||||
|                         systemVmIsoPath = systemVmIso; | ||||
|                         String uriStr = (String)cmd.secondaryStorage; | ||||
|                         if (!String.IsNullOrEmpty(uriStr)) | ||||
|                         NFSTO share = new NFSTO(); | ||||
|                         share.uri = new Uri(uriStr); | ||||
|                         string defaultDataPath = wmiCallsV2.GetDefaultDataRoot(); | ||||
|                         string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm")); | ||||
|                         string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso"); | ||||
|                         if (choices.Length != 1) | ||||
|                         { | ||||
|                             if (String.IsNullOrEmpty(systemVmIsoPath) || !File.Exists(systemVmIsoPath)) | ||||
|                             { | ||||
|                                 NFSTO share = new NFSTO(); | ||||
|                                 share.uri = new Uri(uriStr); | ||||
|                                 string defaultDataPath = wmiCallsV2.GetDefaultDataRoot(); | ||||
| 
 | ||||
|                                 string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm")); | ||||
|                                 string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso"); | ||||
|                                 if (choices.Length != 1) | ||||
|                                 { | ||||
|                                     String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath; | ||||
|                                     logger.Debug(errMsg); | ||||
|                                 } | ||||
|                                 else | ||||
|                                 { | ||||
|                                     systemVmIsoPath = Utils.NormalizePath(Path.Combine(defaultDataPath, Path.GetFileName(choices[0]))); | ||||
|                                     if (!File.Exists(systemVmIsoPath)) | ||||
|                                     { | ||||
|                                         Utils.DownloadCifsFileToLocalFile(choices[0], share, systemVmIsoPath); | ||||
|                                     } | ||||
|                                     systemVmIso = systemVmIsoPath; | ||||
|                                 } | ||||
|                             } | ||||
|                             String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath; | ||||
|                             logger.Error(errMsg); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             systemVmIsoPath = choices[0]; | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     wmiCallsV2.DeployVirtualMachine(cmd, systemVmIsoPath); | ||||
|                     result = true; | ||||
|                 } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user