Пример #1
0
        private Mock <Pool_patch> SetupBuilder(after_apply_guidance guidance, out string msg, out Mock <Host> host)
        {
            Mock <Pool_patch> patch = ObjectManager.NewXenObject <Pool_patch>(id);

            host = ObjectManager.NewXenObject <Host>(id);
            host.Setup(h => h.IsMaster()).Returns(true);
            host.Setup(h => h.Name).Returns("MyHost");

            if (guidance == after_apply_guidance.restartHost)
            {
                host.Setup(h => h.uuid).Returns("MyHostUUID");
            }

            host.Setup(h => h.patches).Returns(new List <XenRef <Host_patch> >());
            patch.Setup(p => p.after_apply_guidance).Returns(new List <after_apply_guidance> {
                guidance
            });

            bool outBool;

            msg = PatchingWizardModeGuidanceBuilder.ModeRetailPatch(new List <Host> {
                host.Object
            }, patch.Object, new Dictionary <string, LivePatchCode>(), out outBool);
            return(patch);
        }
 public void CheckCanEvacuatePreCheckPresence(after_apply_guidance guidance, bool expected)
 {
     AccessiblePreCheckPage page = new AccessiblePreCheckPage();
     Mock<Pool_patch> patch = ObjectManager.NewXenObject<Pool_patch>(id);
     patch.Setup(p => p.after_apply_guidance).Returns(new List<after_apply_guidance> {guidance});
     IEnumerable<KeyValuePair<string, List<Check>>> generatedChecks = page.GetGenerateChecks(patch.Object);
     Assert.That(generatedChecks.Any(kvp=>kvp.Key == Messages.CHECKING_CANEVACUATE_STATUS), Is.EqualTo(expected));
 }
 private Mock<Pool_patch> SetupBuilder(after_apply_guidance guidance, out string msg, out Mock<Host> host)
 {
     Mock<Pool_patch> patch = ObjectManager.NewXenObject<Pool_patch>(id);
     host = ObjectManager.NewXenObject<Host>(id);
     host.Setup(h => h.IsMaster()).Returns(true);
     host.Setup(h => h.Name).Returns("MyHost");
     patch.Setup(p => p.after_apply_guidance).Returns(new List<after_apply_guidance> { guidance });
     msg = PatchingWizardModeGuidanceBuilder.ModeRetailPatch(new List<Host> { host.Object }, patch.Object);
     return patch;
 }
        public void CheckCanEvacuatePreCheckPresence(after_apply_guidance guidance, bool expected)
        {
            AccessiblePreCheckPage page  = new AccessiblePreCheckPage();
            Mock <Pool_patch>      patch = ObjectManager.NewXenObject <Pool_patch>(id);

            patch.Setup(p => p.after_apply_guidance).Returns(new List <after_apply_guidance> {
                guidance
            });
            IEnumerable <KeyValuePair <string, List <Check> > > generatedChecks = page.GetGenerateChecks(patch.Object);

            Assert.That(generatedChecks.Any(kvp => kvp.Key == Messages.CHECKING_CANEVACUATE_STATUS), Is.EqualTo(expected));
        }
        private Mock <Pool_patch> SetupBuilder(after_apply_guidance guidance, out string msg, out Mock <Host> host)
        {
            Mock <Pool_patch> patch = ObjectManager.NewXenObject <Pool_patch>(id);

            host = ObjectManager.NewXenObject <Host>(id);
            host.Setup(h => h.IsMaster()).Returns(true);
            host.Setup(h => h.Name).Returns("MyHost");
            patch.Setup(p => p.after_apply_guidance).Returns(new List <after_apply_guidance> {
                guidance
            });
            msg = PatchingWizardModeGuidanceBuilder.ModeRetailPatch(new List <Host> {
                host.Object
            }, patch.Object);
            return(patch);
        }
Пример #6
0
 public static string ToString(after_apply_guidance x)
 {
     switch (x)
     {
         case after_apply_guidance.restartHVM:
             return "restartHVM";
         case after_apply_guidance.restartPV:
             return "restartPV";
         case after_apply_guidance.restartHost:
             return "restartHost";
         case after_apply_guidance.restartXAPI:
             return "restartXAPI";
         default:
             return "unknown";
     }
 }
        private Mock<Pool_patch> SetupBuilder(after_apply_guidance guidance, out string msg, out Mock<Host> host)
        {
            Mock<Pool_patch> patch = ObjectManager.NewXenObject<Pool_patch>(id);

            host = ObjectManager.NewXenObject<Host>(id);
            host.Setup(h => h.IsMaster()).Returns(true);
            host.Setup(h => h.Name).Returns("MyHost");

            if (guidance == after_apply_guidance.restartHost)
                host.Setup(h => h.uuid).Returns("MyHostUUID");

            host.Setup(h => h.patches).Returns(new List<XenRef<Host_patch>>());
            patch.Setup(p => p.after_apply_guidance).Returns(new List<after_apply_guidance> { guidance });
            bool outBool;
            msg = PatchingWizardModeGuidanceBuilder.ModeRetailPatch(new List<Host> { host.Object }, patch.Object, out outBool);
            return patch;
        }
