private static List<DeployUnitInfoDTO> GetDeployUnits(IAsimovConfig config, string agentGroup = null) { var units = new List<DeployUnitInfoDTO>(); foreach (var deployUnit in config.GetUnitsByGroup(agentGroup)) { var unitInfo = deployUnit.GetUnitInfo(); var unitInfoDto = new DeployUnitInfoDTO { name = unitInfo.Name, lastDeployed = unitInfo.LastDeployed }; if (unitInfo.DeployStatus != DeployStatus.NA) { unitInfoDto.status = unitInfo.DeployStatus.ToString(); unitInfoDto.lastDeployed = ""; } else unitInfoDto.status = unitInfo.Status.ToString(); unitInfoDto.url = unitInfo.Url; unitInfoDto.version = unitInfo.Version.VersionNumber; unitInfoDto.branch = unitInfo.Version.VersionBranch; unitInfoDto.hasDeployParameters = unitInfo.HasDeployParameters; unitInfoDto.actions = deployUnit.Actions.OrderBy(x => x.Sort).Select(x => x.Name).ToArray(); units.Add(unitInfoDto); } return units; }
public DeployModule(ITaskExecutor taskExecutor, IAsimovConfig config) { _taskExecutor = taskExecutor; Post["/deploy/deploy"] = _ => { var command = this.Bind<DeployCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var packageSource = config.GetPackageSourceFor(deployUnit); var version = packageSource.GetVersion(command.versionId, deployUnit.PackageInfo); var deployTask = deployUnit.GetDeployTask(version, new ParameterValues(command.parameters)); _taskExecutor.AddTask(deployTask); return "OK"; }; Post["/deploy/verify"] = _ => { var command = this.Bind<VerifyCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var verifyTask = deployUnit.GetVerifyTask(); _taskExecutor.AddTask(verifyTask); return "OK"; }; }
public DeployUnitModule(IAsimovConfig config) { Get["/units/list"] = _ => { var units = GetDeployUnits(config); return Response.AsJson(units); }; Get["/units/list/{group}"] = urlArgs => { var units = GetDeployUnits(config, (string)urlArgs.group); return Response.AsJson(units); }; Get["/units/deploy-parameters/{unitName}"] = urlArgs => { var deployUnit = config.GetUnitByName((string)urlArgs.unitName); if (deployUnit == null) return 404; var parameters = deployUnit.DeployParameters.Select(deployParameter => deployParameter.GetDescriptor()).ToList(); return Response.AsJson(parameters); }; }
private static List <DeployUnitInfoDTO> GetDeployUnits(IAsimovConfig config, string agentGroup = null) { var units = new List <DeployUnitInfoDTO>(); foreach (var deployUnit in config.GetUnitsByGroup(agentGroup)) { var unitInfo = deployUnit.GetUnitInfo(); var unitInfoDto = new DeployUnitInfoDTO { name = unitInfo.Name, lastDeployed = unitInfo.LastDeployed }; if (unitInfo.DeployStatus != DeployStatus.NA) { unitInfoDto.status = unitInfo.DeployStatus.ToString(); unitInfoDto.lastDeployed = ""; } else { unitInfoDto.status = unitInfo.Status.ToString(); } unitInfoDto.url = unitInfo.Url; unitInfoDto.version = unitInfo.Version.VersionNumber; unitInfoDto.branch = unitInfo.Version.VersionBranch; unitInfoDto.hasDeployParameters = unitInfo.HasDeployParameters; unitInfoDto.actions = deployUnit.Actions.OrderBy(x => x.Sort).Select(x => x.Name).ToArray(); units.Add(unitInfoDto); } return(units); }
public UnitActionModule(ITaskExecutor taskExecutor, IAsimovConfig config) { Post["/action"] = _ => { var command = this.Bind <UnitActionCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var action = deployUnit.Actions[command.actionName]; if (action == null) { return(Response.AsJson(new { OK = false, Message = $"No action found with name {command.actionName}.", AvailableActions = deployUnit.Actions.Select(x => x.Name) }, HttpStatusCode.BadRequest)); } var asimovUser = new AsimovUser() { UserId = command.userId, UserName = command.userName }; var task = action.GetTask(deployUnit, asimovUser, command.correlationId); if (task != null) { taskExecutor.AddTask(task); } return(Response.AsJson(new { OK = true })); }; }
public DeployUnitModule(IAsimovConfig config) { Get["/units/list"] = _ => { var units = GetDeployUnits(config); return(Response.AsJson(units)); }; Get["/units/list/{group}"] = urlArgs => { var units = GetDeployUnits(config, (string)urlArgs.group); return(Response.AsJson(units)); }; Get["/units/deploy-parameters/{unitName}"] = urlArgs => { var deployUnit = config.GetUnitByName((string)urlArgs.unitName); if (deployUnit == null) { return(404); } var parameters = deployUnit.DeployParameters.Select(deployParameter => deployParameter.GetDescriptor()).ToList(); return(Response.AsJson(parameters)); }; }
public LoadBalancerModule(IAsimovConfig config, ITaskExecutor taskExecutor) { _config = config; _taskExecutor = taskExecutor; Get["/loadbalancer/listHosts"] = _ => { if (_config.LoadBalancer.Password == null) return Response.AsJson(new object[] { }); using (var loadBalancer = new AlteonLoadBalancer(_config.LoadBalancer)) { loadBalancer.Login(); return Response.AsJson(loadBalancer.GetHostList()); } }; Post["/loadbalancer/change"] = _ => { var command = this.Bind<ChangeLoadBalancerStateCommand>(); _taskExecutor.AddTask(new ChangeLoadBalancerStates(command)); return "OK"; }; Post["/loadbalancer/settings"] = _ => { var command = this.Bind<UpdateLoadBalancerSettingsCommand>(); _config.LoadBalancer.Password = command.password; if (!string.IsNullOrEmpty(command.host)) _config.LoadBalancer.Host = command.host; return "OK"; }; }
public ServerMonitorLoadBalancer(IAsimovConfig config) { _url = config.LoadBalancerAgentUrl; _loadBalancerDelaySeconds = config.ServerMonitorLoadBalancerDelaySeconds; UseLoadBalancer = !string.IsNullOrEmpty(config.LoadBalancerAgentUrl); }
public HeartbeatService(IAsimovConfig config, ILoadBalancerService loadBalancerService) { _config = config; _loadBalancerService = loadBalancerService; _intervalMs = config.HeartbeatIntervalSeconds * 1000; _hostControlUrl = config.WebControlUrl.ToString(); _config = config; _config.ApiKey = Guid.NewGuid().ToString(); }
public TestVerifyCommandTask( IAsimovConfig config, WebSiteDeployUnit webSiteDeployUnit, string zipPath, string command, string correlationId) : base(webSiteDeployUnit, zipPath, command, correlationId) { _config = config; }
public LoadBalancerService(IAsimovConfig config) { _config = config; if (config.LoadBalancerAgentUrl != null) { _agentUri = new Uri(config.LoadBalancerAgentUrl); UseLoadBalanser = true; } }
public LoadBalancerService(IAsimovConfig config) { _config = config; if (config.LoadBalancerAgentUrl != null) { _agentUri = new Uri(config.LoadBalancerAgentUrl); UseLoadBalanser = true; } }
public HeartbeatService(IAsimovConfig config, ILoadBalancerService loadBalancerService) { _config = config; _loadBalancerService = loadBalancerService; _nodeFrontUri = new Uri(new Uri(config.NodeFrontUrl), "/agent/heartbeat"); _intervalMs = config.HeartbeatIntervalSeconds * 1000; _hostControlUrl = config.WebControlUrl.ToString(); _config = config; _config.ApiKey = Guid.NewGuid().ToString(); }
public DeployUnitModule(IAsimovConfig config) { Get["/units/list"] = _ => { var units = new List <DeployUnitInfoDTO>(); foreach (var deployUnit in config.Units) { var unitInfo = deployUnit.GetUnitInfo(); var unitInfoDto = new DeployUnitInfoDTO(); unitInfoDto.name = unitInfo.Name; unitInfoDto.lastDeployed = unitInfo.LastDeployed; if (unitInfo.DeployStatus != DeployStatus.NA) { unitInfoDto.status = unitInfo.DeployStatus.ToString(); unitInfoDto.lastDeployed = ""; } else { unitInfoDto.status = unitInfo.Status.ToString(); } unitInfoDto.url = unitInfo.Url; unitInfoDto.version = unitInfo.Version.VersionNumber; unitInfoDto.branch = unitInfo.Version.VersionBranch; unitInfoDto.hasDeployParameters = unitInfo.HasDeployParameters; unitInfoDto.actions = deployUnit.Actions.OrderBy(x => x.Sort).Select(x => x.Name).ToArray(); units.Add(unitInfoDto); } return(Response.AsJson(units)); }; Get["/units/deploy-parameters/{unitName}"] = urlArgs => { var deployUnit = config.GetUnitByName((string)urlArgs.unitName); if (deployUnit == null) { return(404); } var parameters = new List <dynamic>(); foreach (var deployParameter in deployUnit.DeployParameters) { parameters.Add(deployParameter.GetDescriptor()); } return(Response.AsJson(parameters)); }; }
public MainModule(IAsimovConfig config) { Get["/"] = _ => VersionUtil.GetAgentVersion(); Get["/version"] = _ => { var resp = new { version = VersionUtil.GetAgentVersion(), configVersion = config.ConfigVersion }; return Response.AsJson(resp); }; }
public MainModule(IAsimovConfig config) { Get["/"] = _ => VersionUtil.GetAgentVersion(); Get["/version"] = _ => { var resp = new { version = VersionUtil.GetAgentVersion(), configVersion = config.ConfigVersion }; return(Response.AsJson(resp)); }; }
public DeployLogModule(IAsimovConfig config) { Get["/deploylog/list/{unitName}"] = parameters => { var deployUnit = config.GetUnitByName((string)parameters.unitName); if (deployUnit == null) { return(404); } var deployedVersions = deployUnit.GetDeployedVersions(); int position = 0; var jsonData = deployedVersions.Select(x => new { timestamp = x.DeployTimestamp.ToString("yyyy-MM-dd HH:mm:ss"), version = x.VersionNumber, commit = x.VersionCommit, branch = x.VersionBranch, status = x.DeployFailed == true ? "DeployFailed" : "Success", userId = x.UserId, username = x.UserName, position = position++, }); return(Response.AsJson(jsonData)); }; Get["/deploylog/file/{unitName}/{position}"] = parameters => { var deployUnit = config.GetUnitByName((string)parameters.unitName); if (deployUnit == null) { return(404); } var deployedVersions = deployUnit.GetDeployedVersions(); var specific = deployedVersions.ElementAtOrDefault((int)parameters.position); if (specific == null) { return(404); } var logFile = Path.Combine(deployUnit.DataDirectory, "Logs", specific.LogFileName); using (var fileStream = new StreamReader(logFile, Encoding.UTF8)) { return(new TextResponse(fileStream.ReadToEnd(), "text/plain; charset=utf-8", Encoding.UTF8)); } }; }
public UnitActionModule(ITaskExecutor taskExecutor, IAsimovConfig config) { Post["/action"] = _ => { var command = this.Bind<UnitActionCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var action = deployUnit.Actions[command.actionName]; var asimovUser = new AsimovUser() {UserId = command.userId, UserName = command.userName}; var task = action.GetTask(deployUnit,asimovUser, command.correlationId); if(task != null) taskExecutor.AddTask(task); return Response.AsJson(new { OK = true }); }; }
public DeployModule(ITaskExecutor taskExecutor, IAsimovConfig config) { Post["/deploy/deploy"] = _ => { var command = this.Bind<DeployCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var user = new AsimovUser() { UserId = command.userId, UserName = command.userName }; var packageSource = config.GetPackageSourceFor(deployUnit); var version = packageSource.GetVersion(command.versionId, deployUnit.PackageInfo); var deployTask = deployUnit.GetDeployTask(version, new ParameterValues(command.parameters), user); taskExecutor.AddTask(deployTask); return Response.AsJson(new { OK = true }); }; }
public DeployUnitModule(IAsimovConfig config) { Get["/units/list"] = _ => { var units = new List<DeployUnitInfoDTO>(); foreach (var deployUnit in config.Units) { var unitInfo = deployUnit.GetUnitInfo(); var unitInfoDto = new DeployUnitInfoDTO(); unitInfoDto.name = unitInfo.Name; unitInfoDto.info = unitInfo.Info; if (unitInfo.DeployStatus != DeployStatus.NA) { unitInfoDto.status = unitInfo.DeployStatus.ToString(); unitInfoDto.info = ""; } else unitInfoDto.status = unitInfo.Status.ToString(); unitInfoDto.url = unitInfo.Url; unitInfoDto.version = unitInfo.Version.VersionNumber; unitInfoDto.branch = unitInfo.Version.VersionBranch; unitInfoDto.hasDeployParameters = unitInfo.HasDeployParameters; units.Add(unitInfoDto); } return Response.AsJson(units); }; Get["/units/deploy-parameters/{unitName}"] = urlArgs => { var deployUnit = config.GetUnitByName((string)urlArgs.unitName); if (deployUnit == null) return 404; var parameters = new List<dynamic>(); foreach (var deployParameter in deployUnit.DeployParameters) parameters.Add(deployParameter.GetDescriptor()); return Response.AsJson(parameters); }; }
public DeployLogModule(IAsimovConfig config) { Get["/deploylog/list/{unitName}"] = parameters => { var deployUnit = config.GetUnitByName((string)parameters.unitName); if (deployUnit == null) return 404; var deployedVersions = deployUnit.GetDeployedVersions(); int position = 0; var jsonData = deployedVersions.Select(x => new { timestamp = x.DeployTimestamp.ToString("yyyy-MM-dd HH:mm:ss"), version = x.VersionNumber, commit = x.VersionCommit, branch = x.VersionBranch, status = x.DeployFailed == true ? "DeployFailed" : "Success", userId = x.UserId, username = x.UserName, position = position++, }); return Response.AsJson(jsonData); }; Get["/deploylog/file/{unitName}/{position}"] = parameters => { var deployUnit = config.GetUnitByName((string)parameters.unitName); if (deployUnit == null) return 404; var deployedVersions = deployUnit.GetDeployedVersions(); var specific = deployedVersions.ElementAtOrDefault((int)parameters.position); if (specific == null) return 404; var logFile = Path.Combine(deployUnit.DataDirectory, "Logs", specific.LogFileName); using (var fileStream = new StreamReader(logFile, Encoding.UTF8)) { return new TextResponse(fileStream.ReadToEnd(), "text/plain; charset=utf-8", Encoding.UTF8); } }; }
public DeployModule(ITaskExecutor taskExecutor, IAsimovConfig config) { Post["/deploy/deploy"] = _ => { var command = this.Bind <DeployCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var user = new AsimovUser() { UserId = command.userId, UserName = command.userName }; var packageSource = config.GetPackageSourceFor(deployUnit); var version = packageSource.GetVersion(command.versionId, deployUnit.PackageInfo); var deployTask = deployUnit.GetDeployTask(version, new ParameterValues(command.parameters), user); taskExecutor.AddTask(deployTask); return(Response.AsJson(new { OK = true })); }; }
public VersionsModule(IAsimovConfig config) { Get["/versions/{unitName}"] = parameters => { var unitName = (string)parameters.unitName; var deployUnit = config.GetUnitByName(unitName); var versions = config.GetPackageSourceFor(deployUnit) .GetAvailableVersions(deployUnit.PackageInfo) .Select(x => new DeployUnitVersionDTO() { id = x.Id, timestamp = x.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"), version = x.Number, branch = x.Branch, commit = x.Commit }); return(Response.AsJson(versions)); }; }
public VersionsModule(IAsimovConfig config) { Get["/versions/{unitName}"] = parameters => { var unitName = (string) parameters.unitName; var deployUnit = config.GetUnitByName(unitName); var versions = config.GetPackageSourceFor(deployUnit) .GetAvailableVersions(deployUnit.PackageInfo) .Select(x => new DeployUnitVersionDTO() { id = x.Id, timestamp = x.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"), version = x.Number, branch = x.Branch, commit = x.Commit }); return Response.AsJson(versions); }; }
public UnitActionModule(ITaskExecutor taskExecutor, IAsimovConfig config) { Post["/action"] = _ => { var command = this.Bind <UnitActionCommand>(); var deployUnit = config.GetUnitByName(command.unitName); var action = deployUnit.Actions[command.actionName]; var asimovUser = new AsimovUser() { UserId = command.userId, UserName = command.userName }; var task = action.GetTask(deployUnit, asimovUser); if (task != null) { taskExecutor.AddTask(task); } return(Response.AsJson(new { OK = true })); }; }
public DeployUnitModule(IAsimovConfig config) { Get["/units/list"] = _ => { var request = this.Bind <GetDeployUnitsRequestDto>(); var units = GetDeployUnits(config, request); return(Response.AsJson(units)); }; Get["/units/list/{group}"] = urlArgs => { var units = GetDeployUnits(config, new GetDeployUnitsRequestDto { AgentGroups = new[] { (string)urlArgs.group } }); return(Response.AsJson(units)); }; Get["/units/deploy-parameters/{unitName}"] = urlArgs => { var deployUnit = config.GetUnitByName((string)urlArgs.unitName); if (deployUnit == null) { return(404); } var parameters = deployUnit.GetDeployParameters().Select(deployParameter => deployParameter.GetDescriptor()).ToList(); return(Response.AsJson(parameters)); }; Get["/agent-groups"] = _ => Response.AsJson(config.GetAgentGroups()); Get["/unit-groups"] = _ => Response.AsJson(config.GetUnitGroups()); Get["/unit-types"] = _ => Response.AsJson(config.GetUnitTypes()); Get["/unit-tags"] = _ => Response.AsJson(config.GetUnitTags()); Get["/unit-statuses"] = _ => Response.AsJson(config.GetUnitStatuses()); }
public UpdateWindowsService(IAsimovConfig config) { _config = config; }
public UpdateWindowsService(IAsimovConfig config) { _config = config; }
private static List <DeployUnitInfoDTO> GetDeployUnits(IAsimovConfig config, GetDeployUnitsRequestDto getDeployUnitsRequestDto) { var deployUnits = config.Units.AsEnumerable(); if (getDeployUnitsRequestDto.AgentGroups != null && getDeployUnitsRequestDto.AgentGroups.Any()) { var filteredByAgentGroups = getDeployUnitsRequestDto.AgentGroups.SelectMany(config.GetUnitsByAgentGroup); deployUnits = deployUnits.Intersect(filteredByAgentGroups); } if (getDeployUnitsRequestDto.UnitGroups != null && getDeployUnitsRequestDto.UnitGroups.Any()) { var filteredByUnitGroups = getDeployUnitsRequestDto.UnitGroups.SelectMany(config.GetUnitsByUnitGroup); deployUnits = deployUnits.Intersect(filteredByUnitGroups); } if (getDeployUnitsRequestDto.UnitTypes != null && getDeployUnitsRequestDto.UnitTypes.Any()) { var filteredByType = getDeployUnitsRequestDto.UnitTypes.SelectMany(config.GetUnitsByType); deployUnits = deployUnits.Intersect(filteredByType); } if (getDeployUnitsRequestDto.Tags != null && getDeployUnitsRequestDto.Tags.Any()) { var filteredByTags = getDeployUnitsRequestDto.Tags.SelectMany(config.GetUnitsByTag); deployUnits = deployUnits.Intersect(filteredByTags); } if (getDeployUnitsRequestDto.Units != null && getDeployUnitsRequestDto.Units.Any()) { var filteredByUnits = getDeployUnitsRequestDto.Units.SelectMany(config.GetUnitsByUnitName); deployUnits = deployUnits.Intersect(filteredByUnits); } if (getDeployUnitsRequestDto.UnitStatus != null && getDeployUnitsRequestDto.UnitStatus.Any()) { var filteredByStatus = getDeployUnitsRequestDto.UnitStatus.SelectMany(s => config.GetUnitsByStatus(s, !getDeployUnitsRequestDto.SkipStatusRefresh)); deployUnits = deployUnits.Intersect(filteredByStatus); } var list = new List <DeployUnitInfoDTO>(); foreach (var deployUnit in deployUnits.ToList().Distinct()) { var unitInfo = deployUnit.GetUnitInfo(!getDeployUnitsRequestDto.SkipStatusRefresh); var unitInfoDto = new DeployUnitInfoDTO { name = unitInfo.Name, group = unitInfo.Group, type = deployUnit.UnitType, status = unitInfo.GetUnitStatus(), lastDeployed = unitInfo.LastDeployed, tags = deployUnit.Tags.ToArray() }; if (unitInfo.DeployStatus != DeployStatus.NA) { unitInfoDto.lastDeployed = ""; } unitInfoDto.url = unitInfo.Url; unitInfoDto.version = unitInfo.Version.VersionNumber; unitInfoDto.branch = unitInfo.Version.VersionBranch; unitInfoDto.hasDeployParameters = unitInfo.HasDeployParameters; unitInfoDto.actions = deployUnit.Actions.OrderBy(x => x.Sort).Select(x => x.Name).ToArray(); list.Add(unitInfoDto); } return(list); }
public CleanTempFolder(IAsimovConfig config) { _config = config; }
public TestChangeLoadBalancerStateTask(ChangeLoadBalancerStateCommand command, ILoadBalancerService loadBalancerService, INotifier nodeFront) : base(command, loadBalancerService, nodeFront) { _config = new AsimovConfig(); }
public PowerShellDeployStep(IAsimovConfig config) { _config = config; }
public CopyPackageToTempFolder(IAsimovConfig asimovConfig) { _asimovConfig = asimovConfig; }
public PowerShellDeployStep(IAsimovConfig config) { _config = config; }
public TestChangeLoadBalancerStateTask(ChangeLoadBalancerStateCommand command, ILoadBalancerService loadBalancerService, INotifier nodeFront) : base(command, loadBalancerService, nodeFront) { _config = new AsimovConfig(); }
public WebServerStartup(IAsimovConfig config) { _config = config; }
public UpdateWebSite(IAsimovConfig config) { _config = config; }
public CleanTempFolder(IAsimovConfig config) { _config = config; }
public CopyPackageToTempFolder(IAsimovConfig asimovConfig) { _asimovConfig = asimovConfig; }
public UpdateWebSite(IAsimovConfig config) { _config = config; }
public WebServerStartup(IAsimovConfig config) { _config = config; }