Пример #1
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            //can I connect to the server?

            IDbConnection conn = null;
            try
            {
                conn = GetConnection();
                conn.Open();
                result.AddGood("I can talk to the database");
            }
            catch (Exception)
            {
                result.AddAlert("I cannot open the connection");
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

            //can I connect to the database?
            if (OutputSql != null)
                result.AddAlert(string.Format("I will run the sql '{0}'", OutputSql));


            return result;
        }
Пример #2
0
        public void CheckForSiteAndVDirExistance(Func <bool> website, Func <bool> vdir, DeploymentResult result)
        {
            if (website())
            {
                result.AddGood("Found Website '{0}'", WebsiteName);

                if (vdir())
                {
                    result.AddGood("Found VDir '{0}'", VdirPath);
                }
                else
                {
                    result.AddAlert("Couldn't find VDir '{0}'", VdirPath);

                    if (ShouldCreate)
                    {
                        result.AddAlert("The VDir '{0}' will be created", VdirPath);
                    }
                }
            }
            else
            {
                result.AddAlert("Couldn't find Website '{0}'", WebsiteName);

                if (ShouldCreate)
                {
                    result.AddAlert("Website '{0}' and VDir '{1}' will be created", WebsiteName, VdirPath);
                }
            }
        }
Пример #3
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            if (Environment.MachineName.Equals(_serverName))
            {
                //if(MessageQueue.Exists(path))
                //{
                //    result.AddGood("'{0}' does exist");
                //}
                //else
                //{
                //    result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _queueName));
                //}
                result.AddAlert("I can't check queue exstance yet");
            }
            else
            {
                result.AddAlert(string.Format("Cannot check for queue '{0}' on server '{1}' while on server '{2}'",
                                              _queueName, _serverName, Environment.MachineName));
            }


            return(result);
        }
Пример #4
0
        public void CheckForSiteAndVDirExistance(Func<bool> website, Func<bool> vdir, DeploymentResult result)
        {
            if (website())
            {
                result.AddGood("Found Website '{0}'", WebsiteName);

                if (vdir())
                {
                    result.AddGood("Found VDir '{0}'", VdirPath);
                }
                else
                {
                    result.AddAlert("Couldn't find VDir '{0}'", VdirPath);

                    if (ShouldCreate)
                        result.AddAlert("The VDir '{0}' will be created", VdirPath);
                }
            }
            else
            {
                result.AddAlert("Couldn't find Website '{0}'", WebsiteName);

                if (ShouldCreate)
                    result.AddAlert("Website '{0}' and VDir '{1}' will be created", WebsiteName, VdirPath);
            }
        }
Пример #5
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            //check can write from _to
            if (_path.DirectoryDoesntExist(_to))
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));
            }

            if (_clearOptions == DestinationCleanOptions.Delete)
            {
                result.AddAlert("The files and directories in '{0}' will be deleted before deploying, except for items being ignored.", _to);
            }
            if (_clearOptions == DestinationCleanOptions.Clear)
            {
                result.AddAlert("The files in '{0}' will be cleared before deploying, except for items being ignored.", _to);
            }

            DirectoryInfo fromDirectory = new DirectoryInfo(_from);

            if (fromDirectory.Exists)
            {
                result.AddGood(string.Format("'{0}' exists", fromDirectory.FullName));

                //check can read from _from
                FileInfo[] readFiles = fromDirectory.GetFiles();
                foreach (var file in readFiles.Where(f => !IsIgnored(_copyIgnorePatterns, f)))
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        _log.DebugFormat("Going to copy '{0}' to '{1}'", file.FullName, _to);
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyDirectoryTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return(result);
        }
Пример #6
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (UserName.ShouldPrompt())
                result.AddAlert("We are going to prompt for a username.");

			if (shouldPromptForPassword())
                result.AddAlert("We are going to prompt for a password.");

            return result;
        }
