mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5689: System vm creation on local storage fails for hyper-v. A
null pointer exception was getting generated when a VolumeTO object was serialized to create an answer object. If a local storage is used the uri field will be null. Added null checks for the same.
This commit is contained in:
parent
f8681de07c
commit
f58d77c8d1
@ -61,7 +61,7 @@ namespace HypervResource
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
string uncPath = null;
|
string uncPath = null;
|
||||||
if (uri.Scheme.Equals("cifs") || uri.Scheme.Equals("networkfilesystem"))
|
if (uri != null && (uri.Scheme.Equals("cifs") || uri.Scheme.Equals("networkfilesystem")))
|
||||||
{
|
{
|
||||||
uncPath = @"\\" + uri.Host + uri.LocalPath;
|
uncPath = @"\\" + uri.Host + uri.LocalPath;
|
||||||
}
|
}
|
||||||
@ -72,31 +72,46 @@ namespace HypervResource
|
|||||||
public string User
|
public string User
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
{
|
||||||
|
string user = null;
|
||||||
|
if (uri != null)
|
||||||
{
|
{
|
||||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["user"]);
|
user = System.Web.HttpUtility.UrlDecode(queryDictionary["user"]);
|
||||||
|
}
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Password
|
public string Password
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
{
|
||||||
|
string password = null;
|
||||||
|
if (uri != null)
|
||||||
{
|
{
|
||||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["password"]);
|
password = System.Web.HttpUtility.UrlDecode(queryDictionary["password"]);
|
||||||
|
}
|
||||||
|
return password;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Domain
|
public string Domain
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
{
|
||||||
|
string domain = null;
|
||||||
|
if (uri != null)
|
||||||
{
|
{
|
||||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||||
if (queryDictionary["domain"] != null)
|
if (queryDictionary["domain"] != null)
|
||||||
{
|
{
|
||||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["domain"]);
|
domain = System.Web.HttpUtility.UrlDecode(queryDictionary["domain"]);
|
||||||
}
|
}
|
||||||
else return uri.Host;
|
else domain = uri.Host;
|
||||||
|
}
|
||||||
|
return domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1474,15 +1474,8 @@ namespace HypervResource
|
|||||||
{
|
{
|
||||||
// TODO: thin provision instead of copying the full file.
|
// TODO: thin provision instead of copying the full file.
|
||||||
File.Copy(srcFile, destFile);
|
File.Copy(srcFile, destFile);
|
||||||
VolumeObjectTO volume = new VolumeObjectTO();
|
destVolumeObjectTO.path = destFile;
|
||||||
volume.path = destFile;
|
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO);
|
||||||
volume.dataStore = destVolumeObjectTO.dataStore;
|
|
||||||
volume.name = destVolumeObjectTO.name;
|
|
||||||
volume.size = ulong.Parse(destVolumeObjectTO.size.ToString());
|
|
||||||
volume.format = destVolumeObjectTO.format;
|
|
||||||
volume.nfsDataStore = destVolumeObjectTO.nfsDataStore;
|
|
||||||
volume.primaryDataStore = destVolumeObjectTO.primaryDataStore;
|
|
||||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
|
|
||||||
newData = ansObj;
|
newData = ansObj;
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user