@@ -558,38 +558,82 @@ private void generateCustomFieldsBox()
558558
559559 private void generatePoolPatchesBox ( )
560560 {
561- Pool pool = xenObject as Pool ;
562- if ( pool == null )
561+ if ( ! ( xenObject is Pool pool ) )
563562 return ;
564563
565564 PDSection s = pdSectionUpdates ;
566565
567- List < KeyValuePair < String , String > > messages = CheckPoolUpdate ( pool ) ;
566+ var messages = CheckPoolUpdate ( pool ) ;
568567 if ( messages . Count > 0 )
569568 {
570- foreach ( KeyValuePair < String , String > kvp in messages )
571- {
569+ foreach ( var kvp in messages )
572570 s . AddEntry ( kvp . Key , kvp . Value ) ;
573- }
574571 }
572+
575573 Host master = Helpers . GetMaster ( xenObject . Connection ) ;
576574 if ( master == null )
577575 return ;
578576
579- var poolAppPatches = poolAppliedPatches ( ) ;
580- if ( ! string . IsNullOrEmpty ( poolAppPatches ) )
577+ var fullyApplied = new List < string > ( ) ;
578+ var partAppliedError = new List < string > ( ) ;
579+ var partApplied = new List < string > ( ) ;
580+
581+ var cache = xenObject . Connection . Cache ;
582+ var allHostCount = xenObject . Connection . Cache . HostCount ;
583+
584+ if ( Helpers . ElyOrGreater ( xenObject . Connection ) )
581585 {
582- s . AddEntry ( FriendlyName ( "Pool_patch.fully_applied" ) , poolAppPatches ) ;
586+ foreach ( var u in cache . Pool_updates )
587+ {
588+ var entry = Helpers . UpdatesFriendlyNameAndVersion ( u ) ;
589+ var appliedHostCount = u . AppliedOnHosts ( ) . Count ;
590+
591+ if ( appliedHostCount == allHostCount )
592+ {
593+ fullyApplied . Add ( entry ) ;
594+ }
595+ else if ( appliedHostCount > 0 )
596+ {
597+ if ( u . EnforceHomogeneity ( ) )
598+ partAppliedError . Add ( entry ) ;
599+ else
600+ partApplied . Add ( entry ) ;
601+ }
602+ }
603+ }
604+ else
605+ {
606+ foreach ( var p in cache . Pool_patches )
607+ {
608+ var entry = p . name_label ;
609+ var appliedHostCount = p . host_patches . Count ;
610+
611+ if ( appliedHostCount == allHostCount )
612+ fullyApplied . Add ( entry ) ;
613+ else if ( appliedHostCount > 0 )
614+ partAppliedError . Add ( entry ) ;
615+ }
616+ }
617+
618+ if ( fullyApplied . Count > 0 )
619+ {
620+ fullyApplied . Sort ( StringUtility . NaturalCompare ) ;
621+ s . AddEntry ( FriendlyName ( "Pool_patch.fully_applied" ) , string . Join ( Environment . NewLine , fullyApplied ) ) ;
583622 }
584623
585- var poolPartPatches = poolPartialPatches ( ) ;
586- if ( ! string . IsNullOrEmpty ( poolPartPatches ) )
624+ if ( partApplied . Count > 0 )
587625 {
588- CommandToolStripMenuItem applypatch = new CommandToolStripMenuItem (
589- new InstallNewUpdateCommand ( Program . MainWindow ) , true ) ;
590- var menuItems = new [ ] { applypatch } ;
626+ var menuItems = new [ ] { new CommandToolStripMenuItem ( new InstallNewUpdateCommand ( Program . MainWindow ) , true ) } ;
627+ partApplied . Sort ( StringUtility . NaturalCompare ) ;
628+ s . AddEntry ( FriendlyName ( "Pool_patch.partially_applied" ) , string . Join ( Environment . NewLine , partApplied ) , menuItems ) ;
629+ }
591630
592- s . AddEntry ( FriendlyName ( "Pool_patch.partially_applied" ) , poolPartPatches , menuItems , Color . Red ) ;
631+ if ( partAppliedError . Count > 0 )
632+ {
633+ var menuItems = new [ ] { new CommandToolStripMenuItem ( new InstallNewUpdateCommand ( Program . MainWindow ) , true ) } ;
634+ partAppliedError . Sort ( StringUtility . NaturalCompare ) ;
635+ s . AddEntry ( string . Format ( Messages . STRING_SPACE_STRING , FriendlyName ( "Pool_patch.partially_applied" ) , Messages . UPDATES_GENERAL_TAB_ENFORCE_HOMOGENEITY ) ,
636+ string . Join ( Environment . NewLine , partAppliedError ) , menuItems , Color . Red ) ;
593637 }
594638 }
595639
@@ -1724,59 +1768,6 @@ private static string HVMBootMode(VM vm)
17241768
17251769 #endregion
17261770
1727- #region Pool delegates
1728-
1729- private string poolAppliedPatches ( )
1730- {
1731- return
1732- Helpers . ElyOrGreater ( xenObject . Connection )
1733- ? poolUpdateString ( update => update . AppliedOnHosts ( ) . Count == xenObject . Connection . Cache . HostCount )
1734- : poolPatchString ( patch => patch . host_patches . Count == xenObject . Connection . Cache . HostCount ) ;
1735- }
1736-
1737- private string poolPartialPatches ( )
1738- {
1739- return Helpers . ElyOrGreater ( xenObject . Connection )
1740- ? poolUpdateString ( update =>
1741- {
1742- var appliedOnHosts = update . AppliedOnHosts ( ) ;
1743- return appliedOnHosts . Count > 0 && appliedOnHosts . Count != xenObject . Connection . Cache . HostCount ;
1744- } )
1745- : poolPatchString ( patch => patch . host_patches . Count > 0 && patch . host_patches . Count != xenObject . Connection . Cache . HostCount ) ;
1746- }
1747-
1748- private string poolPatchString ( Predicate < Pool_patch > predicate )
1749- {
1750- Pool_patch [ ] patches = xenObject . Connection . Cache . Pool_patches ;
1751-
1752- List < String > output = new List < String > ( ) ;
1753-
1754- foreach ( Pool_patch patch in patches )
1755- if ( predicate ( patch ) )
1756- output . Add ( patch . name_label ) ;
1757-
1758- output . Sort ( StringUtility . NaturalCompare ) ;
1759-
1760- return string . Join ( Environment . NewLine , output ) ;
1761- }
1762-
1763- private string poolUpdateString ( Predicate < Pool_update > predicate )
1764- {
1765- Pool_update [ ] updates = xenObject . Connection . Cache . Pool_updates ;
1766-
1767- List < String > output = new List < String > ( ) ;
1768-
1769- foreach ( var update in updates )
1770- if ( predicate ( update ) )
1771- output . Add ( Helpers . UpdatesFriendlyNameAndVersion ( update ) ) ;
1772-
1773- output . Sort ( StringUtility . NaturalCompare ) ;
1774-
1775- return string . Join ( Environment . NewLine , output ) ;
1776- }
1777-
1778- #endregion
1779-
17801771 /// <summary>
17811772 /// Checks for reboot warnings on all hosts in the pool and returns them as a list
17821773 /// </summary>
0 commit comments