Пример #7
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            //check can write from _to
            if (_path.DirectoryDoesntExist(_to))
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));
            }

            if (_options == DestinationCleanOptions.Delete)
            {
                result.AddAlert("The files and directories in '{0}' will be deleted before deploying", _to);
            }

            if (_path.DirectoryExists(_from))
            {
                result.AddGood(string.Format("'{0}' exists", _from));

                //check can read from _from
                string[] readFiles = _path.GetFiles(_from);
                foreach (var file in readFiles)
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file, FileMode.Open, FileAccess.Read);
                        _log.DebugFormat("Going to copy '{0}' to '{1}'", file, _to);
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyDirectoryTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return(result);
        }
Пример #8
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to = _path.GetFullPath(_to);

            //check can write from _to
            if (_path.DirectoryDoesntExist(_to)) result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));

            if (_clearOptions == DestinationCleanOptions.Delete) result.AddAlert("The files and directories in '{0}' will be deleted before deploying, except for items being ignored.", _to);
            if (_clearOptions == DestinationCleanOptions.Clear) result.AddAlert("The files in '{0}' will be cleared before deploying, except for items being ignored.", _to);

            DirectoryInfo fromDirectory = new DirectoryInfo(_from);
            if (fromDirectory.Exists)
            {
                result.AddGood(string.Format("'{0}' exists", fromDirectory.FullName));

                //check can read from _from
                FileInfo[] readFiles = fromDirectory.GetFiles();
                foreach (var file in readFiles.Where(f => !IsIgnored(_copyIgnorePatterns, f)))
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        _log.DebugFormat("Going to copy '{0}' to '{1}'", file.FullName, _to);
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyDirectoryTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return result;
        }
Пример #9
0
 private void CheckApplicationPoolExists(ServerManager iisManager, DeploymentResult result)
 {
     if (!iisManager.ApplicationPools.Any(a => a.Name == ApplicationPool))
     {
         result.AddAlert(ApplicationPoolDoesNotExistError);
     }
 }
Пример #10
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                    if (c.CanStop)
                    {
                        int pid = GetProcessId(ServiceName);

                        c.Stop();
                        c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                        //WaitForProcessToDie(pid);
                    }
                }
                result.AddGood("Stopped Service '{0}'", ServiceName);
                Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return result;
        }
Пример #11
0
        void BuildVirtualDirectory(Site site, ServerManager mgr, DeploymentResult result)
        {
            Magnum.Guard.AgainstNull(site, "The site argument is null and should not be");
            var appPath     = "/" + VirtualDirectoryPath;
            var application = site.Applications.FirstOrDefault(x => x.Path == appPath);

            if (application == null)
            {
                result.AddAlert("'{0}' doesn't exist. creating.", VirtualDirectoryPath);
                application = site.Applications.Add(appPath, PathOnServer);
                LogFineGrain("[iis7] Created application '{0}'", VirtualDirectoryPath);
            }
            else
            {
                result.AddNote("'{0}' already exists. Updating settings.", VirtualDirectoryPath);
            }

            if (application.ApplicationPoolName != AppPoolName)
            {
                application.ApplicationPoolName = AppPoolName;
                LogFineGrain("[iis7] Set the ApplicationPool for '{0}' to '{1}'", VirtualDirectoryPath, AppPoolName);
            }

            var vdir = application.VirtualDirectories["/"];

            if (vdir.PhysicalPath != PathOnServer)
            {
                vdir.PhysicalPath = PathOnServer;
                LogFineGrain("[iis7] Updated physical path for '{0}' to '{1}'", VirtualDirectoryPath, PathOnServer);
            }

            ConfigureAuthentication(mgr, result, true);
            //result.AddGood("'{0}' was created/updated successfully", VirtualDirectoryPath);
        }
Пример #12
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (UserName.ShouldPrompt())
            {
                UserName = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(ServiceName));
            }

            if (Password.ShouldPrompt())
            {
                Password = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(ServiceName, UserName));
            }

            ServiceReturnCode returnCode = WmiService.Create(MachineName, ServiceName, ServiceDisplayName, ServiceLocation,
                                                             StartMode, UserName, Password, Dependencies);

            if (returnCode != ServiceReturnCode.Success)
            {
                result.AddAlert("Create service returned {0}".FormatWith(returnCode.ToString()));
            }
            else
            {
                result.AddGood("Create service succeeded.");
            }

            return(result);
        }
