public void Go(IContext context) { _context = context; _initializer.Initialize(_context); _invoker.Invoke(_context); _finalizer.Finalize(_context); }
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 }); } }
public void should_delete_temp_file_and_folders() { finalizer.Finalize(new List <string> { "test.txt", "test_directory" }); Assert.That(File.Exists("test.txt"), Is.False); Assert.That(Directory.Exists("test_directory"), Is.False); Assert.That(File.Exists("test_directory\\test4.txt"), Is.False); }
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; } }
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 }); } }