Exemplo n.º 1
0
 private static void RemoveNodeConfigurationXCopy(string machineName, bool deleteLog, string nodeName)
 {
     try
     {
         string fabricDataRoot = Utility.GetFabricDataRoot(machineName);
         if (string.IsNullOrEmpty(fabricDataRoot))
         {
             DeployerTrace.WriteWarning("FabricDataRoot on machine {0} is empty or not present; no current installation likely exists", machineName);
         }
         else
         {
             DeployerTrace.WriteInfo("FabricDataRoot on machine {0} is {1}", machineName, fabricDataRoot);
             FabricDeployerServiceController.GetServiceInStoppedState(machineName, Constants.FabricInstallerServiceName);
             WriteTargetInformationFile(fabricDataRoot, machineName, deleteLog, nodeName);
             RunInstallerService(machineName);
         }
         FabricDeployerServiceController.DeleteFabricInstallerService(machineName);
         Utility.DeleteRegistryKeyTree(machineName);
     }
     catch (TimeoutException)
     {
         DeployerTrace.WriteError("FabricInstallerSvc timeout on machine {0}. Cleaning up to avoid environment corruption.", machineName);
         SuppressExceptions(() => { FabricDeployerServiceController.StopHostSvc(machineName); });
         SuppressExceptions(() => { FabricDeployerServiceController.DeleteFabricHostService(machineName); });
         SuppressExceptions(() => { FabricDeployerServiceController.StopInstallerSvc(machineName); });
         SuppressExceptions(() => { FabricDeployerServiceController.DeleteFabricInstallerService(machineName); });
         SuppressExceptions(() => { Utility.DeleteRegistryKeyTree(machineName); });
         throw;
     }
 }
Exemplo n.º 2
0
        private void RemoveNodeConfigurationMsi(bool deleteLog)
        {
            DeployerTrace.WriteInfo("Checking if fabric host is running");
            if (FabricDeployerServiceController.IsRunning(Helpers.GetMachine()))
            {
                DeployerTrace.WriteInfo("Stopping fabric host");
                FabricDeployerServiceController.StopHostSvc(Helpers.GetMachine());
            }

            string fabricCodePath = String.Empty;

            try
            {
                fabricCodePath = FabricEnvironment.GetCodePath();
            }
            catch (FabricException)
            {
                DeployerTrace.WriteError(StringResources.Error_FabricCodePathNotFound);
            }

            string fabricSetupFilepath = Path.Combine(fabricCodePath, "FabricSetup.exe");

            ProcessStartInfo FabricSetupExeStartInfo = new ProcessStartInfo();

            FabricSetupExeStartInfo.FileName         = fabricSetupFilepath;
            FabricSetupExeStartInfo.Arguments        = string.Format("/operation:removenodestate");
            FabricSetupExeStartInfo.WorkingDirectory = fabricCodePath == String.Empty ? Directory.GetCurrentDirectory() : fabricCodePath;

            try
            {
                using (Process exeProcess = Process.Start(FabricSetupExeStartInfo))
                {
                    DeployerTrace.WriteInfo("Starting FabricSetup.exe");
                    exeProcess.WaitForExit();
                }
            }
            catch (Exception e)
            {
                DeployerTrace.WriteError("Starting FabricSetup.exe failed with exception {0}.", e);
            }

            string value = deleteLog ? DeleteLogTrue : DeleteLogFalse;

            using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(FabricConstants.FabricRegistryKeyPath, true))
            {
                regKey.SetValue(Constants.Registry.RemoveNodeConfigurationValue, value);
            }

            DeployerTrace.WriteInfo("Starting fabric host");
            FabricDeployerServiceController.StartHostSvc();

            DeployerTrace.WriteInfo("Stopping fabric host");
            FabricDeployerServiceController.StopHostSvc();

            DeployerTrace.WriteInfo("Cleaning registry value");
            DeleteRemoveNodeConfigurationRegistryValue(string.Empty);

            DeployerTrace.WriteInfo("Done cleaning registry value");
        }