Пример #13
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                    if (c.CanStop)
                    {
                        int pid = GetProcessId(ServiceName);

                        c.Stop();
                        c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                        WaitForProcessToDie(pid);
                    }
                }
                result.AddGood("Stopped Service '{0}'", ServiceName);
                Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return(result);
        }
Пример #14
0
        public override DeploymentResult VerifyCanRun()
        {
            var r = new DeploymentResult();

            r.AddAlert("NO CHECKS RUN");
            return(r);
        }
Пример #15
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var iisManager = ServerManager.OpenRemote(ServerName);

            BuildApplicationPool(iisManager, result);

            if (!DoesSiteExist(result))
            {
                CreateWebSite(iisManager, WebsiteName, result);
            }


            Site site = GetSite(iisManager, WebsiteName);

            if (!DoesVirtualDirectoryExist(site))
            {
                result.AddAlert("'{0}' doesn't exist. creating.", VdirPath);
                CreateVirtualDirectory(site, iisManager);
                result.AddGood("'{0}' was created", VdirPath);
            }


            iisManager.CommitChanges();
            LogCoarseGrain("[iis7] {0}", Name);
            return(result);
        }
Пример #16
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            if (Environment.MachineName.Equals(_serverName))
            {
                //if(MessageQueue.Exists(path))
                //{
                //    result.AddGood("'{0}' does exist");
                //}
                //else
                //{
                //    result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _queueName));
                //}
                result.AddAlert("I can't check queue exstance yet");
            }
            else
            {
                result.AddAlert(string.Format("Cannot check for queue '{0}' on server '{1}' while on server '{2}'",
                                              _queueName, _serverName, Environment.MachineName));
            }

            return result;
        }
Пример #17
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (UserName.ShouldPrompt())
            {
                result.AddAlert("We are going to prompt for a username.");
            }

            if (Password.ShouldPrompt())
            {
                result.AddAlert("We are going to prompt for a password.");
            }

            return(result);
        }
Пример #18
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                if (!dropkick.Wmi.WmiService.AuthenticationSpecified)
                {
                    using (var c = new ServiceController(ServiceName, MachineName))
                    {
                        Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                        if (c.CanStop)
                        {
                            int pid = GetProcessId(ServiceName);

                            c.Stop();
                            c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                            WaitForProcessToDie(pid);
                        }
                    }
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
                else
                {
                    if (!ServiceIsRunning())
                    {
                        result.AddGood("Stopping Service '{0}', Service Already Stopped", ServiceName);
                        Logging.Coarse("[svc] Stopping service '{0}', service already stopped", ServiceName);
                    }
                    else
                    {
                        var status = dropkick.Wmi.WmiService.Stop(MachineName, ServiceName);
                        switch (status)
                        {
                        case Wmi.ServiceReturnCode.StatusServiceExists:
                        case Wmi.ServiceReturnCode.Success:
                            result.AddGood("Stopped Service '{0}'", ServiceName);
                            Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                            break;

                        default:
                            //BAD
                            throw new Exception("Failed to stop service {0}: {1}".FormatWith(ServiceName, status));
                        }
                    }
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return(result);
        }
Пример #19
0
        protected void ValidateIsDirectory(DeploymentResult result, string path)
        {
            if (!(new DirectoryInfo(_path.GetFullPath(path)).Exists))
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(path));

            if (!_path.IsDirectory(path))
                result.AddError("'{0}' is not a directory.".FormatWith(path));
        }
Пример #20
0
 public void CheckServerName(DeploymentResult result)
 {
     if (!Environment.MachineName.Equals(ServerName))
     {
         result.AddAlert("You are not on the right server [On: '{0}' - Target: '{1}'", Environment.MachineName,
                         ServerName);
     }
 }
