public static ConDepExecutionResult ExecuteFromAssembly(ConDepSettings conDepSettings, CancellationToken token) { try { if (conDepSettings.Options.Assembly == null) { throw new ArgumentException("assembly"); } var clientValidator = new ClientValidator(); var serverInfoHarvester = HarvesterFactory.GetHarvester(conDepSettings); var serverValidator = new RemoteServerValidator(conDepSettings.Config.Servers, serverInfoHarvester); var lbLookup = new LoadBalancerLookup(conDepSettings.Config.LoadBalancer); var artifactConfigHandler = new ArtifactConfigurationHandler(new ArtifactHandler(), new ArtifactDependencyHandler(), new ServerHandler(), lbLookup.GetLoadBalancer()); var sequenceManager = artifactConfigHandler.CreateExecutionSequence(conDepSettings); if (conDepSettings.Options.DryRun) { Logger.Warn("Showing execution sequence from dry run:"); sequenceManager.DryRun(conDepSettings); return(new ConDepExecutionResult(true)); } return(new ConDepConfigurationExecutor().Execute(conDepSettings, clientValidator, serverValidator, sequenceManager, token)); } catch (Exception ex) { Logger.Error("An error sneaked by.", ex); throw; } }
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); }