Ejemplo n.º 1
0
 private IEnumerable <ApplicationArtifact> CreateApplicationArtifacts(ConDepOptions options, Assembly assembly)
 {
     if (options.HasApplicationDefined())
     {
         var type = assembly.GetTypes().SingleOrDefault(t => typeof(ApplicationArtifact).IsAssignableFrom(t) && t.Name == options.Application);
         if (type == null)
         {
             throw new ConDepConfigurationTypeNotFoundException(string.Format("A class inheriting from [{0}] must be present in assembly [{1}] for ConDep to work. No calss with name [{2}] found in assembly. ", typeof(ApplicationArtifact).FullName, assembly.FullName, options.Application));
         }
         yield return(CreateApplicationArtifact(assembly, type));
     }
     else
     {
         var types = assembly.GetTypes().Where(t => typeof(ApplicationArtifact).IsAssignableFrom(t));
         foreach (var type in types)
         {
             yield return(CreateApplicationArtifact(assembly, type));
         }
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public static void ExecuteFromAssembly(Assembly assembly, ConDepConfig envSettings, ConDepOptions options, IReportStatus status)
 {
     new ConDepConfigurationExecutor().Execute(assembly, envSettings, options, status);
 }