Пример #21
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = Path.GetFullPath(_from);
            _to   = Path.GetFullPath(_to);

            //check can write from _to
            if (!Directory.Exists(_to))
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));
            }

            if (Directory.Exists(_from))
            {
                result.AddGood(string.Format("'{0}' exists", _from));
                //check can read from _from
                string[] readFiles = Directory.GetFiles(_from);
                foreach (string file in readFiles)
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file, FileMode.Open, FileAccess.Read);
                        result.AddGood(string.Format("Going to copy '{0}' to '{1}'", file, _to));
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return(result);
        }
Пример #22
0
		private void verifyKeyExists(DeploymentResult result)
		{
			using (var regHive = OpenHive())
				using (var regKey = regHive.OpenSubKey(Key))
				{
					if (regKey == null)
						result.AddAlert(@"Registry Key '{0}' does not exist and will need to be created.", GetRegistryKeyDisplayString(Hive, Key));
				}
		}
Пример #23
0
        public static void CheckForIis7(DeploymentResult result)
        {
            int shouldBe6 = Environment.OSVersion.Version.Major;

            if (shouldBe6 != 6)
            {
                result.AddAlert("This machine does not have IIS7 on it");
            }
        }
Пример #24
0
        static void CheckVersionOfWindowsAndIis(DeploymentResult result)
        {
            var shouldBe5 = Environment.OSVersion.Version.Major;

            if (shouldBe5 != 5)
            {
                result.AddAlert("This machine does not have IIS6 on it");
            }
        }
Пример #25
0
        void CheckVersionOfWindowsAndIis(DeploymentResult result)
        {
            int shouldBe6 = Environment.OSVersion.Version.Major;

            if (shouldBe6 != 6)
            {
                result.AddAlert("This machine does not have IIS7 on it");
            }
        }
Пример #26
0
        public DeploymentResult VerifyCanRun()
        {
            //verify admin
            var result = new DeploymentResult();

            if (!Directory.Exists(PointingTo)) result.AddAlert("'{0}' doesn't exist", PointingTo);
            else result.AddGood("'{0}' exists", PointingTo);

            return result;
        }
Пример #27
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Starting service '{0}'", ServiceName);
                    try
                    {
                        c.Start();
                        LogCoarseGrain("[svc] Waiting up to {0} seconds because Windows can be silly", _timeout.TotalSeconds);
                        c.WaitForStatus(ServiceControllerStatus.Running, _timeout);
                    }
                    catch (InvalidOperationException ex)
                    {
                        result.AddError("The service '{0}' did not start, most likely due to a logon issue.".FormatWith(ServiceName), ex);
                        LogCoarseGrain("The service '{0}' did not start, most likely due to a logon issue.{1}{2}", ServiceName, Environment.NewLine, ex);
                        return result;
                    }
                    catch (TimeoutException)
                    {
                        if (ErrorOnFailure)
                            result.AddError(string.Format("Service '{0}' did not finish starting during the specified timeframe.", ServiceName));
                        else
                            result.AddAlert("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        LogCoarseGrain("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        return result;
                    }
                }
                result.AddGood("Started the service '{0}'", ServiceName);
            }
            else
            {
                if (ErrorOnFailure)
                    result.AddError(string.Format("Service '{0}' does not exist so it cannot be started", ServiceName));
                else
                    result.AddAlert("Service '{0}' does not exist so it cannot be started", ServiceName);
            }

            return result;
        }
Пример #28
0
 void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the Administrator role");
     }
     else
     {
         result.AddGood("You are in the Administrator role");
     }
 }
Пример #29
0
		public string Replace(string contents, DeploymentResult result)
		{
			var newContents = Regex.Replace(contents, _pattern, _replacement, _regexOptions);

			if (newContents == contents)
				result.AddAlert("[filepoke] No replacement made for pattern '{0}'.", _pattern);
			else
				_log.InfoFormat("[filepoke] Pattern '{0}' replaced with '{1}' using options {2}.", _pattern, _replacement, _regexOptions);

			return newContents;
		}
