Esempio n. 1
0
        private void RevertTarget(DeploymentParameters parameters)
        {
            string targetInformationFile = parameters.DeploymentSpecification.GetTargetInformationFile();

            if (!File.Exists(targetInformationFile))
            {
                DeployerTrace.WriteInfo("TargetInformation.xml file not found. Return as no operation is needed.");
                return;
            }

            TargetInformationType targetInfo = XmlHelper.ReadXml <TargetInformationType>(targetInformationFile);

            if (targetInfo.CurrentInstallation == null)
            {
                DeployerTrace.WriteInfo("No current information. No operation to be done.");
                return;
            }

            TargetInformationType newTargetInfo = new TargetInformationType();

            newTargetInfo.TargetInstallation  = targetInfo.CurrentInstallation;
            newTargetInfo.CurrentInstallation = targetInfo.TargetInstallation;
            XmlHelper.WriteXml <TargetInformationType>(targetInformationFile, newTargetInfo);

            // Do not need to reinstall the old MSI on rollback on linux. The updater service takes care of this
#if !DotNetCoreClrLinux
            if (!string.IsNullOrEmpty(targetInfo.CurrentInstallation.MSILocation))
            {
                string[] batFileContent = new string[4];
                batFileContent[0] = "sc stop FabricHostSvc";
                batFileContent[1] = "TIMEOUT /T 10";
                batFileContent[2] = string.Format(
                    CultureInfo.InvariantCulture,
                    "msiexec /i \"{0}\" /lv \"{1}\" /q IACCEPTEULA=Yes",
                    targetInfo.CurrentInstallation.MSILocation,
                    parameters.DeploymentSpecification.GetInstallerLogFile("Revert", Utility.GetCurrentCodeVersion(null)));
                batFileContent[3] = "sc start FabrichostSvc";
                string installerScriptFileLocation = parameters.DeploymentSpecification.GetInstallerScriptFile("Revert");
                File.WriteAllLines(installerScriptFileLocation, batFileContent);
                ExecuteScript(installerScriptFileLocation);
            }
#endif
        }
