@@ -155,75 +155,75 @@ internal AzureSLA GetVMSLA(VirtualMachine virtualMachine)
155
155
case "Standard_DS1" :
156
156
case "Standard_DS1_v2" :
157
157
result . HasSLA = true ;
158
- result . IOPS = " 3200" ;
159
- result . TP = "32" ;
158
+ result . IOPS = 3200 ;
159
+ result . TP = 32 ;
160
160
break ;
161
161
case "Standard_DS2" :
162
162
case "Standard_DS2_v2" :
163
163
result . HasSLA = true ;
164
- result . IOPS = " 6400" ;
165
- result . TP = "64" ;
164
+ result . IOPS = 6400 ;
165
+ result . TP = 64 ;
166
166
break ;
167
167
case "Standard_DS3" :
168
168
case "Standard_DS3_v2" :
169
169
result . HasSLA = true ;
170
- result . IOPS = " 12800" ;
171
- result . TP = " 128" ;
170
+ result . IOPS = 12800 ;
171
+ result . TP = 128 ;
172
172
break ;
173
173
case "Standard_DS4" :
174
174
case "Standard_DS4_v2" :
175
175
result . HasSLA = true ;
176
- result . IOPS = " 25600" ;
177
- result . TP = " 256" ;
176
+ result . IOPS = 25600 ;
177
+ result . TP = 256 ;
178
178
break ;
179
179
case "Standard_DS11" :
180
180
case "Standard_DS11_v2" :
181
181
result . HasSLA = true ;
182
- result . IOPS = " 6400" ;
183
- result . TP = "64" ;
182
+ result . IOPS = 6400 ;
183
+ result . TP = 64 ;
184
184
break ;
185
185
case "Standard_DS12" :
186
186
case "Standard_DS12_v2" :
187
187
result . HasSLA = true ;
188
- result . IOPS = " 12800" ;
189
- result . TP = " 128" ;
188
+ result . IOPS = 12800 ;
189
+ result . TP = 128 ;
190
190
break ;
191
191
case "Standard_DS13" :
192
192
case "Standard_DS13_v2" :
193
193
result . HasSLA = true ;
194
- result . IOPS = " 25600" ;
195
- result . TP = " 256" ;
194
+ result . IOPS = 25600 ;
195
+ result . TP = 256 ;
196
196
break ;
197
197
case "Standard_DS14" :
198
198
case "Standard_DS14_v2" :
199
199
result . HasSLA = true ;
200
- result . IOPS = " 50000" ;
201
- result . TP = " 512" ;
200
+ result . IOPS = 50000 ;
201
+ result . TP = 512 ;
202
202
break ;
203
203
case "Standard_GS1" :
204
204
result . HasSLA = true ;
205
- result . IOPS = " 5000" ;
206
- result . TP = " 125" ;
205
+ result . IOPS = 5000 ;
206
+ result . TP = 125 ;
207
207
break ;
208
208
case "Standard_GS2" :
209
209
result . HasSLA = true ;
210
- result . IOPS = " 10000" ;
211
- result . TP = " 250" ;
210
+ result . IOPS = 10000 ;
211
+ result . TP = 250 ;
212
212
break ;
213
213
case "Standard_GS3" :
214
214
result . HasSLA = true ;
215
- result . IOPS = " 20000" ;
216
- result . TP = " 500" ;
215
+ result . IOPS = 20000 ;
216
+ result . TP = 500 ;
217
217
break ;
218
218
case "Standard_GS4" :
219
219
result . HasSLA = true ;
220
- result . IOPS = " 40000" ;
221
- result . TP = " 1000" ;
220
+ result . IOPS = 40000 ;
221
+ result . TP = 1000 ;
222
222
break ;
223
223
case "Standard_GS5" :
224
224
result . HasSLA = true ;
225
- result . IOPS = " 80000" ;
226
- result . TP = " 2000" ;
225
+ result . IOPS = 80000 ;
226
+ result . TP = 2000 ;
227
227
break ;
228
228
default :
229
229
break ;
@@ -305,20 +305,20 @@ internal AzureSLA GetDiskSLA(int? diskSize, string vhdUri)
305
305
if ( diskSize > 0 && diskSize < 129 )
306
306
{
307
307
// P10
308
- sla . IOPS = " 500" ;
309
- sla . TP = " 100" ;
308
+ sla . IOPS = 500 ;
309
+ sla . TP = 100 ;
310
310
}
311
311
else if ( diskSize > 0 && diskSize < 513 )
312
312
{
313
313
// P20
314
- sla . IOPS = " 2300" ;
315
- sla . TP = " 150" ;
314
+ sla . IOPS = 2300 ;
315
+ sla . TP = 150 ;
316
316
}
317
317
else if ( diskSize > 0 && diskSize < 1025 )
318
318
{
319
319
// P30
320
- sla . IOPS = " 5000" ;
321
- sla . TP = " 200" ;
320
+ sla . IOPS = 5000 ;
321
+ sla . TP = 200 ;
322
322
}
323
323
else
324
324
{
@@ -415,6 +415,20 @@ internal void WriteWarning(string message, params object[] args)
415
415
}
416
416
}
417
417
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
+
418
432
internal VirtualMachineExtension GetExtension ( VirtualMachine vm , string type , string publisher )
419
433
{
420
434
if ( vm . Resources != null )
@@ -454,7 +468,7 @@ internal Version GetExtensionVersion(VirtualMachine vm, VirtualMachineInstanceVi
454
468
{
455
469
string strExtVersion = extensionStatus . TypeHandlerVersion ;
456
470
Version extVersion ;
457
- if ( Version . TryParse ( strExtVersion , out extVersion ) )
471
+ if ( Version . TryParse ( strExtVersion , out extVersion ) && extVersion > version )
458
472
{
459
473
version = extVersion ;
460
474
}
@@ -479,18 +493,32 @@ internal VirtualMachineExtensionInstanceView GetExtension(VirtualMachine vm, Vir
479
493
return vmStatus . Extensions . FirstOrDefault ( extSt => extSt . Name . Equals ( ext . Name ) ) ;
480
494
}
481
495
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 )
483
497
{
484
- var value = GetMonPropertyValue ( PropertyName , Properties ) ;
485
- WriteHost ( CheckMessage + "..." , false ) ;
498
+ bool result = false ;
486
499
487
- if ( ! String . IsNullOrEmpty ( value ) && checkExistance )
500
+ WriteHost ( CheckMessage + "..." , false ) ;
501
+ if ( Properties != null && Properties [ "cfg" ] != null )
488
502
{
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
+ }
491
519
}
492
520
493
- if ( ( ! String . IsNullOrEmpty ( value ) && String . IsNullOrEmpty ( ExpectedValue ) ) || ( value == ExpectedValue ) )
521
+ if ( result == expectedResult )
494
522
{
495
523
parentResult . PartialResults . Add ( new AEMTestResult ( CheckMessage , true ) ) ;
496
524
WriteHost ( "OK " , ConsoleColor . Green ) ;
@@ -502,42 +530,64 @@ internal void CheckMonProp(string CheckMessage, string PropertyName, JObject Pro
502
530
}
503
531
}
504
532
505
- internal string GetMonPropertyValue ( string PropertyName , JObject Properties )
533
+ internal void CheckMonitoringProperty < T > ( string CheckMessage , string PropertyName , JObject Properties , T expectedValue , AEMTestResult parentResult )
506
534
{
507
- if ( Properties == null )
535
+ WriteHost ( CheckMessage + "..." , false ) ;
536
+
537
+ T value ;
538
+ if ( GetMonPropertyValue < T > ( PropertyName , Properties , out value ) )
508
539
{
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
+ }
510
550
}
511
- if ( Properties [ "cfg" ] == null )
551
+ else
512
552
{
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 ;
514
565
}
515
566
516
567
var set = Properties [ "cfg" ] . FirstOrDefault ( ( tok ) =>
517
568
{
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 )
520
571
{
521
- return jval . Value . Equals ( PropertyName ) ;
572
+ return jvaltok . Value . Equals ( PropertyName ) ;
522
573
}
523
574
524
575
return false ;
525
576
} ) ;
526
- if ( set == null )
527
- {
528
- return null ;
529
- }
530
- if ( set [ "value" ] == null )
577
+
578
+ if ( set == null || set [ "value" ] == null )
531
579
{
532
- return null ;
580
+ return false ;
533
581
}
534
582
535
- if ( ( set [ "value" ] as JValue ) != null )
583
+ JValue jval = ( set [ "value" ] as JValue ) ;
584
+ if ( jval != null && jval . Value != null )
536
585
{
537
- return ( set [ "value" ] as JValue ) . Value as string ;
586
+ result = ( set [ "value" ] as JValue ) . Value < T > ( ) ;
587
+ return true ;
538
588
}
539
- return null ;
540
589
590
+ return false ;
541
591
}
542
592
543
593
internal bool CheckWADConfiguration ( System . Xml . XmlDocument CurrentConfig )
0 commit comments