Пример #30
0
 protected void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the 'Administrator' role. You will not be able to start/stop services");
     }
     else
     {
         result.AddGood("You are in the 'Administrator' role");
     }
 }
Пример #31
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            _target = _path.GetFullPath(_target);

            if (!_path.DirectoryExists(_target) && !_path.FileExists(_target))
                result.AddAlert("'{0}' does not exist. It may be created.".FormatWith(_target));

            return result;
        }
Пример #32
0
 private void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the Administrator role");
     }
     else
     {
         result.AddGood("You are in the Administrator role");
     }
 }
Пример #33
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (_address.IsLocal)
                VerifyInAdministratorRole(result);
            else
                result.AddAlert("Cannot set permissions for the private remote queue '{0}' while on server '{1}'".FormatWith(_address.ActualUri, Environment.MachineName));

            return result;
        }
Пример #34
0
 private void verifyKeyExists(DeploymentResult result)
 {
     using (var regHive = OpenHive())
         using (var regKey = regHive.OpenSubKey(Key))
         {
             if (regKey == null)
             {
                 result.AddAlert(@"Registry Key '{0}' does not exist and will need to be created.", GetRegistryKeyDisplayString(Hive, Key));
             }
         }
 }
Пример #35
0
 protected void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the 'Administrator' role. You will not be able to start/stop services");
     }
     else
     {
         result.AddGood("You are in the 'Administrator' role");
     }
 }
Пример #36
0
        protected void ValidateIsFile(DeploymentResult result, string path)
        {
            if (!(new FileInfo(_path.GetFullPath(path)).Exists))
            {
                result.AddAlert("'{0}' does not exist.".FormatWith(path));
            }

            if (!_path.IsFile(path))
            {
                result.AddError("'{0}' is not a file.".FormatWith(path));
            }
        }
Пример #37
0
        public DeploymentResult VerifyCanRun()
        {
            var results = new DeploymentResult();

            results.AddNote(Name);

            if (_connectionInfo.WillPromptForUserName())
            {
                results.AddAlert("We are going to prompt for a username.");
            }

            if (_connectionInfo.WillPromptForPassword())
            {
                results.AddAlert("We are going to prompt for a password.");
            }

            //check you can connect to the _instancename
            //check that the path _scriptsLocation exists

            return(results);
        }
Пример #38
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            TestConnectivity(result);

            if (ScriptToRun != null)
            {
                result.AddAlert(string.Format("I will run the sql script at '{0}'", ScriptToRun));
                if (File.Exists(ScriptToRun))
                {
                    result.AddGood(string.Format("I found the script '{0}'", ScriptToRun));
                }
                else
                {
                    result.AddAlert("I can't find '{0}'", ScriptToRun);
                }
            }

            return result;
        }
Пример #39
0
        protected void ValidateIsDirectory(DeploymentResult result, string path)
        {
            if (!(new DirectoryInfo(_path.GetFullPath(path)).Exists))
            {
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(path));
            }

            if (!_path.IsDirectory(path))
            {
                result.AddError("'{0}' is not a directory.".FormatWith(path));
            }
        }
Пример #40
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (!Directory.Exists(ExecutableIsLocatedAt))
                result.AddAlert(string.Format("Can't find the executable '{0}'", Path.Combine(ExecutableIsLocatedAt, Command)));

            if (IsTheExeInThisDirectory(ExecutableIsLocatedAt, Command))
                result.AddGood(string.Format("Found command '{0}' in '{1}'", Command, ExecutableIsLocatedAt));

            return result;
        }
Пример #41
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            base.TestConnectivity(result);


            if (ScriptToRun != null)
            {
                result.AddAlert(string.Format("I will run the sql script at '{0}'", ScriptToRun));
                if (File.Exists(ScriptToRun))
                {
                    result.AddGood(string.Format("I found the script '{0}'", ScriptToRun));
                }
                else
                {
                    result.AddAlert("I can't find '{0}'", ScriptToRun);
                }
            }

            return(result);
        }