Esempio n. 2
0
        private static void WriteTargetInformationFile(string fabricDataRoot, string machineName, bool deleteLog, string nodeName)
        {
            string targetInformationFileName = Path.Combine(fabricDataRoot, Constants.FileNames.TargetInformation);

            DeployerTrace.WriteNoise("targetInformationFileName is {0}", targetInformationFileName);
            if (!string.IsNullOrEmpty(machineName) && !machineName.Equals(Helpers.GetMachine()))
            {
                targetInformationFileName = Helpers.GetRemotePath(targetInformationFileName, machineName);
            }

            DeployerTrace.WriteInfo("Creating target information file {0} to be written on machine {1}", targetInformationFileName, machineName);
            TargetInformationType targetInformation = new TargetInformationType();

            targetInformation.CurrentInstallation = new WindowsFabricDeploymentInformation();
            targetInformation.CurrentInstallation.UndoUpgradeEntryPointExe           = "FabricSetup.exe";
            targetInformation.CurrentInstallation.UndoUpgradeEntryPointExeParameters = string.Format("/operation:Uninstall {0}", deleteLog ? "/deleteLog:true" : "");
            targetInformation.CurrentInstallation.NodeName = nodeName;

            DeployerTrace.WriteInfo("Writing Target information file {0} on machine {1}", targetInformationFileName, machineName);
            XmlHelper.WriteXmlExclusive <TargetInformationType>(targetInformationFileName, targetInformation);
        }
        internal void WriteTargetInformationFile(string clusterManifestLocation, string infrastructureManifestLocation, string fabricDataRoot, string machineName, string packageLocation, FabricPackageType fabricPackageType, string sourcePackageLocation)
        {
            ReleaseAssert.AssertIfNull(fabricDataRoot, "DataRoot Should not be null after configuration");
            TargetInformationType targetInformation = new TargetInformationType
            {
                TargetInstallation = new WindowsFabricDeploymentInformation
                {
                    TargetVersion                  = Utility.GetCurrentCodeVersion(sourcePackageLocation),
                    ClusterManifestLocation        = clusterManifestLocation,
                    UpgradeEntryPointExe           = "FabricSetup.exe",
                    UpgradeEntryPointExeParameters = "/operation:Install"
                }
            };

            if (fabricPackageType == FabricPackageType.XCopyPackage)
            {
                targetInformation.TargetInstallation.MSILocation = packageLocation;
            }

            if (!string.IsNullOrEmpty(infrastructureManifestLocation))
            {
                targetInformation.TargetInstallation.InfrastructureManifestLocation = infrastructureManifestLocation;
            }

            string targetInformationFileName = Path.Combine(fabricDataRoot, Constants.FileNames.TargetInformation);

            DeployerTrace.WriteInfo("TargetInformationFileName is {0}", targetInformationFileName);
            if (!string.IsNullOrEmpty(machineName) && !machineName.Equals(Helpers.GetMachine()))
            {
                targetInformation.TargetInstallation.ClusterManifestLocation = Path.Combine(fabricDataRoot, "clusterManifest.xml");
                targetInformationFileName = Helpers.GetRemotePath(targetInformationFileName, machineName);
            }

            XmlHelper.WriteXmlExclusive <TargetInformationType>(targetInformationFileName, targetInformation);
            DeployerTrace.WriteInfo("Target information file {0} written on machine: {1}", targetInformationFileName, machineName);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strFileName"></param>
        /// <param name="infomationType"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public string GetTargetInformation(string strFileName, TargetInformationType infomationType, ref string strError)
        {
            try
            {
                // Validation
                if (infomationType == TargetInformationType.Unknown)
                {
                    return("");
                }

                SvnTarget target = SvnTarget.FromString(strFileName);

                SvnInfoEventArgs args;

                // Get Target Info
                bool boolRetrievedInfo = this.Connection.GetInfo(target, out args);

                // Validation
                if (boolRetrievedInfo == false || args == null)
                {
                    return("");
                }

                // Determine Information Type
                switch (infomationType)
                {
                case TargetInformationType.ChangeList:
                {
                    return(args.ChangeList);
                }

                case TargetInformationType.Checksum:
                {
                    return(args.Checksum);
                }

                case TargetInformationType.Conflicts:
                {
                    List <string> listConflicts = (args.Conflicts != null) ?
                                                  args.Conflicts.Select(conflict =>
                                                                        "Name: " + conflict.Name +
                                                                        ". Type: " + conflict.ConflictType.ToString() +
                                                                        ". Reason: " + conflict.ConflictReason.ToString() +
                                                                        ". Action: " + conflict.ConflictAction.ToString()).ToList() :
                                                  new List <string>();

                    return(string.Join("\r\n", listConflicts.ToArray()));
                }

                case TargetInformationType.ContentTime:
                {
                    return(args.ContentTime.ToString());
                }

                case TargetInformationType.Depth:
                {
                    return(args.Depth.ToString());
                }

                case TargetInformationType.FullPath:
                {
                    return(args.FullPath);
                }

                case TargetInformationType.LastChangeAuthor:
                {
                    return(args.LastChangeAuthor);
                }

                case TargetInformationType.LastChangeRevision:
                {
                    return(args.LastChangeRevision.ToString());
                }

                case TargetInformationType.LastChangeTime:
                {
                    return(args.LastChangeTime.ToString());
                }

                case TargetInformationType.MovedFrom:
                {
                    return(args.MovedFrom);
                }

                case TargetInformationType.MovedTo:
                {
                    return(args.MovedTo);
                }

                case TargetInformationType.NodeKind:
                {
                    return(args.NodeKind.ToString());
                }

                case TargetInformationType.Path:
                {
                    return(args.Path);
                }

                case TargetInformationType.RepositoryId:
                {
                    return(args.RepositoryId.ToString());
                }

                case TargetInformationType.RepositoryRoot:
                {
                    return(args.RepositoryRoot.AbsolutePath);
                }

                case TargetInformationType.RepositorySize:
                {
                    return(args.RepositorySize.ToString());
                }

                case TargetInformationType.Revision:
                {
                    return(args.Revision.ToString());
                }

                case TargetInformationType.Schedule:
                {
                    return(args.Schedule.ToString());
                }

                case TargetInformationType.TreeConflict:
                {
                    return(args.TreeConflict.FullPath);
                }

                case TargetInformationType.Uri:
                {
                    return(args.Uri.AbsolutePath);
                }

                case TargetInformationType.WorkingCopySize:
                {
                    return(args.WorkingCopySize.ToString());
                }
                }

                return("");
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                Console.WriteLine(strError);

                return("");
            }
        }