Exemplo n.º 1
0
        // Clean install requires machine be free of previous Fabric installations
        private static bool CheckForCleanInstall(StandAloneInstallerJsonModelBase config, MachineHealthContainer machineHealthContainer, bool isForcedRun = false)
        {
            SFDeployerTrace.WriteNoise(StringResources.Info_BPANoFabric);

            List <string> machineNamesTemp  = StandaloneUtility.GetMachineNamesIncludingClient(machineHealthContainer.GetHealthyMachineNames());
            var           importantSettings = config.GetFabricSystemSettings();
            string        fabricDataRoot    = importantSettings.ContainsKey(DMConstants.FabricDataRootString) ?
                                              importantSettings[DMConstants.FabricDataRootString] :
                                              null;

            bool localMachineFailed = false;

            Parallel.ForEach(
                machineNamesTemp,
                (string machineName) =>
            {
                bool result = true;
                if (StandaloneUtility.IsFabricInstalled(machineName))
                {
                    SFDeployerTrace.WriteError(StringResources.Error_BPAPreviousFabricExists, machineName);
                    result = false;
                }

                if (!isForcedRun)
                {
                    if (fabricDataRoot != null)
                    {
                        IEnumerable <string> machineNodes = config.Nodes.Where(n => n.IPAddress == machineName).Select(n => n.NodeName);
                        foreach (string node in machineNodes)
                        {
                            string nodeDirectory;
                            if (StandaloneUtility.DataRootNodeExists(machineName, node, fabricDataRoot, out nodeDirectory))
                            {
                                SFDeployerTrace.WriteError(StringResources.Error_BPADataRootNodeExists, node, machineName, nodeDirectory);
                                result = false;
                            }
                        }
                    }
                }

                if (!result)
                {
                    if (Helpers.IsLocalIpAddress(machineName))
                    {
                        localMachineFailed = true;
                    }
                    else
                    {
                        machineHealthContainer.MarkMachineAsUnhealthy(machineName);
                    }
                }
            });

            if (localMachineFailed)
            {
                return(false);
            }

            return(machineHealthContainer.EnoughHealthyMachines());
        }