Пример #42
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            TestConnectivity(result);

            if (!DoesUserExist(_user))
            {
                result.AddAlert("User not found. going to add");
            }

            return(result);
        }
Пример #43
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            _target = _path.GetFullPath(_target);

            if (!_path.DirectoryExists(_target) && !_path.FileExists(_target))
            {
                result.AddAlert("'{0}' does not exist. It may be created.".FormatWith(_target));
            }

            return(result);
        }
Пример #44
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            TestConnectivity(result);

            if (!DoesUserExist(_user))
            {
                result.AddAlert("User not found. going to add");
            }

            return result;
        }
Пример #45
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Starting service '{0}'", ServiceName);
                    try
                    {
                        c.Start();
                        LogCoarseGrain("[svc] Waiting up to 60 seconds because Windows can be silly");
                        c.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(60));
                    }
                    catch (InvalidOperationException ex)
                    {
                        result.AddError("The service '{0}' did not start, most likely due to a logon issue.".FormatWith(ServiceName), ex);
                        LogCoarseGrain("The service '{0}' did not start, most likely due to a logon issue.{1}{2}", ServiceName, Environment.NewLine, ex);
                        return(result);
                    }
                    catch (TimeoutException)
                    {
                        result.AddAlert("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        LogCoarseGrain("Service '{0}' did not finish starting during the specified timeframe.  You will need to manually verify if the service started successfully.", ServiceName);
                        return(result);
                    }
                }
                result.AddGood("Started the service '{0}'", ServiceName);
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist so it cannot be started", ServiceName);
            }

            return(result);
        }
Пример #46
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            //can I connect to the server?

            IDbConnection conn = null;

            try
            {
                conn = GetConnection();
                conn.Open();
                result.AddGood("I can talk to the database");
            }
            catch (Exception)
            {
                result.AddAlert("I cannot open the connection");
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

            //can I connect to the database?
            if (OutputSql != null)
            {
                result.AddAlert(string.Format("I will run the sql '{0}'", OutputSql));
            }


            return(result);
        }
Пример #47
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            using (var remote = new CopyRemoteOut(_server))
            {
                //capture output
                var vresult = remote.CreateQueue(Address);
                result.AddAlert("REMOTE QUEUE - DID NOTHING");
            }

            return result;
        }
Пример #48
0
        public bool DoesSiteExist(DeploymentResult result)
        {
            var iisManager = ServerManager.OpenRemote(ServerName);
            foreach (var site in iisManager.Sites)
            {
                if (site.Name.Equals(WebsiteName))
                {
                    result.AddGood("'{0}' site exists", WebsiteName);
                    return true;
                }
            }

            result.AddAlert("'{0}' site DOES NOT exist", WebsiteName);
            return false;
        }
Пример #49
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (_address.IsLocal)
            {
                VerifyInAdministratorRole(result);
            }
            else
            {
                result.AddAlert("Cannot set permissions for the private remote queue '{0}' while on server '{1}'".FormatWith(_address.ActualUri, Environment.MachineName));
            }

            return(result);
        }
Пример #50
0
        public string Replace(string contents, DeploymentResult result)
        {
            var newContents = Regex.Replace(contents, _pattern, _replacement, _regexOptions);

            if (newContents == contents)
            {
                result.AddAlert("[filepoke] No replacement made for pattern '{0}'.", _pattern);
            }
            else
            {
                _log.InfoFormat("[filepoke] Pattern '{0}' replaced with '{1}' using options {2}.", _pattern, _replacement, _regexOptions);
            }

            return(newContents);
        }
Пример #51
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            validatePaths(result);

            _zipArchiveFilename = _path.GetFullPath(_zipArchiveFilename);
            _to = _path.GetFullPath(_to);

            if (_options == DestinationCleanOptions.Delete)
                result.AddAlert("The files and directories in '{0}' will be deleted before deploying", _to);

            testArchive(result);

            return result;
        }
