Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void UpdateServiceBinary(string node)
        {
            //reload profile
            profile.LoadProfile();
            var localImagePath  = profile.SvcInstallMediaLoc;
            var remoteImagePath = this.oshelper.GetServiceImagePath(profile.ServiceBinFullName, node);

            if (string.IsNullOrEmpty(remoteImagePath))
            {
                this.logger.LogDebug($@"[{this.GetHashCode()}]{node} does not have {remoteImagePath}, let me fix it now ...");
                //if remoteImagePath being empty due to no net use and return fail, the net use will be called inside here
                var result = serviceDeployment.DeployService(node, profile, reInstall: false);
                if (result)
                {
                    this.logger.LogDebug($@"[{this.GetHashCode()}]{node} service fixed now.");
                }
                else
                {
                    this.logger.LogDebug($@"[{this.GetHashCode()}]{node} service oops");
                }
            }
            else
            {
                FileVersionInfo fileVersionInfo   = FileVersionInfo.GetVersionInfo(localImagePath);
                FileVersionInfo fileVersionRemote = FileVersionInfo.GetVersionInfo(remoteImagePath);
                if (fileVersionInfo.IsNewer(fileVersionRemote))
                {
                    this.logger.LogDebug($@"[{this.GetHashCode()}]Newer version of image file found {localImagePath}, updating the files on {node}");
                    var result = serviceDeployment.DeployService(node, profile, reInstall: false);
                    if (result)
                    {
                        this.logger.LogDebug($@"[{this.GetHashCode()}]{node} service fixed now.");
                    }
                    else
                    {
                        this.logger.LogDebug($@"[{this.GetHashCode()}]{node} service oops");
                    }
                }
            }
        }