Пример #1
0
 public ExecutableResult Execute(string value)
 {
     try
     {
         Statics.ShouldPollXenStore = false;
         _logger.Log(String.Format("Updater Update value: {0}\r\nWill resume in 60 seconds", value));
         _sleeper.Sleep(60);
         _connectionChecker.Check();
         var agentUpdateInfo = _agentUpdateMessageHandler.Handle(value);
         _downloader.Download(agentUpdateInfo.url, Constants.UpdaterReleasePackage);
         _checksumValidator.Validate(agentUpdateInfo.signature, Constants.UpdaterReleasePackage);
         _unzipper.Unzip(Constants.UpdaterReleasePackage, Constants.UpdaterUnzipPath, "");
         _serviceStopper.Stop("RackspaceCloudServersAgentUpdater");
         _fileCopier.CopyFiles(Constants.UpdaterUnzipPath, Constants.UpdaterPath, _logger);
         _serviceStarter.Start("RackspaceCloudServersAgentUpdater");
         Statics.ShouldPollXenStore = true;
         return(new ExecutableResult());
     }
     catch (Exception ex)
     {
         _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", ex.Message, ex.StackTrace));
         return(new ExecutableResult {
             Error = new List <string> {
                 "Update failed"
             }, ExitCode = "1"
         });
     }
     finally
     {
         _finalizer.Finalize(new List <string> {
             Constants.UpdaterUnzipPath, Constants.UpdaterReleasePackage
         });
     }
 }
Пример #2
0
        Task IHostedService.StopAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Application stopped");

            _logger.Retry(_options, "ZipDeploy before shutdown", () =>
            {
                if (File.Exists(Path.Combine(Environment.CurrentDirectory, _options.NewPackageFileName)))
                {
                    _logger.LogDebug("Found package {packageName}", _options.NewPackageFileName);
                    _unzipper.Unzip();
                }

                _logger.LogDebug("ZipDeploy completed after process shutdown");
            });

            return(Task.CompletedTask);
        }
Пример #3
0
 public ExecutableResult Execute(string value)
 {
     try
     {
         Statics.ShouldPollXenStore = false;
         _logger.Log(String.Format("XenTools Update value: {0}\r\nWill resume in 60 seconds", value));
         _sleeper.Sleep(60);
         var agentUpdateInfo = _agentUpdateMessageHandler.Handle(value);
         _downloader.Download(agentUpdateInfo.url, Constants.XenToolsReleasePackage);
         _checksumValidator.Validate(agentUpdateInfo.signature, Constants.XenToolsReleasePackage);
         _unzipper.Unzip(Constants.XenToolsReleasePackage, Constants.XenToolsUnzipPath, "");
         _installer.Install(new Dictionary <string, string>
         {
             { Constants.XenToolsSetupExecutablePath,
               String.Format("/S /norestart /D={0}", Constants.XenToolsPath) }
         });
         _serviceRestarter.Restart("xensvc");
         if (_serviceRestarter.ServiceExists("XenServerVssProvider"))
         {
             _serviceRestarter.Restart("XenServerVssProvider");
         }
         return(new ExecutableResult());
     }
     catch (Exception ex)
     {
         _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", ex.Message, ex.StackTrace));
         return(new ExecutableResult {
             Error = new List <string> {
                 "Update failed"
             }, ExitCode = "1"
         });
     }
     finally
     {
         Statics.ShouldPollXenStore = true;
         _finalizer.Finalize(new List <string> {
             Constants.XenToolsUnzipPath, Constants.XenToolsReleasePackage
         });
     }
 }
        public ExecutableResult Execute(string value)
        {
            try
            {
                Statics.ShouldPollXenStore = false;
                _logger.Log(String.Format("XenTools Update value: {0}\r\nWill resume in 60 seconds", value));
                _sleeper.Sleep(60);
                var agentUpdateInfo = _agentUpdateMessageHandler.Handle(value);
                _finalizer.Finalize(new List <string> {
                    Constants.XenToolsUnzipPath, Constants.XenToolsReleasePackage
                });
                _downloader.Download(agentUpdateInfo.url, Constants.XenToolsReleasePackage);
                _checksumValidator.Validate(agentUpdateInfo.signature, Constants.XenToolsReleasePackage);
                _unzipper.Unzip(Constants.XenToolsReleasePackage, Constants.XenToolsUnzipPath, "");

                if (IsCustomPackage())
                {
                    RunCustomPackage();
                }
                else
                {
                    RunLegacyUpdate();
                }

                return(new ExecutableResult());
            }
            catch (Exception ex)
            {
                _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", ex.Message, ex.StackTrace));
                return(new ExecutableResult {
                    Error = new List <string> {
                        "Update failed"
                    }, ExitCode = "1"
                });
            }
            finally
            {
                Statics.ShouldPollXenStore = true;
            }
        }
Пример #5
0
        public ExecutableResult Execute(string value)
        {
            var backupCreated = false;

            try
            {
                Statics.ShouldPollXenStore = false;
                string         versionNumber = _versionChecker.Check(Version.AGENT_UPDATER_PATH);
                System.Version version;

                try
                {
                    version = new System.Version(versionNumber);
                }
                catch (Exception ex)
                {
                    _logger.Log(string.Format("Version check failed, installing embedded updater.  Version Reported: {0}  Stack Trace: {1}", versionNumber, ex));
                    version = new System.Version("0.0.0.0");
                }

                if (version < UpdaterFiles.Updater.MinimumVersion)
                {
                    _logger.Log(String.Format("Updating the Agent Updater... \r\nWill resume in 10 seconds..."));
                    _sleeper.Sleep(10);
                    _extractEmbededResource.Extract(SvcConfiguration.AgentVersionUpdatesPath, Constants.UpdaterEmbeddedReleasePackagePath, Constants.UpdaterReleasePackageName);
                    _logger.Log("Waiting to unzip package.");
                    _unzipper.Unzip(Constants.UpdaterReleasePackage, Constants.UpdaterUnzipPath, "");
                    _serviceStopper.Stop("RackspaceCloudServersAgentUpdater");
                    _backupUpdater.Backup(Constants.UpdaterPath, Constants.UpdaterBackupPath);
                    backupCreated = true;
                    _fileCopier.CopyFiles(Constants.UpdaterUnzipPath, Constants.UpdaterPath, _logger);
                }
                else
                {
                    _logger.Log(string.Format("Agent Updater Version: {0}  detected, not updating updater.", version));
                }

                return(new ExecutableResult());
            }
            catch (Exception ex)
            {
                try
                {
                    if (backupCreated)
                    {
                        _serviceStopper.Stop("RackspaceCloudServersAgentUpdater");
                        _backupUpdater.Restore(Constants.UpdaterPath, Constants.UpdaterBackupPath);
                    }
                }
                catch (Exception exRestore)
                {
                    _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", exRestore.Message, exRestore.StackTrace));
                }

                _logger.Log(String.Format("Exception was : {0}\nStackTrace Was: {1}", ex.Message, ex.StackTrace));
                return(new ExecutableResult {
                    Error = new List <string> {
                        "Update failed"
                    }, ExitCode = "1"
                });
            }
            finally
            {
                Statics.ShouldPollXenStore = true;
                _serviceStarter.Start("RackspaceCloudServersAgentUpdater");
                _finalizer.Finalize(new List <string> {
                    Constants.UpdaterUnzipPath, Constants.UpdaterReleasePackage
                });
            }
        }