Class: RefArchSetup::CLI
- Inherits:
-
Object
- Object
- RefArchSetup::CLI
- Defined in:
- lib/ref_arch_setup/cli.rb
Overview
Implements the command line subcommands
Instance Attribute Summary collapse
-
#options ⇒ hash
Options from the command line.
Instance Method Summary collapse
-
#check_for_missing_value ⇒ void
Check values of options to see if they are really an option.
-
#check_option(option, subcommand) ⇒ void
Checks for an option that is required by the sub command.
-
#initialize(options, bolt_options) ⇒ void
constructor
Initialize class.
-
#install ⇒ boolean
Installs a bootstrap version of mono on the target host using the provided tarball and pe.conf.
-
#install_bootstrap ⇒ boolean
Installs a bootstrap version of PE on the target host using the provided tarball and pe.conf.
-
#install_configure ⇒ boolean
Configures infrastructure nodes and do initial perf tuning.
-
#install_generate_pe_conf ⇒ boolean
Generates a pe.conf for use doing the install.
-
#install_pe_infra_agent_install ⇒ boolean
Installs an agent on infrastructure nodes.
-
#run(command, subcommand = nil) ⇒ boolean
Wrapper around commands.
Constructor Details
#initialize(options, bolt_options) ⇒ void
Initialize class
17 18 19 20 |
# File 'lib/ref_arch_setup/cli.rb', line 17 def initialize(, ) = = end |
Instance Attribute Details
#options ⇒ hash
Options from the command line
8 9 10 |
# File 'lib/ref_arch_setup/cli.rb', line 8 def end |
Instance Method Details
#check_for_missing_value ⇒ void
This method returns an undefined value.
Check values of options to see if they are really an option
optparse will gobble up the next option if no value is given This checks option values for things that start with – and then assumes the user forgot to provide a value This is okay as long as we don’t need to support values with –
36 37 38 39 40 |
# File 'lib/ref_arch_setup/cli.rb', line 36 def check_for_missing_value .each do |key, value| raise OptionParser::MissingArgument, key if value =~ /^--/ end end |
#check_option(option, subcommand) ⇒ void
This method returns an undefined value.
Checks for an option that is required by the sub command
54 55 56 57 58 59 |
# File 'lib/ref_arch_setup/cli.rb', line 54 def check_option(option, subcommand) return unless [option].nil? || [option].empty? option.tr!("_", "-") raise OptionParser::MissingOption, \ "option --#{option} is required for the #{subcommand} subcommand" end |
#install ⇒ boolean
Installs a bootstrap version of mono on the target host using the provided tarball and pe.conf
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ref_arch_setup/cli.rb', line 87 def install puts "Running install command" success = true success = install_generate_pe_conf unless .key?("pe_conf") # TODO: Pass pe.conf object along so we don't have to read/validate it in each subcommand success = install_bootstrap if success success = install_pe_infra_agent_install if success success = install_configure if success return success end |
#install_bootstrap ⇒ boolean
Installs a bootstrap version of PE on the target host using the provided tarball and pe.conf
114 115 116 117 118 119 120 121 122 |
# File 'lib/ref_arch_setup/cli.rb', line 114 def install_bootstrap puts "Running bootstrap subcommand of install command" # none of these will be required in the future... but are for now check_option("primary_master", "install") install_obj = RefArchSetup::Install.new(["primary_master"]) success = install_obj.bootstrap(["pe_conf"], ["pe_tarball"], ["pe_version"]) return success end |
#install_configure ⇒ boolean
Configures infrastructure nodes and do initial perf tuning
139 140 141 142 |
# File 'lib/ref_arch_setup/cli.rb', line 139 def install_configure puts "Running configure subcommand of install command" return true end |
#install_generate_pe_conf ⇒ boolean
Generates a pe.conf for use doing the install
103 104 105 106 107 |
# File 'lib/ref_arch_setup/cli.rb', line 103 def install_generate_pe_conf puts "Running generate-pe-conf subcommand of install command" # check_option("console_password", "install") # password hardcoded in base file for now return true end |
#install_pe_infra_agent_install ⇒ boolean
Installs an agent on infrastructure nodes
129 130 131 132 |
# File 'lib/ref_arch_setup/cli.rb', line 129 def install_pe_infra_agent_install puts "Running pe-infra-agent-install subcommand of install command" return true end |
#run(command, subcommand = nil) ⇒ boolean
Wrapper around commands
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ref_arch_setup/cli.rb', line 69 def run(command, subcommand = nil) check_for_missing_value BoltHelper. = comm = command unless subcommand.nil? str = subcommand.tr("-", "_") comm += "_" + str end success = send(comm) return success end |