Пример #52
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            IisUtility.CheckForIis7(result);

            var iisManager = ServerManager.OpenRemote(ServerName);
            CheckForSiteAndVDirExistance(DoesSiteExist, () => DoesVirtualDirectoryExist(GetSite(iisManager, WebsiteName)), result);

            if (UseClassicPipeline) result.AddAlert("The Application Pool '{0}' will be set to Classic Pipeline Mode", AppPoolName);


            ConfigureAuthentication(iisManager, result, false);

            return result;
        }
Пример #53
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (!MessageQueue.Exists(Address.LocalName))
            {
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(Address.FormatName));
                MessageQueue.Create(Address.LocalName, _transactional);
                result.AddGood("Created queue '{0}'".FormatWith(Address.FormatName));
            }
            else
            {
                result.AddGood("'{0}' already exists.".FormatWith(Address.FormatName));
            }

            return result;
        }
Пример #54
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            if (MessageQueue.Exists(Address.LocalName))
            {
                result.AddGood("'{0}' does exist");
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created.", Address.ActualUri));
            }

            return result;
        }
Пример #55
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            if (ServiceExists())
            {
                result.AddGood(string.Format("Found service '{0}'", ServiceName));
            }
            else
            {
                result.AddAlert(string.Format("Can't find service '{0}'", ServiceName));
            }

            return result;
        }
Пример #56
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = Path.GetFullPath(_from);
            _to = Path.GetFullPath(_to);

            //check can write from _to
            if (!Directory.Exists(_to))
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));

            if (Directory.Exists(_from))
            {
                result.AddGood(string.Format("'{0}' exists", _from));
                //check can read from _from
                string[] readFiles = Directory.GetFiles(_from);
                foreach (string file in readFiles)
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file, FileMode.Open, FileAccess.Read);
                        result.AddGood(string.Format("Going to copy '{0}' to '{1}'", file, _to));
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return result;
        }
Пример #57
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (UserName.ShouldPrompt())
                UserName = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(ServiceName));

            if (shouldPromptForPassword())
                Password = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(ServiceName, UserName));

            ServiceReturnCode returnCode = WmiService.Create(MachineName, ServiceName, ServiceDisplayName, ServiceLocation,
                                                             StartMode, UserName, Password, Dependencies);
            
            if (returnCode != ServiceReturnCode.Success)
                result.AddAlert("Create service returned {0}".FormatWith(returnCode.ToString()));
            else
                result.AddGood("Create service succeeded.");

            return result;
        }
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();
            base.VerifyInAdministratorRole(result);

            if (_server.IsLocal)
            {
                var cert = FindCertificateBy(_thumbprint, _storeName, _storeLocation, _server, result);
                if (cert == null)
                {
                    result.AddError("Certificate with thumbprint '{0}' was not found in the '{1}' \\ '{2}' store.".FormatWith(_thumbprint, _storeLocation, _storeName));
                }
            }
            else
            {
                result.AddAlert("Cannot verify if '{0}' exists because '{1}' is a remote server".FormatWith(_thumbprint, _server.Name));
            }


            return result;
        }
Пример #59
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyInAdministratorRole(result);

            try
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    ServiceControllerStatus currentStatus = c.Status;
                    result.AddGood(string.Format("Found service '{0}' it is '{1}'", ServiceName, currentStatus));
                }
            }
            catch (Exception)
            {
                result.AddAlert(string.Format("Can't find service '{0}'", ServiceName));
            }

            return result;
        }
Пример #60
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var iisManager = new ServerManager();

            if (DoesSiteExist())
            {
                result.AddGood("'{0}' site exists", WebsiteName);
                Site site = GetSite(iisManager, WebsiteName);

                if (!DoesVirtualDirectoryExist(site))
                {
                    result.AddAlert("'{0}' doesn't exist. creating.", VdirPath);
                    CreateVirtualDirectory(site);
                    result.AddGood("'{0}' was created", VdirPath);
                }
            }

            iisManager.CommitChanges();

            return result;
        }