CLOUDSTACK-8418: [Hyper-V] use systemvm.iso from secondary storage and stop copying to local disk

this closes #198
This commit is contained in:
Anshul Gangwar 2015-04-02 15:36:32 +05:30 committed by Rajesh Battala
parent c355810034
commit f86c0a23c1
2 changed files with 16 additions and 33 deletions

View File

@ -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 // or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information // distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file // regarding copyright ownership. The ASF licenses this file
@ -76,7 +76,6 @@ namespace CloudStack.Plugin.AgentShell
rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName; rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName;
rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory; rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory;
rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path; rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path;
rsrcCnf.systemVmIso = null;
// Side effect: loads the assembly containing HypervResourceController, which // Side effect: loads the assembly containing HypervResourceController, which
// allows HttpSelfHostServer to route requests to the controller. // allows HttpSelfHostServer to route requests to the controller.

View File

@ -81,7 +81,6 @@ namespace HypervResource
public string RootDeviceName; public string RootDeviceName;
public ulong ParentPartitionMinMemoryMb; public ulong ParentPartitionMinMemoryMb;
public string LocalSecondaryStoragePath; public string LocalSecondaryStoragePath;
public string systemVmIso;
private string getPrimaryKey(string id) private string getPrimaryKey(string id)
{ {
@ -157,7 +156,6 @@ namespace HypervResource
public static HypervResourceControllerConfig config = new HypervResourceControllerConfig(); public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
private static ILog logger = LogManager.GetLogger(typeof(HypervResourceController)); private static ILog logger = LogManager.GetLogger(typeof(HypervResourceController));
private string systemVmIso = "";
Dictionary<String, String> contextMap = new Dictionary<String, String>(); Dictionary<String, String> contextMap = new Dictionary<String, String>();
public static void Initialize() public static void Initialize()
@ -1160,39 +1158,25 @@ namespace HypervResource
try try
{ {
string systemVmIsoPath = systemVmIso; string systemVmIsoPath = null;
lock (systemVmIso)
{
systemVmIsoPath = systemVmIso;
String uriStr = (String)cmd.secondaryStorage; String uriStr = (String)cmd.secondaryStorage;
if (!String.IsNullOrEmpty(uriStr)) if (!String.IsNullOrEmpty(uriStr))
{
if (String.IsNullOrEmpty(systemVmIsoPath) || !File.Exists(systemVmIsoPath))
{ {
NFSTO share = new NFSTO(); NFSTO share = new NFSTO();
share.uri = new Uri(uriStr); share.uri = new Uri(uriStr);
string defaultDataPath = wmiCallsV2.GetDefaultDataRoot(); string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm")); string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm"));
string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso"); string[] choices = Directory.GetFiles(secondaryPath, "systemvm*.iso");
if (choices.Length != 1) if (choices.Length != 1)
{ {
String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath; String errMsg = "Couldn't locate the systemvm iso on " + secondaryPath;
logger.Debug(errMsg); logger.Error(errMsg);
} }
else else
{ {
systemVmIsoPath = Utils.NormalizePath(Path.Combine(defaultDataPath, Path.GetFileName(choices[0]))); systemVmIsoPath = choices[0];
if (!File.Exists(systemVmIsoPath))
{
Utils.DownloadCifsFileToLocalFile(choices[0], share, systemVmIsoPath);
}
systemVmIso = systemVmIsoPath;
} }
} }
}
}
wmiCallsV2.DeployVirtualMachine(cmd, systemVmIsoPath); wmiCallsV2.DeployVirtualMachine(cmd, systemVmIsoPath);
result = true; result = true;
} }