Skip to content

Commit f960ada

Browse files
CLOUDSTACK-6159 Fixed creating volumes(Root, DataDisk) with uuid in primary store
1 parent e42e876 commit f960ada

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ public string FullFileName
173173
PrimaryDataStoreTO store = this.primaryDataStore;
174174
if (store.isLocal)
175175
{
176-
fileName = Path.Combine(store.Path, this.name);
176+
fileName = Path.Combine(store.Path, this.uuid);
177177
}
178178
else
179179
{
180-
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.name;
180+
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.uuid;
181181
fileName = Utils.NormalizePath(fileName);
182182
}
183183
}
@@ -198,7 +198,7 @@ public string FullFileName
198198
fileName = Utils.NormalizePath(fileName);
199199
if (Directory.Exists(fileName))
200200
{
201-
fileName = Utils.NormalizePath(fileName + @"\" + this.name);
201+
fileName = Utils.NormalizePath(fileName + @"\" + this.uuid);
202202
}
203203
}
204204
}
@@ -300,11 +300,11 @@ private static void GuessFileExtension(VolumeObjectTO volInfo)
300300
path = Utils.NormalizePath(path);
301301
if (Directory.Exists(path))
302302
{
303-
string[] choices = choices = Directory.GetFiles(path, volInfo.name + ".vhd*");
303+
string[] choices = choices = Directory.GetFiles(path, volInfo.uuid + ".vhd*");
304304
if (choices.Length != 1)
305305
{
306306
String errMsg = "Tried to guess file extension, but cannot find file corresponding to " +
307-
Path.Combine(volInfo.primaryDataStore.Path, volInfo.name);
307+
Path.Combine(volInfo.primaryDataStore.Path, volInfo.uuid);
308308
logger.Debug(errMsg);
309309
}
310310
else
@@ -334,18 +334,18 @@ public string FullFileName
334334
PrimaryDataStoreTO store = this.primaryDataStore;
335335
if (store.isLocal)
336336
{
337-
fileName = Path.Combine(store.Path, this.name);
337+
fileName = Path.Combine(store.Path, this.uuid);
338338
}
339339
else
340340
{
341-
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.name;
341+
fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.uuid;
342342
}
343343
fileName = fileName + '.' + this.format.ToLowerInvariant();
344344
}
345345
else if (this.nfsDataStoreTO != null)
346346
{
347347
NFSTO store = this.nfsDataStoreTO;
348-
fileName = store.UncPath + @"\" + this.path + @"\" + this.name;
348+
fileName = store.UncPath + @"\" + this.path + @"\" + this.uuid;
349349
if (!this.format.Equals("RAW"))
350350
{
351351
fileName = fileName + '.' + this.format.ToLowerInvariant();

plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,13 +1168,13 @@ public JContainer CreateObjectCommand([FromBody]dynamic cmd)
11681168

11691169
bool result = false;
11701170
string details = null;
1171-
1171+
object newData = null;
11721172
try
11731173
{
11741174
VolumeObjectTO volume = VolumeObjectTO.ParseJson(cmd.data);
11751175
PrimaryDataStoreTO primary = volume.primaryDataStore;
11761176
ulong volumeSize = volume.size;
1177-
string volumeName = volume.name + ".vhd";
1177+
string volumeName = volume.uuid + ".vhd";
11781178
string volumePath = null;
11791179

11801180
if (primary.isLocal)
@@ -1187,11 +1187,13 @@ public JContainer CreateObjectCommand([FromBody]dynamic cmd)
11871187
volumePath = Utils.NormalizePath(volumePath);
11881188
Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User, primary.Password);
11891189
}
1190-
1190+
volume.path = volumePath;
11911191
wmiCallsV2.CreateDynamicVirtualHardDisk(volumeSize, volumePath);
11921192
if (File.Exists(volumePath))
11931193
{
11941194
result = true;
1195+
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
1196+
newData = ansObj;
11951197
}
11961198
else
11971199
{
@@ -1209,7 +1211,7 @@ public JContainer CreateObjectCommand([FromBody]dynamic cmd)
12091211
{
12101212
result = result,
12111213
details = details,
1212-
data = cmd.data,
1214+
data = newData,
12131215
contextMap = contextMap
12141216
};
12151217

0 commit comments

Comments
 (0)