Skip to content

Commit 46de9bb

Browse files
author
unknown
committed
Merge branch 'dev' of https://github.com/azure/azure-powershell into dev
2 parents 60d4dc1 + eab6e9b commit 46de9bb

File tree

12 files changed

+5596
-5366
lines changed

12 files changed

+5596
-5366
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/AEMExtensionTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,24 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
2020
public class AEMExtensionTests
2121
{
2222
[Fact]
23-
[Trait(Category.AcceptanceType, Category.CheckIn)]
2423
public void TestAEMExtensionBasicWindows()
2524
{
2625
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicWindows");
2726
}
2827

2928
[Fact]
30-
[Trait(Category.AcceptanceType, Category.CheckIn)]
3129
public void TestAEMExtensionBasicLinux()
3230
{
3331
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionBasicLinux");
3432
}
3533

3634
[Fact]
37-
[Trait(Category.AcceptanceType, Category.CheckIn)]
3835
public void TestAEMExtensionAdvancedWindows()
3936
{
4037
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedWindows");
4138
}
4239

4340
[Fact]
44-
[Trait(Category.AcceptanceType, Category.CheckIn)]
4541
public void TestAEMExtensionAdvancedLinux()
4642
{
4743
ComputeTestController.NewInstance.RunPsTest("Test-AEMExtensionAdvancedLinux");

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedLinux.json

Lines changed: 1240 additions & 1498 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionAdvancedWindows.json

Lines changed: 1699 additions & 1197 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicLinux.json

Lines changed: 957 additions & 1394 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AEMExtensionTests/TestAEMExtensionBasicWindows.json

Lines changed: 1505 additions & 1163 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/AEMExtensionConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class AEMExtensionConstants
2929
public static Dictionary<string, string> WADExtensionDefaultName = new Dictionary<string, string>() { { OSTypeWindows, "IaaSDiagnostics" }, { OSTypeLinux, "LinuxDiagnostic" } };
3030
public static Dictionary<string, string> WADExtensionPublisher = new Dictionary<string, string>() { { OSTypeWindows, "Microsoft.Azure.Diagnostics" }, { OSTypeLinux, "Microsoft.OSTCExtensions" } };
3131
public static Dictionary<string, string> WADExtensionType = new Dictionary<string, string>() { { OSTypeWindows, "IaaSDiagnostics" }, { OSTypeLinux, "LinuxDiagnostic" } };
32-
public static Dictionary<string, Version> WADExtensionVersion = new Dictionary<string, Version>() { { OSTypeWindows, new Version(1,5) }, { OSTypeLinux, new Version(2,2) } };
32+
public static Dictionary<string, Version> WADExtensionVersion = new Dictionary<string, Version>() { { OSTypeWindows, new Version(1,5) }, { OSTypeLinux, new Version(2,3) } };
3333

3434
public const string OSTypeWindows = "Windows";
3535
public const string OSTypeLinux = "Linux";

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/AEMHelper.cs

Lines changed: 107 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -155,75 +155,75 @@ internal AzureSLA GetVMSLA(VirtualMachine virtualMachine)
155155
case "Standard_DS1":
156156
case "Standard_DS1_v2":
157157
result.HasSLA = true;
158-
result.IOPS = "3200";
159-
result.TP = "32";
158+
result.IOPS = 3200;
159+
result.TP = 32;
160160
break;
161161
case "Standard_DS2":
162162
case "Standard_DS2_v2":
163163
result.HasSLA = true;
164-
result.IOPS = "6400";
165-
result.TP = "64";
164+
result.IOPS = 6400;
165+
result.TP = 64;
166166
break;
167167
case "Standard_DS3":
168168
case "Standard_DS3_v2":
169169
result.HasSLA = true;
170-
result.IOPS = "12800";
171-
result.TP = "128";
170+
result.IOPS = 12800;
171+
result.TP = 128;
172172
break;
173173
case "Standard_DS4":
174174
case "Standard_DS4_v2":
175175
result.HasSLA = true;
176-
result.IOPS = "25600";
177-
result.TP = "256";
176+
result.IOPS = 25600;
177+
result.TP = 256;
178178
break;
179179
case "Standard_DS11":
180180
case "Standard_DS11_v2":
181181
result.HasSLA = true;
182-
result.IOPS = "6400";
183-
result.TP = "64";
182+
result.IOPS = 6400;
183+
result.TP = 64;
184184
break;
185185
case "Standard_DS12":
186186
case "Standard_DS12_v2":
187187
result.HasSLA = true;
188-
result.IOPS = "12800";
189-
result.TP = "128";
188+
result.IOPS = 12800;
189+
result.TP = 128;
190190
break;
191191
case "Standard_DS13":
192192
case "Standard_DS13_v2":
193193
result.HasSLA = true;
194-
result.IOPS = "25600";
195-
result.TP = "256";
194+
result.IOPS = 25600;
195+
result.TP = 256;
196196
break;
197197
case "Standard_DS14":
198198
case "Standard_DS14_v2":
199199
result.HasSLA = true;
200-
result.IOPS = "50000";
201-
result.TP = "512";
200+
result.IOPS = 50000;
201+
result.TP = 512;
202202
break;
203203
case "Standard_GS1":
204204
result.HasSLA = true;
205-
result.IOPS = "5000";
206-
result.TP = "125";
205+
result.IOPS = 5000;
206+
result.TP = 125;
207207
break;
208208
case "Standard_GS2":
209209
result.HasSLA = true;
210-
result.IOPS = "10000";
211-
result.TP = "250";
210+
result.IOPS = 10000;
211+
result.TP = 250;
212212
break;
213213
case "Standard_GS3":
214214
result.HasSLA = true;
215-
result.IOPS = "20000";
216-
result.TP = "500";
215+
result.IOPS = 20000;
216+
result.TP = 500;
217217
break;
218218
case "Standard_GS4":
219219
result.HasSLA = true;
220-
result.IOPS = "40000";
221-
result.TP = "1000";
220+
result.IOPS = 40000;
221+
result.TP = 1000;
222222
break;
223223
case "Standard_GS5":
224224
result.HasSLA = true;
225-
result.IOPS = "80000";
226-
result.TP = "2000";
225+
result.IOPS = 80000;
226+
result.TP = 2000;
227227
break;
228228
default:
229229
break;
@@ -305,20 +305,20 @@ internal AzureSLA GetDiskSLA(int? diskSize, string vhdUri)
305305
if (diskSize > 0 && diskSize < 129)
306306
{
307307
// P10
308-
sla.IOPS = "500";
309-
sla.TP = "100";
308+
sla.IOPS = 500;
309+
sla.TP = 100;
310310
}
311311
else if (diskSize > 0 && diskSize < 513)
312312
{
313313
// P20
314-
sla.IOPS = "2300";
315-
sla.TP = "150";
314+
sla.IOPS = 2300;
315+
sla.TP = 150;
316316
}
317317
else if (diskSize > 0 && diskSize < 1025)
318318
{
319319
// P30
320-
sla.IOPS = "5000";
321-
sla.TP = "200";
320+
sla.IOPS = 5000;
321+
sla.TP = 200;
322322
}
323323
else
324324
{
@@ -415,6 +415,20 @@ internal void WriteWarning(string message, params object[] args)
415415
}
416416
}
417417

418+
internal string GetDiskName(string diskPath)
419+
{
420+
Uri diskPathUri;
421+
if (Uri.TryCreate(diskPath, UriKind.Absolute, out diskPathUri))
422+
{
423+
string fileName = diskPathUri.Segments[diskPathUri.Segments.Length - 1];
424+
fileName = Uri.UnescapeDataString(fileName);
425+
426+
return fileName;
427+
}
428+
429+
return "UKNOWN";
430+
}
431+
418432
internal VirtualMachineExtension GetExtension(VirtualMachine vm, string type, string publisher)
419433
{
420434
if (vm.Resources != null)
@@ -454,7 +468,7 @@ internal Version GetExtensionVersion(VirtualMachine vm, VirtualMachineInstanceVi
454468
{
455469
string strExtVersion = extensionStatus.TypeHandlerVersion;
456470
Version extVersion;
457-
if (Version.TryParse(strExtVersion, out extVersion))
471+
if (Version.TryParse(strExtVersion, out extVersion) && extVersion > version)
458472
{
459473
version = extVersion;
460474
}
@@ -479,18 +493,32 @@ internal VirtualMachineExtensionInstanceView GetExtension(VirtualMachine vm, Vir
479493
return vmStatus.Extensions.FirstOrDefault(extSt => extSt.Name.Equals(ext.Name));
480494
}
481495

482-
internal void CheckMonProp(string CheckMessage, string PropertyName, JObject Properties, string ExpectedValue, AEMTestResult parentResult, bool checkExistance = false)
496+
internal void MonitoringPropertyExists(string CheckMessage, string PropertyName, JObject Properties, AEMTestResult parentResult, bool expectedResult = true)
483497
{
484-
var value = GetMonPropertyValue(PropertyName, Properties);
485-
WriteHost(CheckMessage + "...", false);
498+
bool result = false;
486499

487-
if (!String.IsNullOrEmpty(value) && checkExistance)
500+
WriteHost(CheckMessage + "...", false);
501+
if (Properties != null && Properties["cfg"] != null)
488502
{
489-
parentResult.PartialResults.Add(new AEMTestResult(CheckMessage, true));
490-
WriteHost("OK ", ConsoleColor.Green);
503+
var set = Properties["cfg"].FirstOrDefault((tok) =>
504+
{
505+
JValue jval = (tok["key"] as JValue);
506+
if (jval != null && jval.Value != null)
507+
{
508+
return jval.Value.Equals(PropertyName);
509+
}
510+
511+
return false;
512+
});
513+
514+
if (set != null && set["value"] != null && (set["value"] as JValue) != null)
515+
{
516+
result = true;
517+
518+
}
491519
}
492520

493-
if ((!String.IsNullOrEmpty(value) && String.IsNullOrEmpty(ExpectedValue)) || (value == ExpectedValue))
521+
if (result == expectedResult)
494522
{
495523
parentResult.PartialResults.Add(new AEMTestResult(CheckMessage, true));
496524
WriteHost("OK ", ConsoleColor.Green);
@@ -502,42 +530,64 @@ internal void CheckMonProp(string CheckMessage, string PropertyName, JObject Pro
502530
}
503531
}
504532

505-
internal string GetMonPropertyValue(string PropertyName, JObject Properties)
533+
internal void CheckMonitoringProperty<T>(string CheckMessage, string PropertyName, JObject Properties, T expectedValue, AEMTestResult parentResult)
506534
{
507-
if (Properties == null)
535+
WriteHost(CheckMessage + "...", false);
536+
537+
T value;
538+
if (GetMonPropertyValue<T>(PropertyName, Properties, out value))
508539
{
509-
return null;
540+
if (value != null && value.Equals(expectedValue))
541+
{
542+
parentResult.PartialResults.Add(new AEMTestResult(CheckMessage, true));
543+
WriteHost("OK ", ConsoleColor.Green);
544+
}
545+
else
546+
{
547+
parentResult.PartialResults.Add(new AEMTestResult(CheckMessage, false));
548+
WriteHost("NOT OK ", ConsoleColor.Red);
549+
}
510550
}
511-
if (Properties["cfg"] == null)
551+
else
512552
{
513-
return null;
553+
parentResult.PartialResults.Add(new AEMTestResult(CheckMessage, false));
554+
WriteHost("NOT OK ", ConsoleColor.Red);
555+
}
556+
}
557+
558+
internal bool GetMonPropertyValue<T>(string PropertyName, JObject Properties, out T result)
559+
{
560+
result = default(T);
561+
562+
if (Properties == null || Properties["cfg"] == null)
563+
{
564+
return false;
514565
}
515566

516567
var set = Properties["cfg"].FirstOrDefault((tok) =>
517568
{
518-
JValue jval = (tok["key"] as JValue);
519-
if (jval != null && jval.Value != null)
569+
JValue jvaltok = (tok["key"] as JValue);
570+
if (jvaltok != null && jvaltok.Value != null)
520571
{
521-
return jval.Value.Equals(PropertyName);
572+
return jvaltok.Value.Equals(PropertyName);
522573
}
523574

524575
return false;
525576
});
526-
if (set == null)
527-
{
528-
return null;
529-
}
530-
if (set["value"] == null)
577+
578+
if (set == null || set["value"] == null)
531579
{
532-
return null;
580+
return false;
533581
}
534582

535-
if ((set["value"] as JValue) != null)
583+
JValue jval = (set["value"] as JValue);
584+
if (jval != null && jval.Value != null)
536585
{
537-
return (set["value"] as JValue).Value as string;
586+
result = (set["value"] as JValue).Value<T>();
587+
return true;
538588
}
539-
return null;
540589

590+
return false;
541591
}
542592

543593
internal bool CheckWADConfiguration(System.Xml.XmlDocument CurrentConfig)

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/AzureSLA.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Azure.Commands.Compute
1717
public class AzureSLA
1818
{
1919
public bool HasSLA { get; internal set; }
20-
public string IOPS { get; internal set; }
21-
public string TP { get; internal set; }
20+
public int IOPS { get; internal set; }
21+
public int TP { get; internal set; }
2222
}
2323
}

src/ResourceManager/Compute/Commands.Compute/Extension/AEM/KeyValuePair.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public class KeyValuePair
2222
public string Key { get; set; }
2323

2424
[JsonProperty("value")]
25-
public string Value { get; set; }
25+
public object Value { get; set; }
2626

2727
public KeyValuePair() { }
2828

29-
public KeyValuePair(string key, string value)
29+
public KeyValuePair(string key, object value)
3030
{
3131
this.Key = key;
3232
this.Value = value;

0 commit comments

Comments
 (0)