Esempio n. 1
0
        internal static bool IsFabricInstalled(string machineName)
        {
            bool result = true;

            try
            {
                if (NodeConfiguration.GetNodeConfiguration(machineName) == null &&
                    !FabricDeployerServiceController.ServiceExists(System.Fabric.FabricDeployer.Constants.FabricHostServiceName, machineName))
                {
                    SFDeployerTrace.WriteNoise(StringResources.Info_BPAFabricNotInstalledOnMachine, machineName);
                    result = false;
                }
            }
            catch (System.Fabric.FabricException ex)
            {
                SFDeployerTrace.WriteNoise(StringResources.Info_BPAFabricInstalledHitFabricException_Formatted, machineName, ex);
                result = false;
            }
            catch (System.InvalidOperationException ex /*Internal exception: System.Xml.Schema.InvalidOperationException*/)
            {
                SFDeployerTrace.WriteNoise(StringResources.Info_BPAFabricInstalledHitIOX_Formatted, machineName, ex);
                result = false;
            }

            SFDeployerTrace.WriteNoise(StringResources.Info_BPAFabricInstalledOnMachine, machineName, result);

            return(result);
        }
        private static bool CheckFirewallEnabled(MachineHealthContainer machineHealthContainer)
        {
            SFDeployerTrace.WriteNoise(StringResources.Info_BPAWindowsFirewall);
            Parallel.ForEach(
                machineHealthContainer.GetHealthyMachineNames(),
                (string machineName) =>
            {
                bool result = true;
                try
                {
                    FabricDeployerServiceController.ServiceStartupType type =
                        FabricDeployerServiceController.GetServiceStartupType(machineName, DMConstants.FirewallServiceName);
                    if (type == FabricDeployerServiceController.ServiceStartupType.Disabled)
                    {
                        SFDeployerTrace.WriteError(StringResources.Error_BPAFirewallServiceDisabled, machineName);
                        result = false;
                    }
                }
                catch (Exception ex)
                {
                    SFDeployerTrace.WriteError(StringResources.Error_BPAFirewallServiceQueryException, machineName, ex.Message);
                    result = false;
                }

                try
                {
                    ServiceController firewallSvc  = FabricDeployerServiceController.GetService(DMConstants.FirewallServiceName, machineName);
                    ServiceControllerStatus status = firewallSvc.Status;
                    if (status == ServiceControllerStatus.Stopped || status == ServiceControllerStatus.StopPending)
                    {
                        SFDeployerTrace.WriteError(StringResources.Error_BPAFirewallServiceNotRunning, machineName, status.ToString());
                        result = false;
                    }
                }
                catch (Exception ex)
                {
                    SFDeployerTrace.WriteError(StringResources.Error_BPAFirewallServiceStatusException, machineName, ex.Message);
                    result = false;
                }

                if (!result)
                {
                    machineHealthContainer.MarkMachineAsUnhealthy(machineName);
                }
            });

            return(machineHealthContainer.EnoughHealthyMachines());
        }
        private static bool CheckRemoteRegistryEnabled(MachineHealthContainer machineHealthContainer)
        {
            SFDeployerTrace.WriteNoise(StringResources.Info_BPARemoteRegistry);
            Parallel.ForEach(
                machineHealthContainer.GetHealthyMachineNames(),
                (string machineName) =>
            {
                bool result    = true;
                int retryCount = 5;
                for (int i = 0; i < retryCount; i++)
                {
                    try
                    {
                        FabricDeployerServiceController.ServiceStartupType type =
                            FabricDeployerServiceController.GetServiceStartupType(machineName, DMConstants.RemoteRegistryServiceName);
                        if (type == FabricDeployerServiceController.ServiceStartupType.Disabled)
                        {
                            SFDeployerTrace.WriteError(StringResources.Error_BPARemoteRegistryServiceDisabled, machineName);
                            result = false;
                        }

                        break;
                    }
                    catch (Exception ex)
                    {
                        SFDeployerTrace.WriteError(StringResources.Error_BPARemoteRegistryQueryException, machineName, ex.Message, i);

                        if (i < retryCount - 1)
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(10));
                        }
                        else
                        {
                            result = false;
                        }
                    }
                }

                if (!result)
                {
                    machineHealthContainer.MarkMachineAsUnhealthy(machineName);
                }
            });

            return(machineHealthContainer.EnoughHealthyMachines());
        }