Exemple #1
0
 public void UpdateServiceCred(string node)
 {
     this.logger.LogDebug($@"[{this.GetHashCode()}]Reloading the profile...");
     //reload profile
     profile.LoadProfile();
     this.logger.LogDebug($@"[{this.GetHashCode()}]Reinstalling the service on {node}...");
     serviceDeployment.DeployService(node, profile, reInstall: true);
 }
Exemple #2
0
        public virtual bool VerifyServiceProfileOnNode(string node)
        {
            var svcImage = this.helper.GetServiceImagePath(ServiceName, node);

            if (!string.IsNullOrEmpty(svcImage))
            {
                if (!svcImage.Equals(ServiceBinFullName, StringComparison.OrdinalIgnoreCase)
                    ||
                    this.ServiceUserPwdChanged(svcImage, node))
                {
                    this.logger.LogWarning("ReInstall service due to profile content not match");
                    if (!serviceDeployment.DeployService(node, this, true))
                    {
                        this.logger.LogWarning("[VerifyServiceProfileOnNode] Service reinstallation for fix profile mismatch failed");
                        return(false);
                    }
                }
                else
                {
                    var             remoteLoc          = $@"\\{node}\{svcImage.Replace(":", "$").Replace("exe","dll")}";
                    var             svcExeNameFileInfo = new FileInfo(remoteLoc);
                    var             localMedia         = Path.Combine(SvcInstallMediaLoc, svcExeNameFileInfo.Name.Replace("exe", "dll"));
                    FileVersionInfo fileVersionInfo    = FileVersionInfo.GetVersionInfo(localMedia);
                    FileVersionInfo fileVersionRemote  = FileVersionInfo.GetVersionInfo(remoteLoc);
                    if (fileVersionInfo.IsNewer(fileVersionRemote))
                    {
                        this.logger.LogInformation($@"Update {remoteLoc} from {fileVersionRemote.FileVersion} to version {fileVersionInfo.FileVersion}, using local media {localMedia}");
                        var result = serviceDeployment.DeployService(node, this, reInstall: true);
                        if (result)
                        {
                            this.logger.LogInformation($@"Update completes");
                        }
                    }
                }
            }
            else
            {
                if (!serviceDeployment.DeployService(node, this, false))
                {
                    this.logger.LogWarning("[VerifyServiceProfileOnNode] Service installation failed, either cred not correct or server not up");
                    return(false);
                }
            }
            return(true);
        }