Пример #8
0
        private static string GetGuideMessage(after_apply_guidance guidance)
        {
            switch (guidance)
            {
            case after_apply_guidance.restartXAPI:
                return(Messages.PATCHINGWIZARD_MODEPAGE_RESTARTXAPI);

            case after_apply_guidance.restartHost:
                return(Messages.PATCHINGWIZARD_MODEPAGE_RESTARTSERVERS);

            case after_apply_guidance.restartHVM:
            case after_apply_guidance.restartPV:
                return(Messages.PATCHINGWIZARD_MODEPAGE_RESTARTVMS);

            default:
                return(Messages.PATCHINGWIZARD_MODEPAGE_UNKNOWNACTION);
            }
        }
Пример #9
0
        public static string ToString(after_apply_guidance x)
        {
            switch (x)
            {
            case after_apply_guidance.restartHVM:
                return("restartHVM");

            case after_apply_guidance.restartPV:
                return("restartPV");

            case after_apply_guidance.restartHost:
                return("restartHost");

            case after_apply_guidance.restartXAPI:
                return("restartXAPI");
            }
            return("unknown");
        }
Пример #10
0
        private PlanAction GetAfterApplyGuidanceAction(Host host, after_apply_guidance guidance)
        {
            switch (guidance)
            {
            case after_apply_guidance.restartHost:
                return(new RestartHostPlanAction(host, host.GetRunningVMs(), true, false, hostsThatWillRequireReboot));

            case after_apply_guidance.restartXAPI:
                return(new RestartAgentPlanAction(host));

            case after_apply_guidance.restartHVM:
                return(new RebootVMsPlanAction(host, host.GetRunningHvmVMs()));

            case after_apply_guidance.restartPV:
                return(new RebootVMsPlanAction(host, host.GetRunningPvVMs()));

            default:
                return(null);
            }
        }
Пример #11
0
        public static string StringOf(this after_apply_guidance x)
        {
            switch (x)
            {
            case after_apply_guidance.restartHVM:
                return("restartHVM");

            case after_apply_guidance.restartPV:
                return("restartPV");

            case after_apply_guidance.restartHost:
                return("restartHost");

            case after_apply_guidance.restartXAPI:
                return("restartXAPI");

            default:
                return("unknown");
            }
        }
Пример #12
0
        private static Dictionary <Pool, StringBuilder> GetGuidanceList(after_apply_guidance guide, Dictionary <Pool, List <Host> > serversPerPool, Dictionary <string, livepatch_status> livePatchCodesByHost, out bool someHostMayRequireRestart)
        {
            someHostMayRequireRestart = false;

            switch (guide)
            {
            case after_apply_guidance.restartHost:
                return(GetGuidanceListRestartHost(serversPerPool, livePatchCodesByHost, out someHostMayRequireRestart));

            case after_apply_guidance.restartXAPI:
                return(GetGuidanceListRestartXapi(serversPerPool));

            case after_apply_guidance.restartPV:
                return(GetGuidanceListRestartVm(serversPerPool, vm => !vm.IsHVM()));

            case after_apply_guidance.restartHVM:
                return(GetGuidanceListRestartVm(serversPerPool, vm => vm.IsHVM()));

            default:
                return(null);
            }
        }
 private string GetGuideMessage(after_apply_guidance guidance)
 {
     switch (guidance)
     {
         case after_apply_guidance.restartXAPI:
             return Messages.PATCHINGWIZARD_MODEPAGE_RESTARTXAPI;
         case after_apply_guidance.restartHost:
             return Messages.PATCHINGWIZARD_MODEPAGE_RESTARTSERVERS;
         case after_apply_guidance.restartHVM:
         case after_apply_guidance.restartPV:
             return Messages.PATCHINGWIZARD_MODEPAGE_RESTARTVMS;
         default:
             return Messages.PATCHINGWIZARD_MODEPAGE_UNKNOWNACTION;
     }
 }
Пример #14
0
 public static string ToString(after_apply_guidance x)
 {
     return(x.StringOf());
 }