public DeploymentResult VerifyCanRun() { var results = new DeploymentResult(); results.AddNote(Name); //check you can connect to the _instancename //check that the path _scriptsLocation exists results.AddNote("I don't know what to do here..."); return(results); }
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); }
protected void VerifyRegistryHivePermissions(DeploymentResult result) { if (Hive == RegistryHive.CurrentUser) { result.AddNote("Elevated permissions not required for Registry Hive '{0}'", Hive.AsRegistryHiveString()); return; } }
public override DeploymentResult VerifyCanRun() { var result = new DeploymentResult(); if (!ServiceExists()) { result.AddNote("Cannot delete service '{0}', service does not exist".FormatWith(ServiceName)); } return(result); }
public override DeploymentResult VerifyCanRun() { var result = new DeploymentResult(); result.AddNote(_reason); if(_filesShouldExist.Count > 0) { var tmpDR = new DeploymentResult(); foreach(var filePath in _filesShouldExist) { string actualPath = _path.GetFullPath(filePath); if(!File.Exists(actualPath)) { tmpDR.AddError(" File '{0}' should exist!.".FormatWith(actualPath)); } } result.MergedWith(tmpDR); //errors show up anyway, give some feedback if everything OK. if(!tmpDR.ContainsError()) { result.AddNote(" All {0} files found!".FormatWith(_filesShouldExist.Count)); } } else { result.AddNote(" No Files that should exist."); } if(_directoriesShouldExist.Count > 0) { var tmpDR = new DeploymentResult(); foreach(var dirPath in _directoriesShouldExist) { string actualPath = _path.GetFullPath(dirPath); if(!Directory.Exists(actualPath)) { tmpDR.AddError(" Directory '{0}' should exist".FormatWith(actualPath)); } } result.MergedWith(tmpDR); //errors show up anyway, give some feedback if everything OK. if(!tmpDR.ContainsError()) { result.AddNote(" All {0} directories found!".FormatWith(_directoriesShouldExist.Count)); } } else { result.AddNote(" No Directories that should exist."); } if(_filesShould_NOT_Exist.Count > 0) { var tmpDR = new DeploymentResult(); foreach(var filePath in _filesShould_NOT_Exist) { string actualPath = _path.GetFullPath(filePath); if(File.Exists(actualPath)) { tmpDR.AddError(" File '{0}' should NOT exist!.".FormatWith(actualPath)); } } result.MergedWith(tmpDR); if(!tmpDR.ContainsError()) { result.AddNote(" None of the {0} files exist!".FormatWith(_filesShould_NOT_Exist.Count)); } } else { result.AddNote(" No Files that should NOT exist."); } if(_directoriesShould_NOT_Exist.Count > 0) { var tmpDR = new DeploymentResult(); foreach(var dirPath in _directoriesShould_NOT_Exist) { string actualPath = _path.GetFullPath(dirPath); if(Directory.Exists(actualPath)) { tmpDR.AddError(" Directory '{0}' should NOT exist".FormatWith(actualPath)); } } result.MergedWith(tmpDR); if(!tmpDR.ContainsError()) { result.AddNote(" None of the {0} directories exist!".FormatWith(_directoriesShould_NOT_Exist.Count)); } } else { result.AddNote(" No Directories that should NOT exist."); } if(_shouldAbortOnError && result.ContainsError()) { result.AddAbort(_reason); } return result; }
public override DeploymentResult Execute() { var result = new DeploymentResult(); if (!ServiceExists()) { result.AddNote("Cannot delete service '{0}', service does not exist".FormatWith(ServiceName)); } else { ServiceReturnCode returnCode = WmiService.Delete(MachineName, ServiceName); if (returnCode != ServiceReturnCode.Success) { result.AddAlert("Deleting service '{0}' failed: '{1}'".FormatWith(ServiceName, returnCode)); } } return(result); }
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); }
public DeploymentResult Execute() { var result = new DeploymentResult(); var psi = new ProcessStartInfo(Command, Args); psi.UseShellExecute = false; psi.CreateNoWindow = true; psi.RedirectStandardOutput = true; if (!string.IsNullOrEmpty(WorkingDirectory)) { psi.WorkingDirectory = WorkingDirectory; } psi.FileName = _path.Combine(WorkingDirectory, Command); string output; try { using (Process p = Process.Start(psi)) { //what to do here? p.WaitForExit(30.Seconds().Milliseconds); output = p.StandardOutput.ReadToEnd(); result.AddNote(output); } result.AddGood("Command Line Executed"); } catch (Win32Exception ex) { result.AddError( "An exception occured while attempting to execute the following remote command. Working Directory:'{0}' Command:'{1}' Args:'{2}'{3}{4}" .FormatWith(WorkingDirectory, Command, Args, Environment.NewLine, ex)); } return(result); }
//todo: there is quite a bit going on in here...this is going to need to be looked at... private void ExecuteOperation(ApplicationPool appPool, DeploymentResult result) { switch (Operation) { case Iis7Operation.StopApplicationPool: if (appPool == null) { result.AddAlert(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStopped()) { CheckForElevatedPrivileges(appPool.StopAndWaitForCompletion); result.AddGood("Application Pool '{0}' stopped.".FormatWith(ApplicationPool)); } else { result.AddNote("Application Pool '{0}' is not running.".FormatWith(ApplicationPool)); } break; case Iis7Operation.StartApplicationPool: if (appPool == null) { throw new InvalidOperationException(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStarted()) { IisUtility.WaitForIisToCompleteAnyOperations(); CheckForElevatedPrivileges(appPool.StartAndWaitForCompletion); result.AddGood("Application Pool '{0}' started.".FormatWith(ApplicationPool)); } else { result.AddGood("Application Pool '{0}' is already running.".FormatWith(ApplicationPool)); } break; } }
static void checkForSiteBindingConflict(ServerManager iisManager, string targetSiteName, IEnumerable<IisSiteBinding> targetBindings, DeploymentResult result) { if (targetBindings == null || !targetBindings.Any()) { result.AddNote("[iis7] No bindings specified for site '{0}'".FormatWith(targetSiteName)); return; } foreach (var targetPort in targetBindings.Select(x => x.Port)) { var conflictSite = iisManager.Sites .FirstOrDefault(x => x.Bindings.Any(b => b.EndPoint != null && targetPort == b.EndPoint.Port) && x.Name != targetSiteName); if (conflictSite != null) throw new InvalidOperationException( String.Format("Cannot create site '{0}': port '{1}' is already in use by '{2}'.", targetSiteName, targetPort, conflictSite.Name)); } result.AddGood("[iis7] No site binding conflicts detected."); }
public override DeploymentResult VerifyCanRun() { var result = new DeploymentResult(); result.AddNote(_reason); if (_filesShouldExist.Count > 0) { var tmpDR = new DeploymentResult(); foreach (var filePath in _filesShouldExist) { string actualPath = _path.GetFullPath(filePath); if (!File.Exists(actualPath)) { tmpDR.AddError(" File '{0}' should exist!.".FormatWith(actualPath)); } } result.MergedWith(tmpDR); //errors show up anyway, give some feedback if everything OK. if (!tmpDR.ContainsError()) { result.AddNote(" All {0} files found!".FormatWith(_filesShouldExist.Count)); } } else { result.AddNote(" No Files that should exist."); } if (_directoriesShouldExist.Count > 0) { var tmpDR = new DeploymentResult(); foreach (var dirPath in _directoriesShouldExist) { string actualPath = _path.GetFullPath(dirPath); if (!Directory.Exists(actualPath)) { tmpDR.AddError(" Directory '{0}' should exist".FormatWith(actualPath)); } } result.MergedWith(tmpDR); //errors show up anyway, give some feedback if everything OK. if (!tmpDR.ContainsError()) { result.AddNote(" All {0} directories found!".FormatWith(_directoriesShouldExist.Count)); } } else { result.AddNote(" No Directories that should exist."); } if (_filesShould_NOT_Exist.Count > 0) { var tmpDR = new DeploymentResult(); foreach (var filePath in _filesShould_NOT_Exist) { string actualPath = _path.GetFullPath(filePath); if (File.Exists(actualPath)) { tmpDR.AddError(" File '{0}' should NOT exist!.".FormatWith(actualPath)); } } result.MergedWith(tmpDR); if (!tmpDR.ContainsError()) { result.AddNote(" None of the {0} files exist!".FormatWith(_filesShould_NOT_Exist.Count)); } } else { result.AddNote(" No Files that should NOT exist."); } if (_directoriesShould_NOT_Exist.Count > 0) { var tmpDR = new DeploymentResult(); foreach (var dirPath in _directoriesShould_NOT_Exist) { string actualPath = _path.GetFullPath(dirPath); if (Directory.Exists(actualPath)) { tmpDR.AddError(" Directory '{0}' should NOT exist".FormatWith(actualPath)); } } result.MergedWith(tmpDR); if (!tmpDR.ContainsError()) { result.AddNote(" None of the {0} directories exist!".FormatWith(_directoriesShould_NOT_Exist.Count)); } } else { result.AddNote(" No Directories that should NOT exist."); } if (_shouldAbortOnError && result.ContainsError()) { result.AddAbort(_reason); } return(result); }
public override DeploymentResult Execute() { var result = new DeploymentResult(); using (var iisManager = ServerManager.OpenRemote(ServerName)) { var site = iisManager.Sites[SiteName]; if (site == null) result.AddNote(siteDoesNotExist); else { checkForElevatedPrivileges(() => Operation.Action(site)); iisManager.CommitChanges(); result.Add(new DeploymentItem(Operation.ReportingLevel, "Site operation '{0}' executed on '{1}'".FormatWith(Operation.Name, SiteName))); } } return result; }
private void checkSiteExists(ServerManager iisManager, DeploymentResult result) { if (!iisManager.Sites.Any(a => a.Name == SiteName)) result.AddNote(siteDoesNotExist); }
//todo: there is quite a bit going on in here...this is going to need to be looked at... private void ExecuteOperation(ApplicationPool appPool, DeploymentResult result) { switch (Operation) { case Iis7ApplicationPoolOperation.StopApplicationPool: if (appPool == null) { result.AddAlert(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStopped()) { CheckForElevatedPrivileges(appPool.StopAndWaitForCompletion); result.AddGood("Application Pool '{0}' stopped.".FormatWith(ApplicationPool)); } else { result.AddNote("Application Pool '{0}' is not running.".FormatWith(ApplicationPool)); } break; case Iis7ApplicationPoolOperation.StartApplicationPool: if (appPool == null) { throw new InvalidOperationException(ApplicationPoolDoesNotExistError); } else if (appPool.CanBeStarted()) { IisUtility.WaitForIisToCompleteAnyOperations(); CheckForElevatedPrivileges(appPool.StartAndWaitForCompletion); result.AddGood("Application Pool '{0}' started.".FormatWith(ApplicationPool)); } else { result.AddGood("Application Pool '{0}' is already running.".FormatWith(ApplicationPool)); } break; } }
public static DeploymentResult Tracer(Task task) { var r = new DeploymentResult(); r.AddNote(task.Name); return r; }
public DeploymentResult Execute() { var result = new DeploymentResult(); var psi = new ProcessStartInfo(Command, Args); psi.UseShellExecute = false; psi.CreateNoWindow = true; psi.RedirectStandardOutput = true; if (!string.IsNullOrEmpty(WorkingDirectory)) psi.WorkingDirectory = WorkingDirectory; psi.FileName = _path.Combine(ExecutableIsLocatedAt, Command); string output; try { using (Process p = Process.Start(psi)) { //what to do here? p.WaitForExit(30.Seconds().Milliseconds); output = p.StandardOutput.ReadToEnd(); result.AddNote(output); } result.AddGood("Command Line Executed"); } catch (Win32Exception ex) { result.AddError( "An exception occured while attempting to execute the following remote command. Working Directory:'{0}' Command:'{1}' Args:'{2}'{3}{4}" .FormatWith(WorkingDirectory, Command, Args, Environment.NewLine, ex)); } return result; }
public DeploymentResult VerifyCanRun() { var results = new DeploymentResult(); results.AddNote(Name); //check you can connect to the _instancename //check that the path _scriptsLocation exists return results; }
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; }
public void log_a_debug_event_containing(string message, params object[] args) { _results.AddNote(message, args); }
void BuildVirtualDirectory(Site site, ServerManager mgr, DeploymentResult result) { Magnum.Guard.AgainstNull(site, "The site argument is null and should not be"); var appPath = "/" + VirtualDirectoryPath; //this didn't find the application if there is a difference in letter casing like '/MyApplication' and '/Myapplication'. But threw an exception when tried to add it. //var application = site.Applications.FirstOrDefault(x => x.Path == appPath); var application = site.Applications.FirstOrDefault(x => x.Path.Equals(appPath, StringComparison.OrdinalIgnoreCase)); 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); }
void buildVirtualDirectory(Site site, 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("Virtual Directory '{0}' already exists. Updating settings.", VirtualDirectoryPath ?? "/"); } var apn = AppPoolName ?? DefaultAppPoolName; if (application.ApplicationPoolName != apn) { application.ApplicationPoolName = apn; LogFineGrain("[iis7] Set the ApplicationPool for '{0}' to '{1}'", VirtualDirectoryPath, apn); } var vdir = application.VirtualDirectories["/"]; var pon = PathOnServer ?? DefaultPathOnServer; if (vdir.PhysicalPath != pon) { vdir.PhysicalPath = pon; LogFineGrain("[iis7] Updated physical path for '{0}' to '{1}'", VirtualDirectoryPath, pon); } }
void Ex(Action<DeploymentDetail> action) { var result = new DeploymentResult(); result.AddNote(Name); foreach (var role in _roles) { result.AddNote(role.Name); role.ForEachServerMapped(s => { result.AddNote(s.Name); s.ForEachDetail(d => { result.AddNote(d.Name); action(d); }); }); } }
void updateSiteBindings(Site site, DeploymentResult result) { if (Bindings == null) { result.AddNote("No site bindings specified."); return; } LogFineGrain("Checking certificates on existing HTTPS bindings"); updateHttpsBindingCertificates(site, result); LogFineGrain("Adding new IIS bindings"); addnewBindings(site, result); LogFineGrain("Removing IIS bindings that are no longer required"); removeOldBindings(site, result); result.AddGood("Updated bindings for website '{0}'", WebsiteName); }