public BootstrapChefRunListOption(Func <IChefServer> chefServerFactory, ISchedulerWaiter schedulerWaiter, IFileSystemCommands fileSystemCommands) : base(chefServerFactory, schedulerWaiter, "boostraps chef to run the first time with the given policy name and group") { _fileSystemCommands = fileSystemCommands; }
public BootstrapChefPolicy(IFileSystemCommands fileSystemCommands, string config, string validator, BootstrapSettings bootstrapSettings) { _fileSystemCommands = fileSystemCommands; _config = config; _validator = validator; _bootstrapSettings = bootstrapSettings; }
public ProductInstaller(IFileSystem fileSystem, ProcessExecutor processExecutor, IFileSystemCommands commands, string prefix, string installLocation) { _fileSystem = fileSystem; _processExecutor = processExecutor; _commands = commands; _prefix = prefix; _installLocation = installLocation; }
public ProductInstaller(IFileSystem fileSystem, ProcessExecutor processExecutor, IFileSystemCommands commands, string installLocation, IDownloadUrlResolver downloadUrlResolver) { _fileSystem = fileSystem; _processExecutor = processExecutor; _commands = commands; _installLocation = installLocation; _downloadUrlResolver = downloadUrlResolver; }
private static string FindRuntimeIdentifier(IFileSystemCommands commands) { var deps = commands.ReadAllText("cafe.deps.json"); var identifiers = new[] { "win10", "win8", "win7" }; foreach (var identifier in identifiers) { if (deps.Contains(identifier)) { return(identifier); } } Logger.Warn( "Runtime identifier not found in cafe.deps.json, so we are assuming this is running on windows 10"); return("win10"); }
public static OptionGroup CreateRootGroup(IClientFactory clientFactory, ISchedulerWaiter schedulerWaiter, IFileSystemCommands fileSystemCommands, ProcessExecutor processExecutor, IFileSystem fileSystem, ServiceStatusWaiter serviceStatusWaiter, IEnvironment environment) { var root = new OptionGroup() .WithGroup("chef", chefGroup => { const string chefProduct = "Chef"; chefGroup.WithOption(new RunChefOption(clientFactory.RestClientForChefServer, schedulerWaiter), OptionValueSpecification.ForCommand("run"), OnNode()); chefGroup.WithOption( new DownloadProductOption <IChefServer, ChefStatus>(chefProduct, clientFactory.RestClientForChefServer, schedulerWaiter), CreateDownloadVersionSpecifications()); chefGroup.WithOption(new ShowChefStatusOption(clientFactory.RestClientForChefServer), OptionValueSpecification.ForCommand("status"), OnNode()); chefGroup.WithOption( new BootstrapChefRunListOption(clientFactory.RestClientForChefServer, schedulerWaiter, fileSystemCommands), OptionValueSpecification.ForCommand("bootstrap"), OptionValueSpecification.ForValue("run-list:", "the run list"), OptionValueSpecification.ForValue("config:", "the client.rb file"), OptionValueSpecification.ForValue("validator:", "the validator.pem file used to join the node"), OnNode()); chefGroup.WithOption( new BootstrapChefPolicyOption(clientFactory.RestClientForChefServer, schedulerWaiter, fileSystemCommands), OptionValueSpecification.ForCommand("bootstrap"), OptionValueSpecification.ForValue("policy:", "the policy name"), OptionValueSpecification.ForValue("group:", "the policy group"), OptionValueSpecification.ForValue("config:", "the client.rb file"), OptionValueSpecification.ForValue("validator:", "the validator.pem file used to join the node"), OnNode()); var installChefOption = new InstallOption <IChefServer, ChefStatus>(chefProduct, clientFactory.RestClientForChefServer, schedulerWaiter); chefGroup.WithOption(installChefOption, CreateInstallVersionSpecifications()); chefGroup.WithOption(installChefOption, OptionValueSpecification.ForCommand("upgrade"), OptionValueSpecification.ForVersion(), OnNode()); chefGroup.WithOption( ChangeChefRunningStatusOption.CreatePauseChefOption(clientFactory.RestClientForChefServer), OptionValueSpecification.ForCommand("pause"), OnNode()); chefGroup.WithOption( ChangeChefRunningStatusOption.CreateResumeChefOption(clientFactory.RestClientForChefServer), OptionValueSpecification.ForCommand("resume"), OnNode()); }) .WithGroup("inspec", inspecGroup => { const string inspecProduct = "InSpec"; inspecGroup.WithOption(new ShowInSpecStatusOption(clientFactory.RestClientForInspecServer), OptionValueSpecification.ForCommand("status"), OnNode()); inspecGroup.WithOption( new InstallOption <IProductServer <ProductStatus>, ProductStatus>(inspecProduct, clientFactory.RestClientForInspecServer, schedulerWaiter), CreateInstallVersionSpecifications()); inspecGroup.WithOption( new DownloadProductOption <IProductServer <ProductStatus>, ProductStatus>(inspecProduct, clientFactory.RestClientForInspecServer, schedulerWaiter), CreateDownloadVersionSpecifications()); }) .WithGroup("server", serverGroup => { serverGroup.WithDefaultOption(new ServerInteractiveOption()); serverGroup.WithOption(new ServerWindowsServiceOption(), "--run-as-service"); }) .WithGroup("service", serviceGroup => { serviceGroup.WithOption(new RegisterServerWindowsServiceOption(), "register"); serviceGroup.WithOption(new UnregisterServerWindowsServiceOption(), "unregister"); serviceGroup.WithOption(ChangeStateForCafeWindowsServiceOption.StartCafeWindowsServiceOption( processExecutor, fileSystem, serviceStatusWaiter), "start"); serviceGroup.WithOption(ChangeStateForCafeWindowsServiceOption.StopCafeWindowsServiceOption( processExecutor, fileSystem, serviceStatusWaiter), "stop"); serviceGroup.WithOption(new CafeWindowsServiceStatusOption(processExecutor, fileSystem), "status"); }) .WithGroup("job", statusGroup => { var statusOption = new StatusOption(clientFactory.RestClientForJobServer); statusGroup.WithDefaultOption(statusOption); statusGroup.WithOption(statusOption, OptionValueSpecification.ForCommand("status"), OnNode()); statusGroup.WithOption(new JobRunStatusOption(clientFactory.RestClientForJobServer), OptionValueSpecification.ForCommand("status"), OptionValueSpecification.ForValue("id:", "job run id"), OnNode()); }) .WithOption(new InitOption(AssemblyDirectory, environment), "init"); var helpOption = new HelpOption(root); root.WithOption(helpOption, "help"); root.WithDefaultOption(helpOption); return(root); }
public static OptionGroup CreateRootGroup(IClientFactory clientFactory, ISchedulerWaiter schedulerWaiter, IFileSystemCommands fileSystemCommands, ProcessExecutor processExecutor, IFileSystem fileSystem, ServiceStatusWaiter serviceStatusWaiter, IEnvironment environment) { var root = new OptionGroup() .WithGroup("chef", chefGroup => { const string chefProduct = "Chef"; Func <IChefServer> restClientForChefServerFactory = clientFactory.RestClientForChefServer; chefGroup.WithOption(new RunChefOption(restClientForChefServerFactory, schedulerWaiter), OptionValueSpecification.ForCommand("run"), OnNode()); chefGroup.WithOption( new DownloadProductOption <IChefServer, ChefStatus>(chefProduct, restClientForChefServerFactory, schedulerWaiter), CreateDownloadVersionSpecifications()); chefGroup.WithOption(new ShowChefStatusOption(restClientForChefServerFactory), OptionValueSpecification.ForCommand("status"), OnNode()); chefGroup.WithOption( new BootstrapChefRunListOption(restClientForChefServerFactory, schedulerWaiter, fileSystemCommands), OptionValueSpecification.ForCommand("bootstrap"), OptionValueSpecification.ForValue("run-list:", "the run list"), OptionValueSpecification.ForValue("config:", "the client.rb file"), OptionValueSpecification.ForValue("validator:", "the validator.pem file used to join the node"), OnNode()); chefGroup.WithOption( new BootstrapChefPolicyOption(restClientForChefServerFactory, schedulerWaiter, fileSystemCommands), OptionValueSpecification.ForCommand("bootstrap"), OptionValueSpecification.ForValue("policy:", "the policy name"), OptionValueSpecification.ForValue("group:", "the policy group"), OptionValueSpecification.ForValue("config:", "the client.rb file"), OptionValueSpecification.ForValue("validator:", "the validator.pem file used to join the node"), OnNode()); var installChefOption = new InstallOption <IChefServer, ChefStatus>(chefProduct, restClientForChefServerFactory, schedulerWaiter); chefGroup.WithOption(installChefOption, CreateInstallVersionSpecifications()); chefGroup.WithOption(installChefOption, OptionValueSpecification.ForCommand("upgrade"), OptionValueSpecification.ForVersion(), OnNode(), ReturnImmediatelyOrDelayed()); chefGroup.WithOption( ChangeChefRunningStatusOption.CreatePauseChefOption(restClientForChefServerFactory), OptionValueSpecification.ForCommand("pause"), OnNode()); chefGroup.WithOption( ChangeChefRunningStatusOption.CreateResumeChefOption(restClientForChefServerFactory), OptionValueSpecification.ForCommand("resume"), OnNode()); chefGroup.WithOption( new CheckProductVersionOption("chef", clientFactory.GenericRestClientForChefServer), OptionValueSpecification.ForCommand("version?"), OptionValueSpecification.ForVersion(), OnNode()); }) .WithGroup("inspec", inspecGroup => { const string inspecProduct = "inspec"; Func <IProductServer <ProductStatus> > productServerFactory = clientFactory.RestClientForInspecServer; AddProductOptionsTo(inspecGroup, inspecProduct, productServerFactory, schedulerWaiter); }) .WithGroup("server", serverGroup => { const string application = "cafe"; Func <IWin32Service> serviceCreator = () => new CafeServerWindowsService(); serverGroup.WithDefaultOption(new ServerInteractiveOption(application, serviceCreator)); serverGroup.WithOption(new ServerWindowsServiceOption(application, serviceCreator), "--run-as-service"); }) .WithGroup("service", serviceGroup => { ServiceOptionInitializer.AddServiceOptionsTo(serviceGroup, serviceStatusWaiter, processExecutor, fileSystem, CafeServerWindowsServiceOptions.ServiceName, CafeServerWindowsServiceOptions.ServiceDisplayName, CafeServerWindowsServiceOptions.ServiceDescription); }) .WithGroup("job", statusGroup => { var statusOption = new StatusOption(clientFactory.RestClientForJobServer); statusGroup.WithDefaultOption(statusOption); statusGroup.WithOption(statusOption, OptionValueSpecification.ForCommand("status"), OnNode()); statusGroup.WithOption(new JobRunStatusOption(clientFactory.RestClientForJobServer), OptionValueSpecification.ForCommand("status"), OptionValueSpecification.ForValue("id:", "job run id"), OnNode()); }) .WithOption(new InitOption(AssemblyDirectory, environment), "init"); AddProductOptionsTo(root, "cafe", clientFactory.RestClientForCafeProductServer, schedulerWaiter); var helpOption = new HelpOption(root); root.WithOption(helpOption, "help"); root.WithDefaultOption(helpOption); return(root); }
public FileSystem(IEnvironment environment, IFileSystemCommands commands) { _environment = environment; _commands = commands; }
public CafeInstaller(IFileSystemCommands commands, ProcessExecutor processExecutor, string cafeApplicationDirectory) { _commands = commands; _processExecutor = processExecutor; _cafeApplicationDirectory = cafeApplicationDirectory; }
public CafeInstaller(IFileSystemCommands commands, IDownloadUrlResolver resolver, string updaterDirectory) { _commands = commands; _resolver = resolver; _updaterDirectory = updaterDirectory; }
public WaitForInstallOption(IFileSystemCommands commands) : base("Waiting for install to complete") { _commands = commands; }