示例#1
0
        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";
            };
        }
示例#2
0
        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 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 LoadBalancerModule(ITaskExecutor taskExecutor, ILoadBalancerService loadBalancerService)
 {
     Post["/loadbalancer/change"] = _ =>
     {
         var command = this.Bind<ChangeLoadBalancerStateCommand>();
         taskExecutor.AddTask(new ChangeLoadBalancerStateTask(command, loadBalancerService, new NodeFront()));
         return "OK";
     };
 }
示例#5
0
 public LoadBalancerModule(ITaskExecutor taskExecutor, ILoadBalancerService loadBalancerService)
 {
     Post["/loadbalancer/change"] = _ =>
     {
         var command = this.Bind <ChangeLoadBalancerStateCommand>();
         taskExecutor.AddTask(new ChangeLoadBalancerStateTask(command, loadBalancerService, new NodeFront()));
         return("OK");
     };
 }
        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 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 });
            };
        }
示例#8
0
        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 }));
            };
        }
示例#9
0
        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 }));
            };
        }