public ExecutableResult Execute(string value) { var path = ""; if (value == XENTOOLS) { path = XENTOOLS_PATH; } if (value == AGENT) { path = AGENT_PATH; } if (value == AGENT_UPDATER) { path = AGENT_UPDATER_PATH; } return(new ExecutableResult { Output = new[] { _versionChecker.Check(path) } }); }
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 }); } }