private void Execute(Assembly assembly, ConDepConfig envConfig, ConDepOptions options, IReportStatus status) { if (assembly == null) { throw new ArgumentException("assembly"); } if (envConfig == null) { throw new ArgumentException("envSettings"); } if (options == null) { throw new ArgumentException("options"); } if (status == null) { throw new ArgumentException("status"); } var applications = CreateApplicationArtifacts(options, assembly); if(!options.WebDeployExist) { var serverValidator = new RemoteServerValidator(envConfig.Servers); if (!serverValidator.IsValid()) { Logger.Error("Not all servers fulfill ConDep's requirements. Aborting execution."); return; } } var webDeploy = new WebDeployHandler(); var lbLookup = new LoadBalancerLookup(envConfig.LoadBalancer); var sequenceManager = new ExecutionSequenceManager(lbLookup.GetLoadBalancer()); var notification = new Notification(); var postOpSeq = new PostOpsSequence(); foreach (var application in applications) { var infrastructureSequence = new InfrastructureSequence(); var preOpsSequence = new PreOpsSequence(webDeploy); if (!options.DeployOnly) { var infrastructureBuilder = new InfrastructureBuilder(infrastructureSequence, webDeploy); Configure.InfrastructureOperations = infrastructureBuilder; if (HasInfrastructureDefined(application)) { var infrastructureInstance = GetInfrastructureArtifactForApplication(assembly, application); if (!infrastructureSequence.IsValid(notification)) { notification.Throw(); } infrastructureInstance.Configure(infrastructureBuilder, envConfig); } } var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence(application.GetType().Name), infrastructureSequence, preOpsSequence, envConfig.Servers, webDeploy); Configure.LocalOperations = local; application.Configure(local, envConfig); } if (!sequenceManager.IsValid(notification)) { notification.Throw(); } sequenceManager.Execute(status, envConfig, options); postOpSeq.Execute(status, options); }
public SslInfrastructureBuilder(IManageInfrastructureSequence infrastructureSequence, IHandleWebDeploy webDeploy, InfrastructureBuilder infrastructureBuilder) { _infrastructureSequence = infrastructureSequence; _webDeploy = webDeploy; _infrastructureBuilder = infrastructureBuilder; }
private void Execute(Assembly assembly, ConDepConfig envConfig, ConDepOptions options, IReportStatus status) { if (assembly == null) { throw new ArgumentException("assembly"); } if (envConfig == null) { throw new ArgumentException("envSettings"); } if (options == null) { throw new ArgumentException("options"); } if (status == null) { throw new ArgumentException("status"); } var applications = new List<ApplicationArtifact>(); if(options.HasContext()) { var type = assembly.GetTypes().Where(t => typeof(ApplicationArtifact).IsAssignableFrom(t) && t.Name == options.Context).Single(); if (type == null) { throw new ConDepConfigurationTypeNotFoundException(string.Format("A class inheriting from [{0}] must be present in assembly [{1}] for ConDep to work.", typeof(ApplicationArtifact).FullName, assembly.FullName)); } var application = assembly.CreateInstance(type.FullName) as ApplicationArtifact; if (application == null) throw new NullReferenceException(string.Format("Instance of application class [{0}] in assembly [{1}] is not found.", type.FullName, assembly.FullName)); applications.Add(application); } else { var types = assembly.GetTypes().Where(t => typeof(ApplicationArtifact).IsAssignableFrom(t)); foreach(var type in types) { var application = assembly.CreateInstance(type.FullName) as ApplicationArtifact; if (application == null) throw new NullReferenceException(string.Format("Instance of application class [{0}] in assembly [{1}] is not found.", type.FullName, assembly.FullName)); applications.Add(application); } } IoCBootstrapper.Bootstrap(envConfig); var webDeploy = new WebDeployHandler(); var sequenceManager = new ExecutionSequenceManager(); var notification = new Notification(); foreach (var application in applications) { var infrastructureSequence = new InfrastructureSequence(); if (!options.DeployOnly) { var infrastructureBuilder = new InfrastructureBuilder(infrastructureSequence, webDeploy); if (HasInfrastructureDefined(application)) { var infrastructureInstance = GetInfrastructureArtifactForApplication(assembly, application); if (!infrastructureSequence.IsvValid(notification)) { notification.Throw(); } infrastructureInstance.Configure(infrastructureBuilder, envConfig); } } var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence(application.GetType().Name), infrastructureSequence, envConfig.Servers, webDeploy); if(!options.InfraOnly) { application.Configure(local, envConfig); } } if (!sequenceManager.IsValid(notification)) { notification.Throw(); } sequenceManager.Execute(status, envConfig, options); }