Beispiel #1
0
        public void Execute(CmdHelpWriter helpWriter)
        {
            var options = _parser.Parse();

            _validator.Validate(options);

            _helpWriter.PrintCopyrightMessage();

            var configFiles = new List <string>();

            if (!string.IsNullOrWhiteSpace(options.Env))
            {
                configFiles.Add(ConfigHandler.GetConDepConfigFile(options.Env, options.Dir));
            }
            else
            {
                configFiles.AddRange(ConfigHandler.GetConDepConfigFiles(options.Dir));
            }

            foreach (var file in configFiles)
            {
                var crypto = ConfigHandler.ResolveConfigCrypto(file, options.Key);

                System.Console.Out.WriteLine("\tDecrypting file [{0}] ...", file);
                crypto.DecryptFile(file);
                System.Console.Out.WriteLine("\tFile decrypted.");
                System.Console.WriteLine();
            }
        }
        public void Execute(CmdHelpWriter helpWriter)
        {
            helpWriter.PrintCopyrightMessage();

            Logger.WithLogSection("Bootstrap", () =>
            {
                var options = _parser.Parse();
                _validator.Validate(options);

                string ami;
                if (string.IsNullOrWhiteSpace(options.AmiId))
                {
                    var amiLocator = new Ec2AmiLocator(options.AwsProfileName);
                    ami = amiLocator.Find2012R2Core();
                }
                else
                {
                    ami = options.AmiId;
                }

                var bootstrapper = new Ec2Bootstrapper(options.AwsProfileName);
                var bootstrapId = bootstrapper.Boostrap(options.VpcId, ami, options.NumOfInstances == 0 ? 1 : options.NumOfInstances, options.RsaPrivateKeyPath);

                Logger.WithLogSection("Bootstrap finished", () =>
                {
                    Logger.Info("Bootstrap settings stored in: {0}", @"C:\temp\" + bootstrapId + ".json");
                    Logger.Info("To execute tests using the new server(s) do :");
                    Logger.Info("\tConDepTest test <your assembly> " + bootstrapId);
                    Logger.Info("To reset server(s) back into initial state do :");
                    Logger.Info("\tConDepTest reset " + bootstrapId);
                    Logger.Info("To terminate server(s) do :");
                    Logger.Info("\tConDepTest terminate " + bootstrapId);
                });
            });
        }
        public void Execute(CmdHelpWriter helpWriter)
        {
            var options = _parser.Parse();
            _validator.Validate(options);

            _helpWriter.PrintCopyrightMessage();

            var configFiles = new List<string>();

            if (!string.IsNullOrWhiteSpace(options.Env))
            {
                configFiles.Add(ConfigHandler.GetConDepConfigFile(options.Env, options.Dir));
            }
            else
            {
                configFiles.AddRange(ConfigHandler.GetConDepConfigFiles(options.Dir));
            }

            foreach (var file in configFiles)
            {
                var crypto = ConfigHandler.ResolveConfigCrypto(file, options.Key);

                System.Console.Out.WriteLine("\tDecrypting file [{0}] ...", file);
                crypto.DecryptFile(file);
                System.Console.Out.WriteLine("\tFile decrypted.");
                System.Console.WriteLine();
            }
        }
Beispiel #4
0
        public void Execute(CmdHelpWriter helpWriter)
        {
            var failed = false;

            try
            {
                var deployOptions    = GetDeployOptions(_deployParser, _deployValidator);
                var relayOptions     = GetRelayOptions(_relayParser, _relayValidator, deployOptions);
                var relayConfig      = GetRelayConfig(relayOptions, deployOptions);
                var artifactManifest = GetArtifactManifest(relayOptions, deployOptions);

                helpWriter.PrintCopyrightMessage();

                var status = new ConDepStatus();

                var handler = new RelayHandler();

                Logger.Info("Relaying command to available Relay server...");
                var result = handler.Relay(artifactManifest, relayConfig, new DeployOptions
                {
                    AssemblyName = deployOptions.AssemblyName,
                    BypassLB     = deployOptions.BypassLB,
                    ContinueAfterMarkedServer = deployOptions.ContinueAfterMarkedServer,
                    CryptoKey             = deployOptions.CryptoKey,
                    DryRun                = deployOptions.DryRun,
                    Environment           = deployOptions.Environment,
                    Runbook               = deployOptions.Runbook,
                    SkipHarvesting        = deployOptions.SkipHarvesting,
                    StopAfterMarkedServer = deployOptions.StopAfterMarkedServer,
                    TraceLevel            = deployOptions.TraceLevel,
                    WebQAddress           = deployOptions.WebQAddress
                });

                status.EndTime = DateTime.Now;

                if (result.Cancelled || result.Success)
                {
                    status.PrintSummary();
                }
                else
                {
                    status.PrintSummary();
                    failed = true;
                }
            }
            finally
            {
                if (failed)
                {
                    Environment.Exit(1);
                }
            }
        }
        public void Execute(CmdHelpWriter helpWriter)
        {
            helpWriter.PrintCopyrightMessage();

            Logger.WithLogSection("Terminate", () =>
            {
                var options = _parser.Parse();
                _validator.Validate(options);

                var config = LoadConfig(options.BootstrapId);
                var terminator = new Ec2Terminator(config.AwsProfileName);
                terminator.Terminate(options.BootstrapId, config.VpcId);
            });
        }
        public void Execute(CmdHelpWriter helpWriter)
        {
            _helpWriter = helpWriter;
            var options = _parser.Parse();
            _validator.Validate(options);

            if (options.NoOptions())
            {
                helpWriter.WriteHelp();
            }
            else
            {
                helpWriter.WriteHelpForCommand(options.Command);
            }
        }
Beispiel #7
0
        public void Execute(CmdHelpWriter helpWriter)
        {
            HelpWriter = helpWriter;
            var options = _parser.Parse();

            _validator.Validate(options);

            if (options.NoOptions())
            {
                helpWriter.WriteHelp();
            }
            else
            {
                helpWriter.WriteHelpForCommand(options.Command);
            }
        }
Beispiel #8
0
        public void Execute(CmdHelpWriter helpWriter)
        {
            var failed         = false;
            var conDepSettings = new ConDepSettings();

            try
            {
                conDepSettings.Options = GetOptions(_parser, _validator);
                conDepSettings.Config  = ConfigHandler.GetEnvConfig(conDepSettings);

                helpWriter.PrintCopyrightMessage();
                if (QueuingRequested(conDepSettings))
                {
                    _webQ = WaitInQueue(conDepSettings);
                }

                var status = new ConDepStatus();
                _tokenSource = new CancellationTokenSource();
                var token = _tokenSource.Token;

                var result = ConDepConfigurationExecutor.ExecuteFromAssembly(conDepSettings, token);

                status.EndTime = DateTime.Now;

                if (result.Cancelled || result.Success)
                {
                    status.PrintSummary();
                }
                else
                {
                    status.PrintSummary();
                    failed = true;
                }
            }
            finally
            {
                if (_webQ != null)
                {
                    Logger.Info("Leaving WebQ");
                    _webQ.LeaveQueue();
                }
                if (failed)
                {
                    Environment.Exit(1);
                }
            }
        }
Beispiel #9
0
        public void Execute(CmdHelpWriter helpWriter)
        {
            var options = _parser.Parse();

            _validator.Validate(options);

            var anySuccess  = false;
            var configFiles = new List <string>();

            if (!string.IsNullOrWhiteSpace(options.Env))
            {
                configFiles.Add(ConfigHandler.GetConDepConfigFile(options.Env, options.Dir));
            }
            else
            {
                if (string.IsNullOrEmpty(options.Dir))
                {
                    options.Dir = Directory.GetCurrentDirectory();
                }
                configFiles.AddRange(ConfigHandler.GetConDepConfigFiles(options.Dir));
            }

            helpWriter.PrintCopyrightMessage();
            System.Console.WriteLine();

            if (!options.Quiet)
            {
                System.Console.WriteLine("The following files will be encrypted:");
                configFiles.ForEach(x => System.Console.WriteLine("\t{0}", x));

                System.Console.Write("\nContinue? (y/n) : ");
                var choice = System.Console.Read();

                if (!Convert.ToChar(choice).ToString(CultureInfo.InvariantCulture)
                    .Equals("y", StringComparison.InvariantCultureIgnoreCase))
                {
                    System.Console.WriteLine();
                    System.Console.WriteLine("Aborted by user.");
                    return;
                }

                System.Console.WriteLine();
            }

            var key = GetKey(options);

            foreach (var file in configFiles)
            {
                System.Console.Out.WriteLine("\tEncrypting file [{0}] ...", file);
                try
                {
                    var crypto = ConfigHandler.ResolveConfigCrypto(file, key);
                    crypto.EncryptFile(file);
                    anySuccess = true;
                    System.Console.Out.WriteLine("\tFile encrypted.");
                }
                catch (ConDepCryptoException ex)
                {
                    System.Console.ForegroundColor = ConsoleColor.Red;
                    System.Console.Error.WriteLine("\tError: " + ex.Message);
                }
                System.Console.Out.WriteLine();
                System.Console.ResetColor();
            }

            if (anySuccess)
            {
                System.Console.ForegroundColor = ConsoleColor.Green;
                System.Console.Out.WriteLine("\tDecryption key: {0}", key);
                System.Console.Out.WriteLine("\tKeep this key safe!");
                System.Console.Out.WriteLine();
                System.Console.Out.WriteLine("\tWhen deploying or decrypting, use the /key option to provide key.");
                System.Console.ResetColor();
            }
        }
        public void Execute(CmdHelpWriter helpWriter)
        {
            var options = _parser.Parse();
            _validator.Validate(options);

            bool anySuccess = false;
            var configFiles = new List<string>();

            if (!string.IsNullOrWhiteSpace(options.Env))
            {
                configFiles.Add(ConfigHandler.GetConDepConfigFile(options.Env, options.Dir));
            }
            else
            {
                if (string.IsNullOrEmpty(options.Dir))
                {
                    options.Dir = Directory.GetCurrentDirectory();
                }
                configFiles.AddRange(ConfigHandler.GetConDepConfigFiles(options.Dir));
            }

            helpWriter.PrintCopyrightMessage();
            System.Console.WriteLine();

            if (!options.Quiet)
            {
                System.Console.WriteLine("The following files will be encrypted:");
                configFiles.ForEach(x => System.Console.WriteLine("\t{0}", x));

                System.Console.Write("\nContinue? (y/n) : ");
                var choice = System.Console.Read();

                if (!Convert.ToChar(choice).ToString(CultureInfo.InvariantCulture).Equals("y", StringComparison.InvariantCultureIgnoreCase))
                {
                    System.Console.WriteLine();
                    System.Console.WriteLine("Aborted by user.");
                    return;
                }

                System.Console.WriteLine();
            }

            var key = GetKey(options);

            foreach (var file in configFiles)
            {
                System.Console.Out.WriteLine("\tEncrypting file [{0}] ...", file);
                try
                {
                    var crypto = ConfigHandler.ResolveConfigCrypto(file, key);
                    crypto.EncryptFile(file);
                    anySuccess = true;
                    System.Console.Out.WriteLine("\tFile encrypted.");
                }
                catch (ConDepCryptoException ex)
                {
                    System.Console.ForegroundColor = ConsoleColor.Red;
                    System.Console.Error.WriteLine("\tError: " + ex.Message);
                }
                System.Console.Out.WriteLine();
                System.Console.ResetColor();
            }

            if (anySuccess)
            {
                System.Console.ForegroundColor = ConsoleColor.Green;
                System.Console.Out.WriteLine("\tDecryption key: {0}", key);
                System.Console.Out.WriteLine("\tKeep this key safe!");
                System.Console.Out.WriteLine();
                System.Console.Out.WriteLine("\tWhen deploying or decrypting, use the /key option to provide key.");
                System.Console.ResetColor();
            }
        }
Beispiel #11
0
 public void Execute(CmdHelpWriter helpWriter)
 {
 }
 public void Execute(CmdHelpWriter helpWriter)
 {
 }