public static void CreatePool(this ICakeContext context, string server, ApplicationPoolSettings settings)
 {
     using (ServerManager manager = BaseManager.Connect(server))
     {
         ApplicationPoolManager
             .Using(context.Environment, context.Log, manager)
             .Create(settings);
     }
 }
Example #2
0
 public static void CreatePool(this ICakeContext context, string server, ApplicationPoolSettings settings)
 {
     using (ServerManager manager = BaseManager.Connect(server))
     {
         ApplicationPoolManager
         .Using(context.Environment, context.Log, manager)
         .Create(settings);
     }
 }
 public static void CreatePool(this ICakeContext context, ApplicationPoolSettings settings)
 {
     context.CreatePool("", settings);
 }
Example #4
0
 public static void CreatePool(this ICakeContext context, ApplicationPoolSettings settings)
 {
     context.CreatePool("", settings);
 }
        /// <summary>
        /// Creates an application pool
        /// </summary>
        /// <param name="settings">The settings of the application to add</param>
        /// <returns>If the application pool was added.</returns>
        public void Create(ApplicationPoolSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (string.IsNullOrWhiteSpace(settings.Name))
            {
                throw new ArgumentException("Application pool name cannot be null!");
            }

            if (this.IsSystemDefault(settings.Name))
            {
                return;
            }



            //Get Pool
            var pool = _Server.ApplicationPools.FirstOrDefault(p => p.Name == settings.Name);

            if (pool != null)
            {
                _Log.Information("Application pool '{0}' already exists.", settings.Name);

                if (settings.Overwrite)
                {
                    _Log.Information("Application pool '{0}' will be overriden by request.", settings.Name);
                    this.Delete(settings.Name);
                }
                else
                {
                    return;
                }
            }



            //Add Pool
            pool = _Server.ApplicationPools.Add(settings.Name);

            pool.AutoStart = settings.Autostart;

            pool.Enable32BitAppOnWin64 = settings.Enable32BitAppOnWin64;
            pool.ManagedRuntimeVersion = settings.ManagedRuntimeVersion;
            pool.ManagedPipelineMode   = settings.ClassicManagedPipelineMode
                ? ManagedPipelineMode.Classic
                : ManagedPipelineMode.Integrated;



            //Set Identity
            _Log.Information("Application pool identity type: {0}", settings.IdentityType.ToString());

            switch (settings.IdentityType)
            {
            case IdentityType.LocalSystem:
                pool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalSystem;
                break;

            case IdentityType.LocalService:
                pool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalService;
                break;

            case IdentityType.NetworkService:
                pool.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService;
                break;

            case IdentityType.ApplicationPoolIdentity:
                pool.ProcessModel.IdentityType = ProcessModelIdentityType.ApplicationPoolIdentity;
                break;

            case IdentityType.SpecificUser:
                pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
                pool.ProcessModel.UserName     = settings.Username;
                pool.ProcessModel.Password     = settings.Password;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }



            //Set ProcessModel
            pool.ProcessModel.LoadUserProfile = settings.LoadUserProfile;
            pool.ProcessModel.MaxProcesses    = settings.MaxProcesses;

            pool.ProcessModel.PingingEnabled = settings.PingingEnabled;

            if (settings.PingResponseTime != TimeSpan.MinValue)
            {
                pool.ProcessModel.PingInterval = settings.PingInterval;
            }
            if (settings.PingResponseTime != TimeSpan.MinValue)
            {
                pool.ProcessModel.PingResponseTime = settings.PingResponseTime;
            }
            if (settings.IdleTimeout != TimeSpan.MinValue)
            {
                pool.ProcessModel.IdleTimeout = settings.IdleTimeout;
            }
            if (settings.ShutdownTimeLimit != TimeSpan.MinValue)
            {
                pool.ProcessModel.ShutdownTimeLimit = settings.ShutdownTimeLimit;
            }
            if (settings.StartupTimeLimit != TimeSpan.MinValue)
            {
                pool.ProcessModel.StartupTimeLimit = settings.StartupTimeLimit;
            }



            _Server.CommitChanges();

            _Log.Information("Application pool created.");
        }
            public void Create(ApplicationPoolSettings settings)
            {
                if (settings == null)
                {
                    throw new ArgumentNullException("settings");
                }

                if (string.IsNullOrWhiteSpace(settings.Name))
                {
                    throw new ArgumentException("Application pool name cannot be null!");
                }

                if (this.IsSystemDefault(settings.Name))
                {
                    return;
                }



                //Get Pool
                var pool = _Server.ApplicationPools.FirstOrDefault(p => p.Name == settings.Name);

                if(pool != null)
                {
                    _Log.Information("Application pool '{0}' already exists.", settings.Name);

                    if(settings.Overwrite)
                    {
                        _Log.Information("Application pool '{0}' will be overriden by request.", settings.Name);
                        this.Delete(settings.Name);
                    }
                    else return;
                }
            


                //Add Pool
                pool = _Server.ApplicationPools.Add(settings.Name);

                pool.AutoStart             = settings.Autostart;
                pool.Enable32BitAppOnWin64 = settings.Enable32BitAppOnWin64;
                pool.ManagedRuntimeVersion = settings.ManagedRuntimeVersion;
                pool.ManagedPipelineMode   = settings.ClassicManagedPipelineMode
                    ? ManagedPipelineMode.Classic
                    : ManagedPipelineMode.Integrated;



                //Set Identity
                _Log.Information("Application pool identity type: {0}", settings.IdentityType.ToString());

                switch(settings.IdentityType)
                {
                    case IdentityType.LocalSystem:
                        pool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalSystem;
                        break;
                    case IdentityType.LocalService:
                        pool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalService;
                        break;
                    case IdentityType.NetworkService:
                        pool.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService;
                        break;
                    case IdentityType.ApplicationPoolIdentity:
                        pool.ProcessModel.IdentityType = ProcessModelIdentityType.ApplicationPoolIdentity;
                        break;
                    case IdentityType.SpecificUser:
                        pool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
                        pool.ProcessModel.UserName     = settings.Username;
                        pool.ProcessModel.Password     = settings.Password;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }



                //Set ProcessModel
                pool.ProcessModel.LoadUserProfile = settings.LoadUserProfile;
                pool.ProcessModel.MaxProcesses = settings.MaxProcesses;

                pool.ProcessModel.PingingEnabled = settings.PingingEnabled;

                if (settings.PingResponseTime != TimeSpan.MinValue)
                {
                    pool.ProcessModel.PingInterval = settings.PingInterval;
                }
                if (settings.PingResponseTime != TimeSpan.MinValue)
                {
                    pool.ProcessModel.PingResponseTime = settings.PingResponseTime;
                }
                if (settings.IdleTimeout != TimeSpan.MinValue)
                {
                    pool.ProcessModel.IdleTimeout = settings.IdleTimeout;
                }
                if (settings.ShutdownTimeLimit != TimeSpan.MinValue)
                {
                    pool.ProcessModel.ShutdownTimeLimit = settings.ShutdownTimeLimit;
                }
                if (settings.StartupTimeLimit != TimeSpan.MinValue)
                {
                    pool.ProcessModel.StartupTimeLimit = settings.StartupTimeLimit;
                }



                _Server.CommitChanges();

                _Log.Information("Application pool created.");
            }