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
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -73,8 +73,13 @@ namespace HypervResource
|
||||
{
|
||||
get
|
||||
{
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["user"]);
|
||||
string user = null;
|
||||
if (uri != null)
|
||||
{
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
user = System.Web.HttpUtility.UrlDecode(queryDictionary["user"]);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,8 +87,13 @@ namespace HypervResource
|
||||
{
|
||||
get
|
||||
{
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["password"]);
|
||||
string password = null;
|
||||
if (uri != null)
|
||||
{
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
password = System.Web.HttpUtility.UrlDecode(queryDictionary["password"]);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,12 +101,17 @@ namespace HypervResource
|
||||
{
|
||||
get
|
||||
{
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
if (queryDictionary["domain"] != null)
|
||||
string domain = null;
|
||||
if (uri != null)
|
||||
{
|
||||
return System.Web.HttpUtility.UrlDecode(queryDictionary["domain"]);
|
||||
var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
|
||||
if (queryDictionary["domain"] != null)
|
||||
{
|
||||
domain = System.Web.HttpUtility.UrlDecode(queryDictionary["domain"]);
|
||||
}
|
||||
else domain = uri.Host;
|
||||
}
|
||||
else return uri.Host;
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1474,15 +1474,8 @@ namespace HypervResource
|
||||
{
|
||||
// TODO: thin provision instead of copying the full file.
|
||||
File.Copy(srcFile, destFile);
|
||||
VolumeObjectTO volume = new VolumeObjectTO();
|
||||
volume.path = destFile;
|
||||
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);
|
||||
destVolumeObjectTO.path = destFile;
|
||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user